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
 General SQL Server Forums
 New to SQL Server Programming
 New rows from Database

Author  Topic 

rememberme
Starting Member

2 Posts

Posted - 2006-05-30 : 14:58:25
Hi,

I am new to SQL and I need help with following query.

I need to retrieve newly added columns from a table. Records will be added to this table on a daily basis and I need to retrieve the records added the previous day.

Can anyone help me with it.

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-30 : 15:04:09
Do you have a datetime column that records when the row was inserted?

Tara Kizer
aka tduggan
Go to Top of Page

rememberme
Starting Member

2 Posts

Posted - 2006-05-30 : 15:31:08
There is no datetime column in the data table.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-30 : 15:37:24
Then there is no way to retrieve this information unless you add such a column or use a trigger to capture the rows into another table.

Tara Kizer
aka tduggan
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-30 : 21:13:52
create a datetime column and set the default to getdate()
]
alter table yourtable
add create_date datetime default getdate()



KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-31 : 01:41:47
And do query

Where create_date >=DateAdd(day,datediff(day,0,getdate()),-1)
and create_date <DateAdd(day,datediff(day,0,getdate()),0)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -