I'm wondering if its possible to execute a stored procedure in an update statement in TSQL.
I want to execute a stored procedure that will set the CategoryID
for the number table, passing in the number from the row the update statement is currently on.
So something like:
UPDATE [TelephoneNumberManagement].[dbo].[Number]
SET [CategoryID] = exec goldennumbers2 [Number];
No.
You could do this if it were a function:
UPDATE [TelephoneNumberManagement].[dbo].[Number]
SET [CategoryID] = goldennumbers2([Number]);
Just keep in mind that a function can't have side-effects. If you're trying to run a bunch of DML statements in that procedure you should:
Number
table. Even so you might want to...Not really, there are some options like user-defined functions. Triggers might be able to do what you want, depending upon what you're trying to do and why.
What exactly does your goldennumbers2 procedure do?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With