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.
| Author |
Topic |
|
watherton
Starting Member
6 Posts |
Posted - 2004-09-13 : 13:50:20
|
| Hi guys a little question if I may.I have a DTS package that inserts new records into a project lines table. What i need to do is write a statement that returns the most recent lines, i.e package executes, inserts 10 new lines, i then pull back those ten lines. It is being used in a datagrid so i only need to pull back the most recent.any advice would be appreciated.regardsWayne |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-09-13 : 14:12:08
|
| Use the top keyword.SELECT TOP 10 [select columns]FROM [tables]WHERE [some where clause]ORDER BY [Date Column] DESC |
 |
|
|
watherton
Starting Member
6 Posts |
Posted - 2004-09-13 : 14:28:32
|
| Dustin thanks for the reply. If only it was that simply.The table does not have any fields that capture the date, so I can not do that, plus the insert of the records is done by a dts package converted from vb to vb.net and then to c#. The amount of records entered into the database can and will vary so I can not do a select top 10 as you suggested. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-09-13 : 23:02:29
|
| this is just an idea, is it possible to write the number of rows to a text file or a table to keep track how many rows were inserted?then you can make a select from the table based on the number of rows. but this will only work if your target table does not have any index or else, it will be sorted everytime the insert is done... |
 |
|
|
|
|
|