1.

Solve : Creation of database in MSSQL using Batch scritpt?

Answer»

I want to crate database in MSSQL using Batch script I used it by TWO WAYS.
[emailprotected] off
SET ServerName=%1



for /f %%a in ('dir /b *.sql') do call :process %%a

goto end
:process osql -E -S %ServerName% -n -i %1 >> Result.txt


echo %1
:end
It is not creating any database.

2.Created .sql file for cration of database and RUN it batch script

by giving C:\Program Files\Microsoft SQL Server\90\NotificationServices\9.0.242\Bin>
Create.sql

It is giving error as C:\Program Files not found.

Help me......
Path with SPACES needs quotes.
Quote from: pravinshembekar on October 11, 2007, 04:30:48 AM


for /f %%a in ('dir /b *.sql') do call :process %%a

goto end
:process osql -E -S %ServerName% -n -i %1 >> Result.txt


echo %1
:end
It is not creating any database.

This line is the problem
:process osql -E -S %ServerName% -n -i %1 >> Result.txt

This whole line is treated as a LABEL, move the osql to the line below .... you will almost certainly have a 0 byte file called Result.txt

Graham


Discussion

No Comment Found