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
Edit The following should be done - you need to quote the database name in the call to Sqlwb.exe For: 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 [data ES-Name]
: 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% "
& lt ; Machine_name & gt; \ SQLEXPRESS
by default.
Comments
Post a Comment