Hi
I am doing bulk insert as follows. The @.lastUpdate, @.filePath, @.formatFile comes as a parametes to stored proc
INSERT INTO Categories
SELECT CategoryId, @.LastUpdate FROM OPENROWSET
(
BULK @.filePath ,
FORMATFILE = @.formatFile,
FIRSTROW =2
)
AS a
This works fine for me.
But my new requirement is that i shouldn't insert the CategoryId if it exists
How can we have conditional bulk insert? i am using Bulk insert as the file might have millions of category Ids.
Please provide your inputs that executes much faster
Best Regards,
~Mohan Babu
Try
INSERT INTO Categories
SELECT CategoryId, @.LastUpdate FROM OPENROWSET
(
BULK @.filePath ,
FORMATFILE = @.formatFile,
FIRSTROW =2
)
AS a
where a.CategoryID not in (select distinct CategoryId from Categories )
No comments:
Post a Comment