| Author |
Topic |
|
Ex
Posting Yak Master
166 Posts |
Posted - 2005-05-05 : 23:32:05
|
| hey guys what stored proc can i use to exec a .sql file?also is there any way to give a .sql file a paramter when you run it?------------------------------------------------------------------Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Rich Cook |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-05-05 : 23:38:06
|
| The one you write.(But I'm guessing it will be something like xp_cmdshell calling osql)DamianIta erat quando hic adveni. |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-05-05 : 23:39:16
|
| You should load it into a .PDF file, import it into a BLOB, then use an extended stored procedure to read the contents of the .PDF file. You could load that into a temp table and use dynamic SQL with a cursor to execute it.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-05-05 : 23:40:30
|
| Ya know, you can also make three left turns instead of one right turn too... |
 |
|
|
Ex
Posting Yak Master
166 Posts |
Posted - 2005-05-05 : 23:49:35
|
| though there might be a nice easy way to do it but i will read the file into my app and exec it through the db connection------------------------------------------------------------------Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Rich Cook |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-05-05 : 23:51:26
|
| Look at osql in Books Online Ex. It should give you the information you need. You can execute the .sql file with that. The problem will be adding parameters.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
Ex
Posting Yak Master
166 Posts |
Posted - 2005-05-05 : 23:53:32
|
| that will do the trick, thanks derrick------------------------------------------------------------------Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Rich Cook |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-05-06 : 00:01:29
|
| It's pretty easy to pass parameters using a batch file, the only problem is that they are based on number/position, so you must ensure you pass them in the proper order. Paste the following into a text file and save it as northwind.bat:osql -Sserver -E -n -Q"select * from northwind..orders where customerid='%1'"Then run it like so:EXEC master..xp_cmdshell 'northwind.bat VINET'Using this technique is probably not too practical with a .SQL file though, but it should give you some ideas. Probably better to just make a stored procedure out of the script. |
 |
|
|
|