macleod1021
Programmer
Hi everyone...I'm having a brain fart here and beano(R) didn't help 
I have 2 views created that work great. The problem is that I need to dynamically determine the applications version number (which I've done) and then create the view based off of the version.
To keep this simple, I'm only concerned with 2 versions; 8 & 9.
What I've done so far is created each view and verify that they work individually. What I thought would work was to declare a variable, query for the app's version number and assign it to the variable. Then I used an if...else statement. Here's a shortened down version of what I have:
If (@version = 8)
Set QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.ActiveReceipts
AS
SELECT TOP 1000....(rest of view truncated for size)
GO
ELSE
IF (@version = 9)
PRINT 'Version 9'
I removed the other view creation script in order to test to make sure that it was working. This is how I discovered that it was running the first script, no matter what version number was returned. I also used a set command to make sure that @version was 9 and it still created the view.
Any help would be greatly appreciated.
Thanks in advance.
I have 2 views created that work great. The problem is that I need to dynamically determine the applications version number (which I've done) and then create the view based off of the version.
To keep this simple, I'm only concerned with 2 versions; 8 & 9.
What I've done so far is created each view and verify that they work individually. What I thought would work was to declare a variable, query for the app's version number and assign it to the variable. Then I used an if...else statement. Here's a shortened down version of what I have:
If (@version = 8)
Set QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.ActiveReceipts
AS
SELECT TOP 1000....(rest of view truncated for size)
GO
ELSE
IF (@version = 9)
PRINT 'Version 9'
I removed the other view creation script in order to test to make sure that it was working. This is how I discovered that it was running the first script, no matter what version number was returned. I also used a set command to make sure that @version was 9 and it still created the view.
Any help would be greatly appreciated.
Thanks in advance.