September 22, 2003 at 5:12 am
Hi all
Does anyone know if it's possible to write a UDF that will perform a bitwise or operation on all values in an int column inside a select - something like:
SELECT id, name, udf_BOR(permissions)
FROM
WHERE ....
ie. something that does the equivalent of the cursor:
FETCH NEXT FROM csr_Permissions INTO @curPermissions
WHILE (@@fetch_status = 0)
BEGIN
SET @permissions = @permissions | @curPermissions
FETCH NEXT FROM csr_Permissions INTO @curPermissions
END
but in a UDF.
It looks like it "might" be possible to do something with dynamic sql inside a UDF, but
that looked a pretty messy way to go (and I'm not sure if it would be a horribly inefficient thing to do).
The sp with a cursor is fine, but I thought it would be a useful thing to have as a general function.
I had a look in BOL, but this didn't seem to fit into any of the UDF categories -I'm not sure if I'm missing something obvious here or just trying to do something daft!
Thanks
Jon
September 22, 2003 at 5:27 am
Apologies - I just read the "Can this be done without a cursor?"
topic a couple of topics ago and it seems to answer my question!
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply