Is there any simple way to set max id of ID column using trigger before insert in MS SQL Server -


I've seen almost every post about this question, but some of them have not captured the best one I recommend using the identity , but I would also like to use the trigger to increase the integer column to some trigger because in this case more removed in my table will be given. Apart from this, as I have come mainly from Interbus DBMS, where I used to create one before the insert trigger on the table, so far this problem is useless till I have come to MS SQL Server from Interbase .

Thus, I declared the variable M integer as the currency currency_bi for the active currency before the interbase

  0. Choose from currency Maximum (ID) +1 Initially: M; If (: M is the tap) then M = 1; new.id =: meters; End   

So, as I should use it often, which is the best way to create a trigger that increases the integer columns using the maximum (ID) +1?

Do not use triggers to do this, kill performance based on your transaction usage Or cause all kinds of concurrency problems and locking.

It is better to use one of the available mechanisms in the engine-identifying property or sequence object.

If you are running a new version of SQL Server, use the sequence feature available, sequence it will allow you to reserve multiple AIDS from client applications and send them to the server to enter First, the client will assign them to new rows.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -