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
 General SQL Server Forums
 New to SQL Server Programming
 Can I execute .SQL file from a query?

Author  Topic 

jlowder
Starting Member

2 Posts

Posted - 2009-11-17 : 13:56:07
Hello,

I'm running some tests using Perl and the Win32:SQLServer module. From my SQL connection I'd like to be able to execute several .SQL files. Is this possible using SQL?

Thanks,

Jason

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-17 : 14:17:08
well..yes...using xp_cmdshell and isql, osql or sqlcmd



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

jlowder
Starting Member

2 Posts

Posted - 2009-11-17 : 14:22:05
I was actually looking for a means to do this via a query instead of kicking off a command line parameter. The problem with using those commands is that they appear to require authentication, even if you're set to use windows authority. At least osql is. sqlcmd won't even execute, claiming remote access is turned off even though that's not the case. I need a seamless way of executing these files without asking the user for input..

quote:
Originally posted by X002548

well..yes...using xp_cmdshell and isql, osql or sqlcmd



Brett

8-)


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-17 : 14:26:35
well, then...ummm...no



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-17 : 15:06:47
in that case why not just make a stored proc with the contents of the .sql file and execute that?
Go to Top of Page
   

- Advertisement -