|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
flatten rows into a variableDoes anyone know how to flatten rows into a variable using sql in a stored procedure? Such as getting a rowset like this : SELECT ID FROM SOMETABLE ID ---------- 1 2 3 4 5 6 7 And somehow get a variable containing 1234567 Regards Marteng Declare @ids varchar(8000)
Set @ids = '' SELECT @ids = @ids + CONVERT(varchar, ID) + ' ' FROM SOMETABLE Select @ids Show quote "MrMarteng" <mrmart***@hotmail.com> wrote in message news:uawEGqifFHA.484@TK2MSFTNGP14.phx.gbl... > Hi! > Does anyone know how to flatten rows into a variable using sql in a stored > procedure? > > Such as getting a rowset like this : > > SELECT ID FROM SOMETABLE > > > ID > ---------- > 1 > 2 > 3 > 4 > 5 > 6 > 7 > > > And somehow get a variable containing 1234567 > > Regards Marteng > >
Other interesting topics
|
|||||||||||||||||||||||