I am using SQL Server 2008. I have two table variables, such as
FirstName
==========
Little
John
Baby
LastName
==========
Timmy
Doe
Jessica
And I want the result table:
First Last
Little Timmy
John Doe
Baby Jessica
Note that PK cannot join the two tables. I am trying to use a cursor but don’t know how to start.
---- Updated -----
I know this is a rare case, but I am writing a script to clear outdated data. The only way we know Little is coming with Timmy is that they are the first record in the table. Would it help if we had a PC for tables, but there is no relation?
ID FirstName
1 Little
2 John
3 Baby
ID LastName
4 Timmy
5 Doe
6 Jessica
I am not familiar with TSQL, so I thought that I could iterate over 2 tables, for example, iterate over arrays in memory.
source
share