I've situation where I've to capture a DML executing against let say Table1 and later may at the end of the day or week I want to be able to extract all the DML executed against Table1 and execute them against similar tables on different sql server to synchronize the data. I don't want to use profiler as this is quite expensive resource for my problem niether can use any third party tool.
Is it possible to capture sql statement in the trigger?
I hope I made my question clear. Urgent help will be highly appreciated.
Is there a way to capture every change made in a database? I would like to be able to audit and report on all changes made in our corp. database. Is there a system tool or function that can accomodate such a thing? Transaction Log maybe??
Hi, We would like to capture events in our system. There seem to be three obvious capture points for us - application, triggers, transaction log. The latter seems to be the most attractive, since we`re looking for a solution with minimal performance impact. In general, our problem is similar to populating data warehouses from on-line databases. Can anyone proffer some advice? In particular, being quite new to SQL Server, I am not sure how difficult/possible it is to read the transaction log in order to cull events. Some direction here would be greatly appreciated. Thanks, Karl
Hi all, Is there anyway to capture the SQL Server Error and act accordingly? I donot want sql server to raise an error when a Primary key violation has occured. Instead i want to capture that error(number,description etc) and act accordingly. Whats happening is, from the application we are trapping this sql error and raising it. Instead, if somebody inserts a record which already exists, then we want to trap that error from the sqlprocedure itself and then do an update to that record.
I have this project that I need help with. There are 9 tables that I need to capture everything that happens to them (update, insert, delete). I was thinking of creating triggers. If someone does any of these actions against them then I need to insert into another table the date, the table name, the command that was run, and the records that are affected by it. Now I know how to do the date and table name, that's easy. My question is how do I capture the command. Once I have the command I can get the records affected.
I was wondering how you go about capturing text as it is entere into a textarea? i want it captured exactly as it is typed, with carriage returns and everything. is there an easy way to do this?
Access front-end, SQL Server 2005 backend.I have users connected to SQL Server via a Microsoft Access user-interface.Connection is via NT login.I want to log users' activities to the database with their userid.How can I capture their NT User ID (via VBA in Access)?Thanks,Bubbles
I have a stored procedure which will do 2 insert statements on 2 different tables. In my 2nd insert statement, I need to know how to capture the exact identity primary key value of the newly inserted record from the first insert statement. I am not sure how to get the correct key value of the new record because there may be more than one user inserting at the same time. Therefore, it is tough to capture the key value that belongs to the user doing his transaction at the time. Please help out. Thanks in advance.blumonde
In my BLL I have a method that adds a new row to a table in the database... [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)] public bool AddContact(string firstname, string lastname, string middleinit, bool active, Guid uid, bool newsletter) { ContactsDAL.tblContactsDataTable contacts = new ContactsDAL.tblContactsDataTable(); ContactsDAL.tblContactsRow contact = contacts.NewtblContactsRow(); contact.FirstName = firstname; contact.LastName = lastname; contact.MiddleName = middleinit; contact.Active = active; contact.UserID = uid; contact.Newletter = newsletter; contacts.AddtblContactsRow(contact); int rowsAffected = Adapter.Update(contact); return rowsAffected == 1; } The primary key in this table is a BigInt set as an identity column....How do I capture the value of the primary key that gets created when the new row is added?
I've a textbox that displays the current time in this format "hh:mm:ss tt" but when it is save into the database it'll display the date and time together. So how do I save only the time into the database? My codes is as shown below:
txtTime.Text = DateTime.Now.ToLongTimeString() Dim parameterDate As SqlParameter = New SqlParameter("@Date_5",SqlDbType.DateTime) parameterDate.Value = txtDate.Text objCommand.Parameters.Add(parameterDate)
I've tried using Format() but it still get the same results. Can someone help me out? Thanks!
Is there a way I can view the transaction log mean I want to see the transactions occurred during the last few hours before the commit? And is there a way to capture all the logins who access the DB
Does anybody know of a way to set up a task which will send an email with an attachment other than using sp_sendmail. Sp_SendMail will run a query and send the results as a text file. But I need to run a stored procedure which generates an Excel spreadsheet then have an email sent with the Excel file as an attachment. The sp_sendmail text file just doesn't work with the information I am generating so I need to find another solution.
I am trying to find a easy way of capturing the SQL user login that is being used for the the record row that is being added/updated. I am now using a insert and update trigger to update the last edit date and record add date. Is there a way I could incorporate the user login capturing within the triggers ???
I have to leave a production trace running for a couple of days to track down a little bit of data corruption. I am setting the stop time and maximum file size and I am running it from another machine and writing to a file and not a table and all of that good stuff.
however since I am going to be leaving this running for a while I do not want to deal with a gigantic file to sift through I am trying to limit my trace to all of the stored procs, which can be coming from other databases, to those inserting and and updating a particular table.
I have been goofing around with the Objects:Closed and Objects:Open and the SP:Starting And SP:Completed events, but I can not seem to make this work. I skimmed through the first 5 pages of my google search and my BOL search, but came up empty.
Is this possible? I thought I had done this before.
I need to capture the logout time and login time. I can capture the login time already but I cannot capture the logout time.My logout time and login time need to be on the same entry.This is the coding in the logout button:
Code: protected void logoutButton_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("SELECT TOP 1 LogId FROM LoggedInUsers where MemberID = @MemberID ORDER BY LogId DESC"); cmd.Parameters.AddWithValue("@MemberID", Session["MemberID"]); Session.Abandon(); }
I also need to do in global.asax. And this is the coding:
One of my co-worker told me I can do this to capture errors and insert into error table but when I test it, it doesn't work. Here is what I try to accomplish. SQL 2012. In reality, I have more complicate queries than below.
1. Insert data FROM SourceEmployee INTO Employee table and capture emp_id and error msg insert into dbo.##temperror table 2. Continue on the process until no more record. Basically, skip the error records and do a while loop until end of record.
--DROP TABLE dbo.Employee; CREATE TABLE [dbo].[Employee] ( [emp_id] [int] NOT NULL, [last_name] [varchar](20) NULL, [first_name] [varchar](15) NOT NULL,
I'm trying to organize this SQL query from a packet capture and I'm more of a network/application guy, not so much of a DBA. To me it looks like they are using variables in their query and the "@" is a delimiter.
S E L E C T [ t 0 ] . [ S E C T I O N N A M E ] , [ t 0 ] . [ P A R A M E T E R N A M E ] , [ t 0 ] . [ I N T V A L U E ] , [ t 0 ] . [ S T R I N G V A L U E ] , [ t 0 ] . [ D A T E V A L U E ] , [ t 0 ] . [ I N F R A S T R U C T U R A L ] , [ t 0 ] . [ S i t e P a r a m e t e r s I d ] F R O M [ d b o ] . [ S I T E _ P A R A M E T E R S ] A S [ t 0 ] W H E R E ( [ t 0 ] . [ S E C T I O N N A M E ] = @ p 0 ) A N D ( [ t 0 ] . [ P A R A M E T E R N A M E ] = @ p 1 ) @ 4@ @ p 0 n v a r c h a r ( 3 ) , @ p 1 n v a r c h a r ( 1 0 ) @ p 0 4 W e b @ p 1 4 M a x Q u e r i e s
Happy New Year everyone!I would like to capture CPU Utilization % using TSQL. I know this canbe done using PerfMon but I would like to run TSQL command (maybe onceevery 5 minutes) and see what is the CPU Utilization at that instant sothat I can insert the value in a table and run reports based on thedata.I have spent a good amount of time scouring google groups but this isall I have found:SELECT(CAST(@@CPU_BUSY AS float)* @@TIMETICKS/ 10000.00/ CAST(DATEDIFF (s, SP2.Login_Time, GETDATE()) AS float)) ASCPUBusyPctFROMmaster..SysProcesses AS SP2WHERESP2.Cmd = 'LAZY WRITER'Problem is this gives me total amount of time CPU in %) has been busysince the server last started. What I want is the % for the instant -the same number we see in Task Manager and PerfMon.Any help would be appreciated.Thanks
I trashed SQL Server2000 when I added the WINXP SP2, and had to reinstallit. When I did, my database(DEV_DATA) remained intact, but when I go inthru Enterprise Manager, it is not located in the system tree, and istherefore inaccessible. Can anyone suggest how I could get this databaseincluded.
I'm wondering if SSIS can capture the table schema structure, including the primary keys, foreign keys and indexes applied from the source table to the destination table? My source tables will be coming from AS400/DB2 and I'm using OLEDB Provider for DB2. I would like to automatically generate the table schema of my destination table in SQL Server 2005 (thru SSIS) as similar as my source table from AS400.
I'm new to sql server. Now I'm re-writing an application without any source code. I want to find out how the data is retrieved from the database. Can anyone give me any detail instructions or link to the documentation that tells this? There's no DBA here either. Thanks.
The following snippet of code returns something like that: string;string1;string2
Up to here fine. I woner how to export such value to ssis variable??? That variable will contain the value needed for the FILEATTACHMENTS property (Send Mail Task)
Thanks a lot,
declare @anex as varchar(500) declare @anex2 as varchar(700) set @anex2 = '' DECLARE anexos CURSOR FOR SELECT [Ruta] + [Fichero] as ANEXO FROM SVC_FICHEROS INNER JOIN SVC_ENVIOS ON SVC_FICHEROS.IDENVIO = SVC_ENVIOS.IDENVIO WHERE ENVIADO = 0 OPEN anexos; FETCH NEXT FROM anexos INTO @anex
WHILE @@FETCH_STATUS = 0 BEGIN IF @anex2 = '' begin set @anex2 = @anex end else begin set @anex2 = @anex2 + ';' + @anex end FETCH NEXT FROM anexos INTO @anex END CLOSE anexos DEALLOCATE anexos
I have a situation where my best solution is to capture the full Referrer URL in my SSRS 2005 Report to facilitate "Back" links within my reports. I have looked but don't see a way to capture this information natively in a report.
I have two groupings defined in my table. I group by Owner and then by Priority. I'm struggling with the expression to capture the string values at the appropriate scope. Using the table below, I want to capture "Critical, High" for "Jack Daniels" and "Medium, Low, Informational" for "Jim Beam". The table has "grpOwner" and "grpPriority" defined on Fields!Owner.Value and Fields!Priority.Value respectively. Any help would be greatly appreciated!
Recently I Restored a database from Live to Test Instance for implementing CDC feature on sql server 2008 X64 Enterprise Edition on Windows server 2008r2 X64.
Meant there was NO CDC Enabled in Production Nor Replication Features Its stand Alone.
Initially i Enabled CDC on Database level and next for 3 Tables, after that i inserted records for all the tables but the same was not getting reflected to CDC tables. then i checked in agent service-> CDC capture Job -> view history, then i got the following below error..
Message
Msg 22859, Level 16, State 2, Log Scan process failed in processing log records. Refer to previous errors in the current session to identify the cause and correct any associated problems. For more information, query the sys.dm_cdc_errors dynamic management view.
Date 14-Dec-13 8:07:35 AM Log Job History (cdc.HC_UAT_DB_V4_capture)
Step ID 2
Server ADDCSVHC05 Job Name cdc.HC_UAT_DB_V4_capture Step Name Change Data Capture Collection Agent Duration 00:34:29 Sql Severity 16 Sql Message ID 22859 Operator Emailed Operator Net sent Operator Paged Retries Attempted 11
Message
Executed as user: Testhcuat. Could not locate text information records for the column "ExMaritalStatus",
ID 189 during command construction. [SQLSTATE 42000] (Error 18773) The Log-Scan Process failed to construct a
replicated command from log sequence number (LSN) {00232390:00001fc9:0015}. Back up the publication database and
contact Customer Support Services. [SQLSTATE 42000] (Error 18805) Log Scan process failed in processing log
records. Refer to previous errors in the current session to identify the cause and correct any associated
problems. [SQLSTATE 42000] (Error 22859)
what is the cause for the below error and how i can get rid of this.
"ExMaritalStatus",column -> Nvarchar datatype
Note : issue can be solved by disabling & enabling CDC at database level but i need the root cause, again CDC capture job fails for capturing other Nvarchar columns when i Re-Enable at the database level. This cause is getting cycled/looping in capturing other colums.
Is it possible to capture the runtime metadata relating to the number of rows processed by a graph, the number of rows inserted/updated in the target blah blah using SSIS.
I have only seen metadata extensions for starttime, machine name etc. but not for this
Again, looking for the best way to do this with SSIS.
I have a source table and I'd like to load it to a database daily, capturing what changed.
This is not a dimentional table but a fact table.
So, what I;d need to do for each record is to see if the record already exists (using business key) and if it does - compare some of the data fields and of there are changes - register it somehow and if not changes ignore.
Right now, the only two ways I see to do it with SSIS:
- Use Slowly Chaging Dimentions transformation
- Use Lookup and customize SQL, adding something like: WHERE key = ? and (field1 <> ? or field2 <> ?...)