Page 1 of 1
SQL Server return values
Posted: Wed Aug 23, 2006 9:54 am
by manso
Hi,
I'm struggling with SQL Server script deployment. I'd like to be able to execute an SQL statement and feed the return value to a variable. More specifically, our app only works on 2005 and we would like to verify the version of SQL Server you are connecting to. We have other things we would like to do such as verify access rights before deploying script.
Can you point me in the right direction?
Thanks,
Manso
Posted: Wed Aug 23, 2006 1:23 pm
by MichaelNesmith
I think you can take care of these inside your SQL script.
The Check Service command and Read Registry commands may also be used to check for a particular version and instance of SQL Server.
Posted: Wed Aug 23, 2006 1:33 pm
by manso
Hi,
Thanks for your reply.
>> I think you can take care of these inside your SQL script.
I certainly can but there's no way I can communicate back what went wrong. All I get is ERROR.
>> The Check Service command and Read Registry commands may also
>> be used to check for a particular version and instance of SQL Server.
The SQL Server is not typically available on the same machine so this is not an option. This must be an issue for anyone targeting a specific db version, no?
I ended up writing a console application that takes care of the SQL struff. Simply SUCCESS/ERROR is not sufficient to build a solid db initialization imho. I now have a problem communicating back detailed error messages from the console application because I only have exit codes to work with but at least I can execute it multple times asking for version, create db, apply schema etc etc.
Regards,
Manso
Posted: Wed Aug 23, 2006 2:01 pm
by Gizm0
Instead of creating an console application, you can simply make your script echo the return codes/text/error message to a text file (within the SQL Script), and read it through the Read Text from File command of InstallAWARE.Of course what you read, you can put it on a variable.
I think it's far more easier that way..
Posted: Wed Aug 23, 2006 2:12 pm
by manso
How can I echo messages from SQLServer if the db instance is located on a locked down server somewhere? The installation is typically not being run on the db server. I can't find a way to get the result from SQLServer stored somewhere.
Thanks,
Manso