October 25, 2012 at 10:15 am
Declare @test-2 Table (First Nvarchar(10), Last Nvarchar(10))
Insert into @test-2 (First, Last) values ('Tom' ,'Jones')
Insert into @test-2 (First, Last) values ('John' ,'Jones')
Select First, Last From @test-2
Giving me the results of
FirstLast
TomJones
JohnJones
I need these results
FirstTomJohn
LastJonesJones
If a third insert is added
Insert into @test-2 (First, Last) values ('Mike' ,'Jones')
I would get
FirstTomJohnMike
LastJonesJonesJones
Running SQL2005
October 25, 2012 at 10:41 am
Have you read Jeff Moden's articles on cross tabs and Dynamic cross tabs? Search them in this site.
I don't remember if ROW_NUMBER is mentioned on the article, but this will help you to start.
SELECT First,
Last,
ROW_NUMBER() OVER( ORDER BY (SELECT NULL)) AS rn
FROM @test-2
October 25, 2012 at 11:10 am
the results of your select are
FirstLastrn
TomJones1
JohnJones2
these are not the results I am look for thank you
October 25, 2012 at 11:14 am
I told you that was a start.
What you need is dynamic code to include all columns needed.
Have you read the articles?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply