Mar 20, 2006 #1 delfy MIS Feb 8, 2005 96 JM here is an example of what i am trying to do declare @max_key select @max_key = max(key) from parts declare @parts_history table( parts_history_key int identity(1,@parts_history) ) why can't i use a variable in the identity function above
here is an example of what i am trying to do declare @max_key select @max_key = max(key) from parts declare @parts_history table( parts_history_key int identity(1,@parts_history) ) why can't i use a variable in the identity function above
Mar 20, 2006 #2 vongrunt Programmer Mar 8, 2004 4,863 HR This is T-SQL limitation. No big deal... create it as identity(1, 1) and then use parts_history_key + @max_key whenever you need "correct" value in SELECT statements. ------ [small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small] Upvote 0 Downvote
This is T-SQL limitation. No big deal... create it as identity(1, 1) and then use parts_history_key + @max_key whenever you need "correct" value in SELECT statements. ------ [small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]