| Author |
Topic |
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2010-04-08 : 04:54:21
|
| Dear All,I am having table with 5 column without any primary or identity column on it.I will daily insert nearly 1500 records.I want to fetch the last day records which are inserted.Please help me,i am having sysadmin access on the server.Thanks,Gangadhar |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-08 : 05:00:11
|
| Do you have a datetime column?MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-04-08 : 05:02:33
|
| You need a column with the date/time of the insert. You could set a DEFAULT on the column to create this automatically (when not provided by the INSERT statement) or an AFTER INSERT trigger to enforce that it is always created (i.e. even if the INSERT includes a (possibly incorrect) value.Then you can just ORDER BY the Created-Date column DESCENDING to get the most recently inserted records |
 |
|
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2010-04-08 : 05:09:17
|
| Thanks for your reply.Actually its already inserted data as of now i don't have any datetime column on this table.I want to fetch the data which last inserted.Yesterday i inserted some data without one column value so its impacting the business.Some how i need to fetch these records..in there any way to do this,,I tried using adding identity column but it didn't worked for me,,, |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-08 : 05:16:10
|
quote: Originally posted by gangadhara.ms Thanks for your reply.Actually its already inserted data as of now i don't have any datetime column on this table.I want to fetch the data which last inserted.Yesterday i inserted some data without one column value so its impacting the business.Some how i need to fetch these records..in there any way to do this,,I tried using adding identity column but it didn't worked for me,,,
If you inserted data without one column value, what value does the column has now?If it is null, tryselect columns from tablewhere col is nullMadhivananFailing to plan is Planning to fail |
 |
|
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2010-04-08 : 05:17:52
|
| yes Madhivanan the inserted records are NULL,But the table contains already some NULL values which i can't identify exactly can you please help me to get records for the last insertion |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-08 : 05:20:21
|
| then isnt it enough to update those records that have missed columns value as NULL?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-08 : 05:24:28
|
quote: Originally posted by gangadhara.ms yes Madhivanan the inserted records are NULL,But the table contains already some NULL values which i can't identify exactly can you please help me to get records for the last insertion
Then there is no easy wayMadhivananFailing to plan is Planning to fail |
 |
|
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2010-04-08 : 05:26:46
|
| Yes visakh i need to update for the yesterday inserted records with some value before that i need to identify the records which are inserted yesterday only.Actually there are some records with value NULL in that column before. So i need to identify the records which are inserted yesterday and need to update with value.Please help me i am having sys admin access. |
 |
|
|
|