Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I want to insert records into a table. On one of the columns I need to increment the column by one.
insert into partner(cus_no,cus_name,TP_id)select cus_no,cusname,123001+1????, from acecustomerData would look like:ABC customer1 1230001DEF Customer2 1230002GHI Customer3 1230003I need the TPID to start at a specific value.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-12-20 : 14:31:45
[code]DECLARE @StartValue intSET @StartValue = 123001insert into partner(cus_no,cus_name,TP_id)select cus_no,cusname,@StartValue + ROW_NUMBER() OVER (ORDER BY (SELECT 1))from acecustomer[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/