select mainline+'/'+subline from table1 where mainline='54326'
Here I m getting output like this
o/p:
Mainline
54326/1
54326/2
the above query i m getting output in two line
but i need an single line output like i mentioned below
Mainline
54326/1, 54326/2
anybody please post solution for this.....
Krishna GaradRank #191 · 12.8K reputationPosted Nov 29, 2011, 9:13 PM EST
DECLARE @test NVARCHAR(max)
SELECT @test = COALESCE(@test + ',', '') +Col1+'/'+ Col2 FROM
in my case o/p is like as you expeting
you can write like
Declare @test Nvarchar(max)
Select @test=COALESCE)@test+',',")+MainLine+'/'+SubLine From Table Select Mainline=@test
Pravin MoreRank #1,419 · 1.2K reputationPosted Nov 29, 2011, 9:16 PM EST
Hi Rajkumar,
its possible, do it like this....
declare @data varchar(max)
SELECT @data = COALESCE(@data + ', ', '') + mainline+'/'+subline from table1 where mainline='54326'
select @data
execute above query
Thanks,
Pravin.
Krishna GaradRank #191 · 12.8K reputationPosted Nov 29, 2011, 9:16 PM EST
DECLARE @test NVARCHAR(max)
SELECT @test = COALESCE(@test + ',', '') +Col1+'/'+ Col2 FROM Tblxyz Where Col1='1234' SELECT col1= @test
Rajkumar R175 reputationPosted Nov 29, 2011, 9:35 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts