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.
| Author |
Topic |
|
Rootman
Starting Member
15 Posts |
Posted - 2003-01-27 : 05:54:24
|
| The following works, and is designed to be called from a job. But is is good, bad or indifferent? Is there a better way? DECLARE @command as VARCHAR(8000) SET NOCOUNT ON CREATE TABLE #temp (line varchar(8000)) EXEC ('bulk INSERT #tempf FROM "G:\SQLLogs\TestSQL.txt"') SET @command = (SELECT * FROM #temp )EXEC (@command)DROP TABLE #tempThanks in advance |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2003-01-27 : 08:04:07
|
| Unless you didn't post all the code or you have a good reason for using dynamic sql this would be the same.DECLARE @command as VARCHAR(8000) SET NOCOUNT ON CREATE TABLE #temp (line varchar(8000)) BULK INSERT #tempf FROM 'G:\SQLLogs\TestSQL.txt'SELECT * FROM #temp DROP TABLE #temp |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-01-27 : 08:12:35
|
| If you need to actually execute the script, just use the osql command-line program:master..xp_cmdshell 'osql -iG:\SQLLogs\TestSQL.txt -Sserver -Uusername -Ppassword' |
 |
|
|
|
|
|