-
function in where clause
Hi All
I am writing a stored procedure which return rows
here's stored procedure
CREATE PROCEDURE [DBO].[SP_XYZ]
AS
SELECT * FROM TABLENAME WHERE FIELDNAME IN ([DBO].[FN_ABC])
FUNCTION [DBO].[FN_ABC] return something like that
'xx', 'AB','BC'
Now
I can't able to get query right stored procedure doesn't like function in where clause but i write some thing similar with out having function in where clause
SELECT * FROM TABLENAME WHERE FIELDNAME IN ('xx', 'AB','BC') it works fine.
let me explain what function is doing function get field in table which has value like xx;ab;bc;
function replaces ";" and rearrage value like 'xx','ab','bc'
Any advice or suggestion
Thanks
Ayaz
-
What type of function is fn_abc? Does it return string or table?
-
-
I did somthing like this and it work
SET @STRING = [DBO].[FUNCTIONAME](P1,P2)
EXEC ('SELECT * FROM TABLENAME WHERE (' + @STRING +')')
-
That should work or you can return table from function and use IN select functionname.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|