Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Table: <Table_Max id="1" note="some note1" date="2006-07-07T19:39:46" ID_NEW="1"/><Table_Max id="2" note="somenote2" date="2006-07-07T19:37:46" ID_NEW="1"/><Table_Max id="3" note="somenote3" date="2006-07-08T19:35:46" ID_NEW="2"/><Table_Max id="4" note="somenote4
select distinct id_new into #temp from Table_MaxDECLARE ac CURSOR FOR
SELECT * from #temp
OPEN ac-- Perform the first fetch and store the values in variables.
-- Note: The variables are in the same order as the columns
-- in the SELECT statement.DECLARE @id int
FETCH NEXT FROM ac
INTO @id-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
declare @maxP as datetimeset @maxP = ( select MAX([date]) from Table_Max where id_new = @id)
-- Concatenate and display the current values in the variables.
declare @note as nvarchar(4000)
set @note = ( select note from Table_Max where id_new = @id and [date] = @maxP)PRINT 'Last modified: ' + cast(@maxP as nvarchar(4000))+ ' for ID = ' + cast(@id as nvarchar(4000)) + ' NOTE = ' + @note
-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM ac
INTO @id
ENDCLOSE ac
DEALLOCATE ac
GO

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |