February 14, 2017 at 2:08 pm
You may also need to check the actual scripts themselves to be sure you don't have things that require a different execution context....
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
February 14, 2017 at 2:11 pm
Hey sgmunson,
yes I definitely made sure of that, i made sure to change to username and password and to use a domain account only, we use windows authentication only and not mixed mode for security reasons. stupid question, for the password, should I put quotations around the password? or is this exactly how it should be:
@ECHO OFF
FOR %%f IN (\\ServerB\Results\*.Sql) DO @ECHO Executing Script: "%%f" & SQLCMD -S ServerB\MSSQLSERVER -U Test -P Test -i "%%f" & @ECHO Completed Script: "%%f"
EXIT
OR:
@ECHO OFF
FOR %%f IN (\\ServerB\Results\*.Sql) DO @ECHO Executing Script: "%%f" & SQLCMD -S ServerB\MSSQLSERVER -U Test -P "Test" -i "%%f" & @ECHO Completed Script: "%%f"
EXIT
thanks for all your help, i know its something really small and stupid is just a minor thing, i made sure the user account exists and even gave the user account sysadmin rights and share folder read and write... just weird 🙁
February 14, 2017 at 2:15 pm
Siten0308 - Tuesday, February 14, 2017 2:11 PMHey sgmunson,
yes I definitely made sure of that, i made sure to change to username and password and to use a domain account only, we use windows authentication only and not mixed mode for security reasons. stupid question, for the password, should I put quotations around the password? or is this exactly how it should be:
@ECHO OFF
FOR %%f IN (\\ServerB\Results\*.Sql) DO @ECHO Executing Script: "%%f" & SQLCMD -S ServerB\MSSQLSERVER -U Test -P Test -i "%%f" & @ECHO Completed Script: "%%f"
EXIT
OR:
@ECHO OFF
FOR %%f IN (\\ServerB\Results\*.Sql) DO @ECHO Executing Script: "%%f" & SQLCMD -S ServerB\MSSQLSERVER -U Test -P "Test" -i "%%f" & @ECHO Completed Script: "%%f"
EXITthanks for all your help, i know its something really small and stupid is just a minor thing, i made sure the user account exists and even gave the user account sysadmin rights and share folder read and write... just weird 🙁
You shouldn't need to quote the password unless it contains spaces. Remind me again exactly how this job executes? I'm wondering about execution context.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
February 14, 2017 at 2:30 pm
All good, i sadly didnt mention how it was executed, this is in a SQL agent Job that would be executed once a week, ideally.
February 14, 2017 at 2:38 pm
Siten0308 - Tuesday, February 14, 2017 2:30 PMAll good, i sadly didnt mention how it was executed, this is in a SQL agent Job that would be executed once a week, ideally.
And perhaps finally, it may make sense that if the SQL Agent runs as a Windows domain account, that you not specify the userid or password, and instead specify -E to use a "Trusted Connection". It's more secure because the password for that account is not just sitting there in the batch file in plain text. Might solve the problem.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
February 14, 2017 at 2:39 pm
And, ... you'll need to be sure there is a SQL Login in place for the Windows domain account on the server that is the target of SQLCMD.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
February 14, 2017 at 2:43 pm
YOU SIR!!! Are you genius! i replaced -U and -P with -E like you said, THEN BAM!! WORKED... OH SO BEAUTIFUL 🙂
February 14, 2017 at 2:47 pm
Glad I could help...
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
February 14, 2017 at 6:26 pm
The next level of simplification exists in the following command... have a look.
https://technet.microsoft.com/en-us/library/cc753551(v=ws.11).aspx
--Jeff Moden
Change is inevitable... Change for the better is not.
February 14, 2017 at 7:47 pm
Jeff Moden - Tuesday, February 14, 2017 6:26 PMThe next level of simplification exists in the following command... have a look.
https://technet.microsoft.com/en-us/library/cc753551(v=ws.11).aspx
Yep... know about it, but as I haven't had time to track down every single option, my quick scan suggests that at least most of that functionaility exists in Windows 7 and above, if not identical functionality. I had to research the FOR command already today and I just don't have the time to add this one. I do admit, however, that it probably looks better whenever the more arcane options of FOR are used, based on using FORFILES instead.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
Viewing 10 posts - 16 through 24 (of 24 total)
You must be logged in to reply to this topic. Login to reply