isql -S . -U sa -P -i c:\abc.sql -b
if errorlevel 0 goto success
echo 'command failed'
goto end
:success
echo 'command worked
:end
This is always going to success though command fails sometimes.
This is my abc.sql
use master
-- database name
set @dbname=N'xyz'
if not exists(select * from master..sysdatabases where name=@dbname)
begin
declare @Sqlstr varchar(500)
set @Sqlstr = 'Create Database '
set @Sqlstr = @Sqlstr + @dbName
exec xp_cmdshell @Sqlstr
end
else
RAISERROR ('database creation error', 16,1)
go
if errorlevel 0 goto success
echo 'command failed'
goto end
:success
echo 'command worked
:end
This is always going to success though command fails sometimes.
This is my abc.sql
use master
-- database name
set @dbname=N'xyz'
if not exists(select * from master..sysdatabases where name=@dbname)
begin
declare @Sqlstr varchar(500)
set @Sqlstr = 'Create Database '
set @Sqlstr = @Sqlstr + @dbName
exec xp_cmdshell @Sqlstr
end
else
RAISERROR ('database creation error', 16,1)
go