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 have a table with following recordsId Identifier ProviderId CreatedBy CreatedDateGUID OR 123 X 01/01/2007GUID OK 123 X 01/01/2007GUID OM 123 X 01/01/2007GUID OL 234 X 01/01/2007I want to get the records corresponding to providerid ‘123’ and insert new set of records. So the final table will look likeId Identifier ProviderId CreatedBy CreatedDateGUID OR 123 X 01/01/2007GUID OK 123 X 01/01/2007GUID OM 123 X 01/01/2007GUID OL 234 X 01/01/2007GUID OR10 123 Y Todays dateGUID OK10 123 Y Todays dateGUID OM10 123 Y Todays dateI did this by selecting the first table in to a temporary table and loop, process and insert new set of records. Is there any efficient way of doing this?
[code]INSERT INTO Table (Identifier,ProviderId,CreatedBy,CreatedDate)SELECT Identifier+'10',ProviderId,'Y',GETDATE()FROM TableWHERE ProviderId=123[/code]i assume GUID is of type uniqueidentifier with default set to NEWID() or NEWSEQUENTIALID()
rakesh123
Starting Member
2 Posts
Posted - 2008-11-07 : 00:28:01
Thats just display of records in the format i needed (Select statement u specified). I want to have records physically inserted in the table.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-11-07 : 01:00:35
quote:Originally posted by rakesh123 Thats just display of records in the format i needed (Select statement u specified). I want to have records physically inserted in the table.
Did you had a chance to see INSERT on top of SELECT query? it really inserts values to table.