Skip to content

Instantly share code, notes, and snippets.

@rtipton
Created July 10, 2010 20:36
Show Gist options
  • Save rtipton/471000 to your computer and use it in GitHub Desktop.
Save rtipton/471000 to your computer and use it in GitHub Desktop.
SQL -- String Manipulation in SQL Server
DECLARE @testString VARCHAR(20)
SET @testString = 'Big Bang Theory'
SELECT LEN(@testString) AS _Length,
LEFT(@testString,3) AS _Left,
RIGHT(@testString,6) AS _Right,
SUBSTRING(@testString,5,4) AS _Substring,
REPLACE(@testString,'Bang', 'Bazinga') AS _Replace,
STUFF(@testString,5,0,'Big ') AS _Stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment