Gustav Brock
gustav at cactus.dk
Fri Jun 8 09:44:12 CDT 2012
Hi all I'm working on upsizing an Access backend to SQL Server and used Access' wizard for this. That worked with no errors. However, the client used Random Autonumber for IDs in Access and these are converted to integer with an associated trigger to create the random ID for new records: USE [PPT] GO /****** Object: Trigger [dbo].[T_UserLastDataTable_ITrig] Script Date: 06/08/2012 16:19:49 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[T_UserLastDataTable_ITrig] ON [dbo].[UserLastDataTable] FOR INSERT AS SET NOCOUNT ON DECLARE @randc int, @newc int /* EMULATION CODE FOR AUTONUMBERING */ /* * EMULATION CODE FOR RANDOM AUTONUMBERING FOR FIELD "ID" */ SELECT @randc = (SELECT convert(int, rand() * power(2, 30))) SELECT @newc = (SELECT ID FROM inserted) UPDATE UserLastDataTable SET ID = @randc WHERE ID = @newc Is this really the best method? Any disadvantages? Would we be better off changing ID in Access to either sequential IDs or even GUID before running the update wizard? /gustav