March 18, 2008 at 11:52 am
I need some t-sql advice please! I'm trying to get a notification if a table is not updated. I know it's something like..
If tablename.columnname <> now()
...
Any help appreciated! :unsure:
¤ §unshine ¤
March 19, 2008 at 8:27 am
It will be easy if your table has a column with timestamp data type. Here is an example.
DECLARE @Date DATETIME
SELECT @Date = MAX(DateUpdated) FROM myTable
IF @Date > DATEADD(d, -1, GETDATE())
BEGIN
SELECT * FROM master..sysdatabases --Replace your code here.
END
March 19, 2008 at 12:58 pm
It does have a datetime stamp.
the following code means???
DECLARE @Date DATETIME
--Select last update date
SELECT @Date = MAX(DateUpdated) FROM myTable
--If last update date is less than today
IF @Date > DATEADD(d, -1, GETDATE())
--what is this? I'm not sure what to replace to be able to
--get sql agent to notifiy me. Do I just place this whole code
--in the t-sql for sql agent job?
BEGIN
SELECT * FROM master..sysdatabases --Replace your code here.
END
¤ §unshine ¤
March 19, 2008 at 4:30 pm
SQL ORACLE (3/19/2008)
It will be easy if your table has a column with timestamp data type. Here is an example.DECLARE @Date DATETIME
SELECT @Date = MAX(DateUpdated) FROM myTable
IF @Date > DATEADD(d, -1, GETDATE())
BEGIN
SELECT * FROM master..sysdatabases --Replace your code here.
END
In SQL Server timestamp data type has nothing to do with either date or time.
It's just sequential number incrementing every time an update happens.
You may have a timestamp column in line with BINARY(8) column where you'll copy timestamp values every time you do your report or whatever you need to do.
Then you can see if the table was updated by doing this:
WHERE timestapm_col <> timestamp_onReport_col
_____________
Code for TallyGenerator
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply