Friday, February 10, 2012

constant

How do you define a constant in trigger definition? Thanks.There are no constants in SQL Server. Use DECLARE to declare variables and
SET to assign them.
Don't try to assign column values to variables in a trigger. Doing so forces
you to write cursor-like code to cope with multiple row updates. Try to
write set-based code in your triggers instead.
--
David Portas
SQL Server MVP
--|||Allen
I am not sure why do you need to do that?
There is no CONSTANS in SQL Server , probably you are talking about
DEFAULT.
If you insist , try somethin like that
DECLARE @.const INT
SET @.const=<VALUE>
""Allen Iverson"" <no_spam@.bk.com> wrote in message
news:eNV3onO4EHA.1452@.TK2MSFTNGP11.phx.gbl...
> How do you define a constant in trigger definition? Thanks.
>|||Uri,
Actually what I want to use it for is like this. I wrote a
temporarily table name for testing and later I need to change it to the real
one. I am thinking if I can define a constant table name so that I can just
change it in one place instead of replacing all over the trigger definition.
Can you please help? Thanks.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:OYxr1GP4EHA.1524@.TK2MSFTNGP09.phx.gbl...
> Allen
> I am not sure why do you need to do that?
> There is no CONSTANS in SQL Server , probably you are talking about
> DEFAULT.
> If you insist , try somethin like that
> DECLARE @.const INT
> SET @.const=<VALUE>
>
> ""Allen Iverson"" <no_spam@.bk.com> wrote in message
> news:eNV3onO4EHA.1452@.TK2MSFTNGP11.phx.gbl...
>> How do you define a constant in trigger definition? Thanks.
>>
>|||Why not do your testing in a separate database so that you can keep the same
object names? Surely you don't test this in a production database?
Other than that, search-and-replace is the best I can suggest.
--
David Portas
SQL Server MVP
--

No comments:

Post a Comment