November 16, 2012 at 4:25 am
Hi
I just want to execute a sql command stored in a sql file called test.sql through a batch file can you please advise how to write and run a batch file in window 7..
Thanks
Sqlbuddy
November 16, 2012 at 4:53 am
In command prompt type
SQLCMD/?
It will show various options,which will help you to create batch file .
if you want to execute test.sql trough batch file , you can use
SQLCMD -Sservername -Uusername -Ppassword -i"\\yourpath\Test.sql"
-----------------------------------------------------------------------------
संकेत कोकणे
November 16, 2012 at 5:39 am
Thanks for your reply, I have tried it but no joy, i just wondering do we have anything to do with windows authentication/permissions?
i have give as below
SQLCMD -S servername -U uid -P Pw -i"\\D:\x\y\Batch\QA\tables.sql"
November 16, 2012 at 5:45 am
venkat.2829 (11/16/2012)
Thanks for your reply, I have tried it but no joy, i just wondering do we have anything to do with windows authentication/permissions?i have give as below
SQLCMD -S servername -U uid -P Pw -i"\\D:\x\y\Batch\QA\tables.sql"
ohhh did you try this ?
SQLCMD -S servername -U uid -P Pw -i"D:\x\y\Batch\QA\tables.sql"
-----------------------------------------------------------------------------
संकेत कोकणे
November 16, 2012 at 5:49 am
If your using windows authentication then you replace the -U and -P switches for the -E switch, also remember that the switches are case sensitive.
November 16, 2012 at 5:53 am
yes i tried the same as this. if i try it from command prompt it is ending up with an error
HResult 0x35, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [53].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or in
stance-specific error has occurred while establishing a connection to SQL Server
. Server is not found or not accessible. Check if instance name is correct and i
f SQL Server is configured to allow remote connections. For more information see
SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.
November 16, 2012 at 6:02 am
What is your full SQLCMD call?
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply