Hinden
04-25-2005, 05:55 AM
Hi all,
First off let me apologise if this is the wrong forum for this post, but I couldn't see an SQL forum and as its for an ASP page...
I'm quite new to T-SQL and I'm writing a dynamic stored procedure. Bascially is the following code possible?
CREATE PROCEDURE sp_Anything
@BookingKey Int,
@functionFlag Int
AS
DECLARE
@theKey VARCHAR(20)
SET @theKey = "columnName"
SELECT blah blah
FROM blah blah
WHERE @theKey = @BookingKey
So basically I dont want to fix the column name in the Where clause. I'm aiming to put in an IF clause to seach for a user inputted variable (@functionFlag) which will affect which column is called in the WHERE clause. Can it be done?
Thanks in advance,
First off let me apologise if this is the wrong forum for this post, but I couldn't see an SQL forum and as its for an ASP page...
I'm quite new to T-SQL and I'm writing a dynamic stored procedure. Bascially is the following code possible?
CREATE PROCEDURE sp_Anything
@BookingKey Int,
@functionFlag Int
AS
DECLARE
@theKey VARCHAR(20)
SET @theKey = "columnName"
SELECT blah blah
FROM blah blah
WHERE @theKey = @BookingKey
So basically I dont want to fix the column name in the Where clause. I'm aiming to put in an IF clause to seach for a user inputted variable (@functionFlag) which will affect which column is called in the WHERE clause. Can it be done?
Thanks in advance,