Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
askmanojjain
Starting Member
10 Posts |
Posted - 2007-07-26 : 13:51:21
|
I have converted Access database to sql express. Access Database had AutoNumber FIelds for which trigger was generated by Upsizing wizard.Now when I import data from client the autonumber field value changes because trigger is fired which distroys all linksI want to modify trigger so that it generates new number only when it is not supplied in a insert command.Please help. Code is given below. Also suggest how to save because when I use save, it asks for a new .sql file name and a new file is generated instead of modifying the same triggerset ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER TRIGGER [dbo].[T_AcControlLimit_ITrig] ON [dbo].[AcControlLimit] FOR INSERT ASSET NOCOUNT ONDECLARE @randc int, @newc int /* FOR AUTONUMBER-EMULATION CODE *//* * RANDOM AUTONUMBER EMULATION CODE FOR FIELD 'IntAcControlCode' */SELECT @randc = (SELECT convert(int, rand() * power(2, 30)))SELECT @newc = (SELECT IntAcControlCode FROM inserted) UPDATE AcControlLimit SET IntAcControlCode = @randc WHERE IntAcControlCode = @newc |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-07-26 : 13:56:02
|
Duplicate, locking thread.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|