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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Knowing if Table was Changed?

Author  Topic 

Targe
Starting Member

3 Posts

Posted - 2008-10-24 : 15:10:44
I know there's a way to check if a column was changed but when a table of mine has over 100 columns in it, I'm thinking there must/should be a better way to know if the table was changed. Plus, I don't care which column was changed, so it does me little good. I just want to know if the table was changed. Anyone know of way?

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-10-24 : 15:41:17
when you say column was changed do you mean data type for a column was changed or the data in the column changed?
Go to Top of Page

Targe
Starting Member

3 Posts

Posted - 2008-10-24 : 15:58:22
Data in the column. Basically my form can be saved at any point and I have a history table which inserts a row saying it was updated (with other stuff, too). The problem is, if it was not updated in the real world sense (even though in SQL it was), I do not want to write a new row to the history table. So how can I tell if the table was changed or it remained the same?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-10-24 : 16:07:43
You can use triggers to know if a table was updated.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-10-24 : 16:13:08
so you want to check if any of the 100 columns you have in the table has changed or not?
you'll have to compare the fields your form is sending to the fields that are in the table.

Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-24 : 16:19:09
If you haven't been saving the last modified date to a table, you'll need to compare with previous backups...
Go to Top of Page

Targe
Starting Member

3 Posts

Posted - 2008-10-24 : 19:16:27
The trigger looks like it will work, thank you!
Go to Top of Page
   

- Advertisement -