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 Administration
 Ssms Issues/Automation Issue

Author  Topic 

bkstevens1
Starting Member

6 Posts

Posted - 2015-02-19 : 14:30:38
Hello,
I am trying to automate a .sql script to run using Task Manager. I was not having much luck getting it to run. So researching I thought to use command line to run the script instead.

I found information about using Ssms to launch MS SQL Server Management Studio and I can get as far as opening the blank Studio after logging in to the database. I however run into issues when I try to add my .sql script into the mix. The error I am getting is "The following files were specified on the command line: *insert file path here* These files could not be found and will not be loaded."

I have tried both suggestions on the web site of entering the code as such:

Ex 1. Ssms "C:\Scripts\file.sql"

Ex 2. Ssms "C:\Scripts\file.sql" -S server\database name -U user name -P password

Both give the same error as mentioned above. If I use the same commands without entering the file.sql either in the front or at the end of the line, Management Studio opens with blank window ready for use.

I can't seem to figure out why adding the additional step of the file name would cause it to stop working.

I would greatly appreciate any suggestions from the forum as I'm about to lose my mind!

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-19 : 16:10:50
use sqlcmd not ssms to run your script from task manager
Go to Top of Page

bkstevens1
Starting Member

6 Posts

Posted - 2015-02-19 : 16:36:32
quote:
Originally posted by gbritton

use sqlcmd not ssms to run your script from task manager



gbritton,

Thank you for the response. Please keep in mind that I am new to this so would you provide an example of using SQLCMD in a task manager environment? I attempted using SQLCMD in both the task manager and just in the command prompt. Neither option worked. I will continue to research to see if I can figure this out.

Thanks
bkstevens1
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-19 : 17:54:25
check these examples:
https://msdn.microsoft.com/en-us/library/ms180944.aspx?f=255&MSPPError=-2147217396
WHen you get it to work against your data, just put the whole command in a scheduled task
Go to Top of Page

bkstevens1
Starting Member

6 Posts

Posted - 2015-02-19 : 17:56:03
quote:
Originally posted by gbritton

use sqlcmd not ssms to run your script from task manager



Please disregard my last post. I have it working now. Thank you all for providing an invaluable service to the SQL community.

Thanks
bkstevens1
Go to Top of Page
   

- Advertisement -