Thanks Richard - this is just what I need, but there's a small bug.

The NewValue field is outputting the name of the field and not its
value.

T-SQL is not something I have a lot of experience with, and I've been
digging through the docs to see if I can figure out a solution, but no
luck so far. 

> declare @User_modify table(
>       UserID int,
>       FieldName nvarchar(50),
>       NewValue nvarchar(50)
> )
> declare @col sysname
> 
> declare colList cursor local fast_forward for
>       select  COLUMN_NAME
>       from    INFORMATION_SCHEMA.COLUMNS
>       WHERE   TABLE_NAME = 'USER_UPDATED'
> 
> open colList
> 
> -- loop over the column list @col will hold the current column
> fetch next from colList into @col
> while (@@fetch_status = 0) begin
>       -- insert matching records into the temp table
>       insert into @User_Modify(UserId, FieldName, newValue)
>               SELECT userid, @col,
>               cast(@col as sysname) as newValue
>               FROM users where @col > <cfqueryparam type="cf_sql_date"
> value="#since#">
> 
>       fetch next from colList into @col
> end
> 
> close colList
> deallocate colList
> 
> select * from @user_modify
> 
> This way you could offload a lot of the processing onto the SQL
server.
> 
> HTH,
> 
> Rich Kroll


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266150
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to