Running SQL query in batch file Error.
HI All,
SQLCMD -DESKTOP-SDMAAAAA\AAAAAAA DESKTOP-SDAAAA\Suresh Pasham -DelayVerification -E -Q "select * from [adv].[Route] where convert(date,CreatedDate)=convert(date,getdate())" -s "," -o "C:\Users\Suresh Pasham\source\DailySales.csv"
This is my query in my batch, when I run the batch file I am getting error : Invalid object name 'adv.Route'.
Outside of batch file, in sql instance it executes well. Thanks
can any answer please.
6 Replies
Can anyone answer this?
I'd be amazed... Are you running a program named
Suresh
?
I would expect it to be DelayVerification
, but that's not how the command reads.
Where did you get this program from?I am not using suresh as program name.
still I get the same error Invalid object name 'DelayVerification.adv.TempRoute'.
Query : select * from [DelayVerification].[adv].[TempRoute] where convert(date,CreatedDate)=convert(date,getdate())
I am thinking from batch file, how the query reads ? with schema ?
Complete error in the file : Msg 208, Level 16, State 1, Server DESKTOP-SDMATQT, Line 1
Invalid object name 'DelayVerification.adv.TempRoute'.
it would help to put things in a codeblock.
The Invalid Object Name error means that it can't find your database / table using adv.TempRoute as a target. Is adv your database? Schema? TempRoute is probably the table right?
In this case,
-DelayVerification
is a switch to sqlcmd
, which is the program being run. The DESKTOP- stuff makes it hard to parse visuallyadv. is my schema
You may have to add the database name ahead of the schema, so [database].[schema].[Table]