How to get SQLServer name

Hello,

Many times of our application patches need to update sql databases which in the client machines. I've read the instruction how to update it. There is a very important problem.

How do I know the client database server names and how do I pass the parameter to slqcmd command?

We stored the sql server name in the config file of exe and also in the registry.

Is there a way to read these info. then pass to this database name to .bat file before executing ?(like custom action in the setup)

Thank you,Peter

Hey Peter,

You can read values from the registry using Microsoft's "reg.exe" tool (included in all versions of Windows NT -- 2000, XP, Vista, 7, etc., etc.).

Here are 2 help documents I found after a few minutes of googling:

  1. Reading NT's Registry with REG Query
  2. Microsoft's Technet article using Reg Query

You can use "Reg query" in a batch file to read the database details from the registry, store them in a variable, then pass them to "slqcmd".

Tell me if this helps.

HiI am new to sql batch creation and update via wyupdate.Can you post sample code to get the server name and create the patch file.

No, we can't really post an example (beyond what we've already posted) because the batch file depends on what database you're using, how you store database information, etc.

Hiwe have store the database information in app config file . need to update the database information in script file from app config file and execute the batch file with the updated database information in script file.

need urgent help to do this, please post a sample code for this..

Sorry, we don't have the time to provide free developer services like writing application code. You should hire a programmer to do this for you. You already have the problem, you know what you want to do, now you just need the code to do it.