Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Conditionally creating a view in a batch file

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-10 : 12:30:00
Nils writes "isql does not allow 'create view' to exist inside of
a conditional Transact-SQL statement:

IF condition
BEGIN
create view ...
END

I want to conditionally create a view depending on the value
of the IDENTIFIER_CASE attribute returned by the sp_server_info
stored procedure. How can I do that in an isql batch program?

I am running on Windows 2000 Professional and SQL Server 2000 SP3.

- Nils Brubaker"

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-05-10 : 13:11:40
One option is to create multiple batches containing you DDL and conditionally execute the proper batch.
Go to Top of Page

Nils
Starting Member

5 Posts

Posted - 2004-05-10 : 14:18:57
I thought of calling another DDL batch file from inside my original batch file. I can't find anything in the Transact-SQL docs to describe how you do it. Could someone post an example?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-10 : 14:27:12
[code]

IF condition
EXEC master.dbo.xp_cmdshell 'osql -SServer1 -E -iC:\temp\CreateView.sql -oC:\temp\output.txt'

[/code]

Note the use of osql.exe instead of isql.exe. osql replaces isql. isql is provided for backward compatibility mode only.

Tara
Go to Top of Page
   

- Advertisement -