|
Posted by mutemode on 10/02/02 11:56
Thanks! Worked great. Sorry for not understanding it earlier Zeldor :)
Alexander Kuznetsov wrote:
> SET NOCOUNT ON
> go
>
> CREATE TABLE Target(TargetID INT PRIMARY KEY, someData CHAR(1))
> INSERT Target VALUES(1, 'A')
> INSERT Target VALUES(2, 'B')
> go
> create table staging(someData CHAR(1))
> INSERT staging VALUES('C')
> INSERT staging VALUES('D')
> go
> SELECT IDENTITY(INT, 1,1) AS TargetID, someData
> INTO #t FROM staging
>
> INSERT Target
> SELECT TargetID + (SELECT COALESCE(MAX(TargetID), 0) FROM Target),
> someData
> FROM #t
>
> go
> SELECT * FROM Target
> go
>
> TargetID someData
> ----------- --------
> 1 A
> 2 B
> 3 C
> 4 D
>
>
> DROP TABLE Target
> DROP TABLE Staging
> DROP TABLE #t
Navigation:
[Reply to this message]
|