Reputation: 46222
I had the following portion of a where - note that @TRUCK
is an input parameter of the stored proc:
WHERE TRUCK = COALESCE(@TRUCK, ATP.TRUCK) AND ...
I like to pass
SELECT value from dbo.fn_split(@TRUCK, '~')
in place of @TRUCK as I like to pass it a ~ delimited list.
I tried using:
WHERE TRUCK IN (COALESCE(SELECT value from dbo.fn_split(@TRUCK, '~')),ATP.TRUCK)
but got the following error:
Incorrect syntax near the keyword 'SELECT'.
Upvotes: 1
Views: 183
Reputation: 360672
You need to surround the subquery with ()
, and you've got the middle )
misplaced:
WHERE TRUCK IN (COALESCE((SELECT value from dbo.fn_split(@TRUCK, '~')),ATP.TRUCK))
Upvotes: 1
Reputation: 435
not sure - but i would expect you would have to assign the 'select value from dbo.fn...' to a local variable and then reference the local variable in the coalesce(...)
Upvotes: 0