tags:

views:

83

answers:

1

Question: I have an SQL function which returns a list of files

now I should join an additional list to that list with an union, but only if the user is admin.

Is that possible? Something like:

CREATE FUNCTION tfu_CMS_Process(@bIsAdmin bit  )
-- Add the parameters for the function here
RETURNS TABLE
AS
RETURN
 (
 SELECT * FROM TABLE1
 UNION 
 if bIsAdmin
 SELECT * FROM TABLE2
 end if
 )
+10  A: 
SELECT  *
FROM    table1
UNION ALL
SELECT  *
FROM    table2
WHERE   @isAdmin = 1
Quassnoi
I was going to suggest the use of a temp table, but this is the real answer.
ck
@Quassnoi: Leave some for us, eh? :)
OMG Ponies
`@OMG Ponies`: you had the whole week!
Quassnoi