I have a table with an auto incrementing identity/primary key column called ID.
CREATE TABLE Table1( [ID] [bigint] IDENTITY(1,1) NOT NULL, [TextContent] [nvarchar](450) NOT NULL, [Version] [bigint] NOT NULL) When I UPDATE [TextContent], I'd like [Version] to increment by one. The intent is to have a version for each row that increments anytime the row is updated.
Is there a reasonable way to do this within a single table? Something to do with computed column values and/or triggers perhaps?
I'm using MSSQL 2008 via Entity Framework.
Thanks for any info!
Versioncolumn be updated only on update ofTextContentcolumn, or on update of any column? In case of the latter, have a look at special rowversion column type, which is castable to bigint as well.