Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

delete row or sheet in excel from query

$
0
0

i want to delete row in excel file from query because when i insert data in 2nd time, data is not insert in proper place for example

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\TestDB\first.xls;',
'SELECT cid, ClassName FROM [Sheet1$]')
SELECT cid, classname FROM Class
GO

now rows insert from top row, it's fine. now i want to execute this again. i want to delete old data and insert new data. for this purpose i use this query

updateopenrowset('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D:\TestDB\first.xls;','SELECT cid, ClassName FROM [Sheet1$]')set cid=null,
classname=nullINSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\TestDB\first.xls;',
'SELECT cid, ClassName FROM [Sheet1$]')
SELECT cid, classname FROM Class
GO

Now insert from 60 row not in top row. I want to insert again in top row

please help thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>