How to print string value in horizantally in sql server

Murugavelmsc
Posted by Murugavelmsc under Sql Server category on | Points: 40 | Views : 1003
DECLARE @string VARCHAR(50)
DECLARE @wcount INT
DECLARE @index INT
DECLARE @len INT
DECLARE @char varchar(10)
SET @string = 'welcome'
SET @wcount= 0
SET @index = 1
SET @len= LEN(@string)
WHILE @index<= @len
BEGIN
set @char = SUBSTRING(@string, @index, 1)
print @char
SET @index= @index+ 1
END



Output:

w
e
l
c
o
m
e

Comments or Responses

Login to post response