Thursday, February 12, 2015

Get Last Character/s from a String in MS SQL Server

Execute the following:

DECLARE @varTmp NVARCHAR(20)

SET @varTmp = 'Hello World'

SELECT RIGHT(@varTmp,5)



OUTPUT:

World


Note: Same thing when trying to get only the first set of characters.

SELECT LEFT(@varTmp,5)

OUTPUT:

Hello

No comments:

Post a Comment