views:

603

answers:

4

I'm trying to completely automate my builds and part of it is applying SQL scripts to the SQL Server.
I've created a batch file that calls SQL Server utility (OSQL.EXE) to apply scripts and it works if I call it directly on the SQL server.
But I cannot use it on my build machine because it does not have SQL Server installed.

Is there way to start my batch on the remote machine from my build machine?
Is there another solution to this problem?

A: 

To use osql, you need SQL Server installed, but you could use another data access method to communicate from the remote machine to the SQL Server machine. For example, you could have a .VBS script use ADO.

Corey Trager
A: 

Two ideas:

  1. Have you tried copying OSQL.exe and installing the client SQL Server libraries on your build machine? I haven't but I think it's worth a try.

  2. Write a program that connects and feeds the data, shouldn't be too hard. Reads the SQL from a file and feeds it to the specified SQL Server.

Vinko Vrsalovic
If I were to copy osql.exe to my build machine, wouldn't that be copyright violation?
z-boss
Oh, I have no idea about that, good point
Vinko Vrsalovic
+1  A: 

You could install SQLExpress on your client machine for free and use sqlcmd.exe, which is an equivalent of osql and isql tools on MSSQLServer.

muratgu
+2  A: 

install just Sql Server Client

  • Microsoft SQL Server 2005 Management Objects Collection: and then you can use that to run any scripts or anything else from C#. so you could create a project that does the stuff with SMO and use it in your build setup.

  • Microsoft SQL Server 2005 Command Line Query Utility: installs just SQLCMD and do stuff with that.

Mladen Prajdic