I am trying to conditionally create a stored procedure in a Query
Analyzer script. When I have the CREATE PROCEDURE statement by itself
in the script, it compiles and runs ok. Once I put a condition on the
script, it does not run.
I have tried wrapping the script inside a BEGIN...END but it does not
help.
ex:
IF (SELECT [Version] FROM [tblDefaults]) < '5.11a'
CREATE PROCEDURE [dbo].[SelectByAccount]
@ARAcct int
AS
SELECT * FROM tblTable WHERE [AccountNo] = @Acct
This does not work.
I have also tried wrapping the entire CREATE PROCEDURE statement in an
EXEC() but that does not work when I have literals in the select
statement.
HELP!!
Thanks
Paul
Analyzer script. When I have the CREATE PROCEDURE statement by itself
in the script, it compiles and runs ok. Once I put a condition on the
script, it does not run.
I have tried wrapping the script inside a BEGIN...END but it does not
help.
ex:
IF (SELECT [Version] FROM [tblDefaults]) < '5.11a'
CREATE PROCEDURE [dbo].[SelectByAccount]
@ARAcct int
AS
SELECT * FROM tblTable WHERE [AccountNo] = @Acct
This does not work.
I have also tried wrapping the entire CREATE PROCEDURE statement in an
EXEC() but that does not work when I have literals in the select
statement.
HELP!!
Thanks
Paul
Comment