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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Convert Select to Delete

Author  Topic 

hambergler
Starting Member

9 Posts

Posted - 2010-06-25 : 00:18:57
Can someone help me convert this to a delete statement? I've tried nesting this into a delete statement but it gives me errors.


SELECT t1.* FROM tableNAME as t1 inner join
(SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D:\location\names.xls;HDR=No','SELECT * FROM [Sheet1$]')) as t2
on t1.Empname=t2.empname;



Let me know if you need any further information.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-25 : 01:18:21
Try:

DELETE t1
FROM tableNAME as t1 inner join
(SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D:\location\names.xls;HDR=No','SELECT * FROM [Sheet1$]')) as t2
on t1.Empname=t2.empname;

And if it gives errors then please post the error messages.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -