There is an application that users use to capture data. For each record a uniqueidentifier is created and added to a row(GUID).
There is a requirement to bulk upload by passing the application. Data is stored in excel. I am using the Microsoft.Jet.OLEDB.4.0 to select the data from Excel and doing C# SqlBulkCopy tyo insert the values.
Issue is setting the rowduid column to a new GUID for each record. How can i achieve this. I thought by doing something like a "Select *, newguid as ID FROM [sheet1$]" but i dont know if there is such a query in excel. Please help. Thanks.
(Since a default value of NEWID() can't be created) Can you do a post-insert UPDATE, such as ...
CREATE TABLE ##GUID(
ID INT,
ValueOne VARCHAR(1),
NewGuid UNIQUEIDENTIFIER
)
INSERT INTO ##GUID (ID,ValueOne)
VALUES (1,'A')
, (2,'B')
, (3,'C')
SELECT *
FROM ##GUID
-- after the INSERT, update the table with the GUID
UPDATE ##GUID
SET NewGuid = NEWID()
SELECT *
FROM ##GUID
DROP TABLE ##GUID
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.