![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
when doing this create view viewname as select * from table1 no trouble but when doing this if @temp 1 = 1 then begin create view viewname as select * from table1 suddenly sql server doesn't acknowledge the syntax in the create view statement ? how come ? The syntax is all wrong. @temp has not been declared. The if test has 3 |
#3
| |||
| |||
|
|
michael v wrote: when doing this create view viewname as select * from table1 no trouble but when doing this if @temp 1 = 1 then begin create view viewname as select * from table1 suddenly sql server doesn't acknowledge the syntax in the create view statement ? how come ? The syntax is all wrong. @temp has not been declared. The if test has 3 parameters, @temp, 1 and another 1? If in SQL does not use then. Crate view must be the first statement as well. Try this- declare @temp int set @temp = 1 if @temp = 1 begin exec('create view viewname as select * from sysobjects') end -- Darren Green http://www.sqldts.com http://www.sqlis.com |
![]() |
| Thread Tools | |
| Display Modes | |
| |