July 16, 2010 at 11:24 am
Hi,
We have a database to store all the data which is updated or deleted in other databases(around 50) inculding system name, ip address, updated time etc.. I am using triggers for this..
I would like to add one more column to store the query which is used to update or delete.
Can anyone help me on this..
Ram...
🙂
July 16, 2010 at 12:13 pm
ALTER TABLE changed_data ADD query_run VARCHAR(255) NULL ;
GO
http://msdn.microsoft.com/en-us/library/ms190273.aspx
_________________________________
seth delconte
http://sqlkeys.com
July 16, 2010 at 12:19 pm
Seth,
I am sorry for not giving my question cleary..
I would like to store the query into that column..
🙂
July 16, 2010 at 1:12 pm
I think there's a way to do that other than running Profiler to record the queries...
_________________________________
seth delconte
http://sqlkeys.com
July 16, 2010 at 3:37 pm
seth delconte (7/16/2010)
I think there's a way to do that other than running Profiler to record the queries...
Cool... what is it?
--Jeff Moden
Change is inevitable... Change for the better is not.
July 16, 2010 at 3:52 pm
Jeff Moden (7/16/2010)
seth delconte (7/16/2010)
I think there's a way to do that other than running Profiler to record the queries...Cool... what is it?
Typo...I meant I DON'T think there's a way...
_________________________________
seth delconte
http://sqlkeys.com
July 16, 2010 at 3:58 pm
I think still I didn't give much information about my problem..
Here is the clear information..
I have around 50 database with same schema..
I have one additional database to store the data which is updated or deleted in main databases. This database also has the same schema.. In addition to remaining databases.. this database tables have extra columns like-- database_name, action(updated , deleted), modified_date, modified by(IP address), sysname
I am using insert, update triggers in main databases..what ever the data modified, deleted in main databases, stores in this database..
My interest is to add another column and want to store the query to know how this updation have been done..
Please Suggest
🙂
July 16, 2010 at 4:46 pm
If it were me, I'd modify your table to add the column that you need.
I would then modify all of your triggers to include the information you want to populate to the new column.
July 16, 2010 at 4:51 pm
Tim.
Thanks for reply..
I will do all modifications what you have given... But I want to know how to get the particular query that effected the updation or deletion.. Here I want to store that query into the new column which causes to raise the trigger..
Thanks
🙂
July 16, 2010 at 4:52 pm
seth delconte (7/16/2010)
Jeff Moden (7/16/2010)
seth delconte (7/16/2010)
I think there's a way to do that other than running Profiler to record the queries...Cool... what is it?
Typo...I meant I DON'T think there's a way...
Heh... Damn! I thought you were on to something. Thanks anyway, Seth.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 16, 2010 at 4:56 pm
Ram:) (7/16/2010)
I think still I didn't give much information about my problem..Here is the clear information..
I have around 50 database with same schema..
I have one additional database to store the data which is updated or deleted in main databases. This database also has the same schema.. In addition to remaining databases.. this database tables have extra columns like-- database_name, action(updated , deleted), modified_date, modified by(IP address), sysname
I am using insert, update triggers in main databases..what ever the data modified, deleted in main databases, stores in this database..
My interest is to add another column and want to store the query to know how this updation have been done..
Please Suggest
I'm not sure if you'll find it useful or not but check out the "default trace". No sense reinventing the wheel.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 16, 2010 at 4:58 pm
Thanks all
🙂
July 16, 2010 at 5:05 pm
Are you trying to record the text of the dml that did the update? If the updates all come through procs, you might look at this:
http://www.sqlservercentral.com/articles/SQL+Server+2005+-+TSQL/2765/
Other than that, I don't know of any way to actually capture the text of executing sql from the sql itself.
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply