ajdeguzman ajdeguzman - 3 months ago 12
SQL Question

How to insert character in between a string in SQL Server 2008?

I need help in inserting a character inside a string, e.g.:

031613 05:39 AM


The output should be:

03/16/13 05:39 AM

Answer

You can use STUFF

DECLARE @String NVARCHAR(20) = '031613 05:39 AM'

SELECT STUFF(STUFF(@String,3,0,'/'),6,0,'/')

Fiddle

Comments