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
 Other SQL Server Topics (2005)
 delete and insert into SQL table using bat file

Author  Topic 

azreen
Starting Member

2 Posts

Posted - 2010-12-06 : 00:26:44
Dear all developer,

i'm new here and have question about bat file.
i have 1 file named as LOT.dat. This file i want it to automatically insert to SQL table named as LOT_SAP after delete existing data on it by using bat command.

any ideas how to do?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-06 : 04:38:20
Have a look at sqlcmd (the replacement for osql and isql). It's a command line utility that allows you to connect to sql server and execute commands.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

azreen
Starting Member

2 Posts

Posted - 2010-12-06 : 04:59:11
Nigel,

what is the right sqlcmd to use for this?
sorry, i'm still new with SQL and need help for this
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-06 : 05:13:50
sqlcmd is a command line utility.
It can take an sql statement which it can execute against a server. Can also take an input file of commands.

Have a look in bol.

Another option might be to create an ssis package which you can then call from a dtexec command in a bat file - but sqlcmd would be more lightweight.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -