Is there any way to pass a parameter into a view? What I'm trying to do is create a view based on a certain state.
DECLARE @state VARCHAR(2)
SET @state = 'CA'
SELECT * FROM tier2v2
WHERE tier2v2.STATE = @state
works fine, but when I try this:
DECLARE @state VARCHAR(2)
SET @state = 'CA'
CREATE VIEW TEMP_TABLE AS
SELECT * FROM tier2v2
WHERE tier2v2.STATE = @state
I get errors. I know this is probably a simple question, but I did search the forum and couldn't find anything that applied.
DECLARE @state VARCHAR(2)
SET @state = 'CA'
SELECT * FROM tier2v2
WHERE tier2v2.STATE = @state
works fine, but when I try this:
DECLARE @state VARCHAR(2)
SET @state = 'CA'
CREATE VIEW TEMP_TABLE AS
SELECT * FROM tier2v2
WHERE tier2v2.STATE = @state
I get errors. I know this is probably a simple question, but I did search the forum and couldn't find anything that applied.