Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

My Experiments with SQLServer
Browse by Tags · View All
SQLServer 126
SQLServer 2008 R2 91
SQLServer 2008 86
SQLServer 2005 82
SQL 60
Database 59
Sql And Me 57
Tips & Tricks 28
SQL Server 27
SQL FAQ 26

Archive · View All
May 2011 25
June 2011 21
July 2011 21
August 2011 19
April 2011 16
January 2013 4
May 2012 3
April 2012 3
October 2011 3
February 2013 2

Vishal Gajjar's Blog

SQL Functions – STUFF() and REPLACE()

Jul 6 2011 7:46PM by Vishal Gajjar   

STUFF() can be used to stuff a string into another string. It inserts the string at a given position, and deletes the number of characters specified from the original string.

-- © 2011 – Vishal (http://SqlAndMe.com)
 
DECLARE @string1 VARCHAR(20) = 'Microsoft Server'
DECLARE @string2 VARCHAR(20) = 'SQL Server 2005'
 
SELECT      @string1 + ' -> ' + STUFF(@string1, 11, 0, 'SQL ')
            AS 'String 1',
            @string2 + ' -> ' + STUFF(@string2, 15, 1, '8 R2')
            AS 'String 2'

Result Set:

String 1                                 String 2
—————————————- ————————————-
Microsoft Server -> Microsoft SQL Server SQL Server 2005 -> SQL Server 2008 R2
 
(1 row(s) affected)

In the first string it inserts 'SQL ' at specified position – 11, the third argument 0 indicated the number of characters to be deleted before inserting the new string.

For second string, we have deleted one (1) character starting from position 15, which deletes '5', and then it inserts the new string at position 15 – '8 R2'.

REPLACE():

REPLACE() replaces all the specified characters with new characters.

DECLARE @string3 VARCHAR(35) = 'sql 2005, sql 2008, sql 2008 r2'
 
SELECT @string3, REPLACE(@string3,'sql','SQL')

Result Set:

———————————–      ———————————–
sql 2005, sql 2008, sql 2008 r2   SQL 2005, SQL 2008, SQL 2008 r2
 
(1 row(s) affected)

However, it is not limited to same number of characters:

DECLARE @string3 VARCHAR(35) = '2008 R2'
 
SELECT @string3, REPLACE(@string3,'20','SQL Server 2')

Result Set:

————–       ————————
2008 R2              SQL Server 208 R2
 
(1 row(s) affected)

Hope This Helps! Cheers!


Republished from Sql&Me [31 clicks].  Read the original version here [32134 clicks].

Vishal Gajjar
46 · 4% · 1276
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]