Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Row Version Expand / Collapse
Author
Message
Posted Wednesday, October 23, 2013 9:40 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, September 30, 2014 7:01 AM
Points: 26, Visits: 67
I would like to try and get the Rowversion change snuck into the schedule sometime soon.

An overview of this plan:

If we use the following command we can add a rowversion column to every table in both our main and settings databases.
EXEC sp_MSforeachtable '
if not exists (select * from sys.columns
where object_id = object_id(''?'')
and name = ''RowVersion'')
begin
ALTER TABLE ? ADD [RowVersion] Rowversion NOT NULL;
end';

With the rowversion column in place we can quickly check that data we are about to update is not stale, without having to read entire row into memory.
This is targeted more at disconnected/web service application contexts.
Entity Framework can be configured to take advantage of the column as well.

The plan was to add a one-time entry into the each of the update scripts to initialize this on all of the tables. And then add code to always run this command after main data or setting data updates are triggered (actually do something).


Any tips how can I implement it??
Post #1507706
Posted Wednesday, October 23, 2013 10:10 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:10 AM
Points: 13,082, Visits: 12,546
Is what you have not working? Are you getting an error message?

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1507726
Posted Wednesday, October 23, 2013 10:41 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, September 30, 2014 7:01 AM
Points: 26, Visits: 67
I have not done the changes in Database so far but I was looking for any better option
Post #1507743
Posted Wednesday, October 23, 2013 10:45 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:10 AM
Points: 13,082, Visits: 12,546
sumair.haider (10/23/2013)
I have not done the changes in Database so far but I was looking for any better option


What you posted worked fine on a dev database I have. If you want to add this column to every single table in the database this is pretty much how I would do it.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1507747
Posted Wednesday, October 23, 2013 10:50 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:41 AM
Points: 40,187, Visits: 36,593
The only thing I would suggest is give the column a better name. You shouldn't use reserved words or datatype names as column names


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1507752
Posted Wednesday, October 23, 2013 12:03 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:10 AM
Points: 13,082, Visits: 12,546
GilaMonster (10/23/2013)
The only thing I would suggest is give the column a better name. You shouldn't use reserved words or datatype names as column names


+100000000000


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1507782
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse