Wednesday, November 03, 2010

Quotename Function in SQL

I have learned something very basic today from the sql share video today. It is about the Quotename TSQL function. This function I think is hardly used and hence some of the developers may not be aware of this. Hence I thought I will put my learning about this function here.
  • Quotename function returns the string along with the delimiters added in the function.
  • This function can be used if you are using the delimiters repeatedly.
  • If you are using delimiters on an ad-hoc basis you can just use something like select "-" +@variable +"-"
  • One requirement for using this funciton is that the string cannot be more than 128 characters long as depicted in Andy's video

Thanks to Andy Warren who explains the various ways of using the quotename function in this video.

No comments:

INSERT EXEC failed because the stored procedure altered the schema of the target table.

This morning I was trying to call a stored procedure and insert the results in a temp table using the following code  -- create table #...