SQL Server Questions and Answers
1. Difference between replace and Stuff function.
Answer: Replace function replaces all occurrences of a specified string value with another string value.
The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.
Replace function returns nvarchar if one of the input arguments is of the nvarchar data type; otherwise, REPLACE returns varchar and it returns NULL if any one of the arguments is NULL.
Stuff function returns character data if character_expression is one of the supported character data types and it returns binary data if character_expression is one of the supported binary data types.
Ex: Select Replace (‘ABC123DEF123’,’123’,’—‘)
The above code will replace all occurrence of 123 with — and output will be ABC—DEF—
Select Stuff(‘ABCDE’,2,3,’000’) will return A000E
2. Can I create Foreign Key with defining a Primary Key?
Answer: Yes, It is possible to create a Foreign Key without having a primary key.
Foreign key can be created by referring a Unique Key.
3 Comments »
Leave a Reply
-
Archives
- March 2013 (1)
- January 2013 (3)
- December 2012 (2)
- November 2012 (1)
- August 2012 (4)
- July 2012 (2)
- June 2012 (2)
- May 2012 (1)
- April 2012 (5)
- March 2012 (1)
- February 2012 (1)
- January 2012 (5)
-
Categories
-
RSS
Entries RSS
Comments RSS


From data perspective, what is the significance of usage of DBCC DROPCLEANBUFFERS, is this good practice to use this ? Objective is trying to read data from disk and memory.
Would like to know more about DBCC FREEPROCCACHE command from performance perspective
Hi Damodar,
Very Good Question.
When we do performance testing of any query or procedure, we remove the data cache so that the query will not use any cache.
I found a good article on this , please go through link : http://www.mssqltips.com/sqlservertip/1360/clearing-cache-for-sql-server-performance-testing/
and let me know if need any explanation.
Happy Reading
Thanks,
SQLcommitted