sql server 2005 - Why doesn't prompt for input in a batch file allow for a DASH character? -


I have this simple bit file program that I have written but if I enter a database name in which a " " Character. I'm not completely sure why, but I want to find a way around it? :: Open DB batch file @echo off :: SQL Server Management Studio Express 2005 :: starts and opens it to a specific database with the query: the window is already open CLS: SHOWDBNAMES echoed out database names found on this system: echo "% PROGRAMFILES% \ Microsoft SQL Server \ 90 \ Tools \ Binn \ OSQL.EXE" -h-1 -S -E-Q "Selection cast (as naming Naming (30)) from sysdatabases "@echo set DBNAME = set / P DBNAME = Which database name you want to open (from the list Select)? If "dBname%" = "" (resonance dunk I do not recognize your selection. Try again. Goto SELECTDB): SHOWTABLES cls echo echo tables which you can ask% DBNAME%: echo "% PROGRAMFILES% Use \ Microsoft SQL Server \ 90 \ Tools \ Binn \ OSQL.EXE "-h-1 -S-e-Q" [% DBNAME%]; Selection Cast (named as VARCHAR (30)). : RUNIT sqlwb.exe -nosplash -s-A-D% DBNAME% break: EOF

< P> Try to attach the database name to the square bracket:

[data ES-Name]

Edit

The following should be done - you need to quote the database name in the call to Sqlwb.exe For:

 : SHOWTABLES cls echo echo tables which you can ask with% DBNAME%: echo "% PROGRAMFILES% \ Microsoft SQL Server \ 90 \ Tool \ Binn \ OSQL.EXE" -h -1 -S-E-Q "selection cast (Named VARCHAR (30)) [% DBNAME%] Sys.Tables name by name "echo: RUNIT sqlwb.exe -nosplash -s-e-D"% DBNAME% " 

I have to ask - what does this script mean? The built-in SSMS Object Explorer gives you all this information free of charge.

In addition, your script does not take account of SQL Server instances except the default server - SQL Server Express is installed as & lt ; Machine_name & gt; \ SQLEXPRESS by default.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -