.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

String Format in SQL

Posted By:Hitendra       Posted Date: March 19, 2010    Points: 10    Category: SQL Query    URL: http://www.dotnetspark.com  

String Format in SQL
 

Using This sql Function We can Use String In sql Function


DROP FUNCTION dbo.fnFormatString
GO
CREATE FUNCTION dbo.fnFormatString(@format varchar(6000),
    @arg1 sql_variant,
    @arg2 sql_variant='',
    @arg3 sql_variant='')
RETURNS varchar(8000)
AS
BEGIN
RETURN  REPLACE(
    REPLACE(
    REPLACE(@format, '{0}', CAST(@arg1 as varchar(400))),
    '{1}', CAST(@arg2 as varchar(400))),
    '{2}', CAST(@arg3 as varchar(400)))
END
GO
PRINT dbo.fnFormatString('This {0} of works like {1} in that langauge {2}'
    , 'sorta'
    , 'string.Format()'
    , 'C#')

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply

    Read also another Resources from the same Author

Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend