SQL Express - Automate query and save as text
Posted on 2011-04-18
I'm trying to automate a query on an SQL Express db, Not too sure where to start.
I've written the query and am using Oracle SQL Developer (with the MS SQL Express JDBC driver), to run the query manually.
I want to automate that query to run as a daily task, and save the output as a text file. I don't know if there is way to automate this from within SQL Developer, so I started to try SQLCMD.
I can't seem to get the connection string correct though.
I'm connecting to another PC, using windows authentication.
I tried >sqlcmd -E -S host\sqlexpress
But get this error msg: HResult 0x274D, Level 16, State 1
TCP Provider: No connection could be made because the target machine actively re
Google offered that perhaps It's refused due not specifying the Port, so I tried:
>sqlcmd -E -S host\sqlexpress,1433
It does not make sense to me that I can connect with SQL Developer, but not sqlcmd. Is there a problem with my connection string? Do I need to install something else on my PC? Or should I use a different tool?
I do need to connect to a specific db called tempdata within SQLExpress, should I be including the specific db within the connection string as well?