String interpolation in T-SQL

Most programming languages have the ability to interpolate formatted strings. For example, in C#

1
String input = String.Format("oh hi {0}", "mike");

 

This is also possible in T-SQL through the use of two functions.
In SQL Server 2008 the function xp_sprintf was introduced

Also, in SQL Server 2012 the FORMATMESSAGE function was added.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s