Gud Evening all.... Here this query from Mr. Ravi and Kartheek - TopicsExpress



          

Gud Evening all.... Here this query from Mr. Ravi and Kartheek has given solution for this... Please try it works or not.... you can also got this in gmail .... Hi Friends, Can anyone please help me,how to write a query for this scenario: src table: col1 col2 a b a c a d output: col1 col2 a b,c,d and src: col1 col2 a b,c,d output:: col1 col2 a b a c a d use sampledb create table example (number int, name varchar(20)) insert into example select 1,ravi union all select 2,raju union all select 3,sirisha union all select 4,seetha update example set number=1 where number=4 update example set number=1 where number=3 update example set number=1 where number=2 select * from example --The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position. declare @names varchar(200) set @names= select distinct number,STUFF ((select ,+@names+name from example as e where e.number=a.number for XML path()),1,1,) as names from example a insert into example select 2,seetha union all select 2,sirisha union all select 2,hari declare @names varchar(200) set @names= select distinct number,STUFF ((select ,+@names+name from example as e where e.number=a.number for XML path()),1,1,) as names from example a
Posted on: Tue, 08 Jul 2014 12:34:14 +0000

Trending Topics



Recently Viewed Topics




© 2015