Showing posts with label insert. Show all posts
Showing posts with label insert. Show all posts

Friday, March 9, 2012

Monitoring database activities from outside SQL Server

Hi,

I want to know how can I monitor some operations that are executed on a SQL Server database. Operations like: INSERT, DELETE, UPDATE, transactions, and so on (I know that I can do this using triggers, but doing this way I'll have to fill a table with the information from the triggers and stay loading the table data all the time. I want a way to monitor using other resources, in realtime).

My idea is to build a program to monitor these activities (developed in C# to be more exactly). How can I do this?

Thanks

PS: I know that we already have commercial products to do this, but I need to develop one.

WHy not just use a trace and export it to whatever external app you want to review?

I usually create my traces using sp_**trace, then I've set up external apps to call the trace and view the results.

|||

The problem is...if I create some triggers and Stored Procedures, my program will have to stay selecting data for long cycles. I'd like to have something automated, so when something occurs, automatically my program understands it.

Must have a way to do this, because I think SQL Profiler wouldn't use SELECTs to get Performance and Counting info.

Monitoring database activities from outside SQL Server

Hi,

I want to know how can I monitor some operations that are executed on a SQL Server database. Operations like: INSERT, DELETE, UPDATE, transactions, and so on (I know that I can do this using triggers, but doing this way I'll have to fill a table with the information from the triggers and stay loading the table data all the time. I want a way to monitor using other resources, in realtime).

My idea is to build a program to monitor these activities (developed in C# to be more exactly). How can I do this?

Thanks

PS: I know that we already have commercial products to do this, but I need to develop one.

WHy not just use a trace and export it to whatever external app you want to review?

I usually create my traces using sp_**trace, then I've set up external apps to call the trace and view the results.

|||

The problem is...if I create some triggers and Stored Procedures, my program will have to stay selecting data for long cycles. I'd like to have something automated, so when something occurs, automatically my program understands it.

Must have a way to do this, because I think SQL Profiler wouldn't use SELECTs to get Performance and Counting info.

Saturday, February 25, 2012

Monitor a SQL table

Is there a way that I can monitor a table on SQL server. Specially if the table get change, then it will log who change it and what's been insert to the table?
http://www.aspfaq.com/2448
http://www.aspfaq.com/2496
http://www.aspfaq.com/
(Reverse address to reply.)
"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:CCC17ADE-6083-4A48-88E1-5F2261539410@.microsoft.com...
> Is there a way that I can monitor a table on SQL server. Specially if the
table get change, then it will log who change it and what's been insert to
the table?
>
|||Do you mean the table schema changes or do you mean that data in the table
changes?
If data, simply add a trigger and capture the user's identity.
"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:CCC17ADE-6083-4A48-88E1-5F2261539410@.microsoft.com...
> Is there a way that I can monitor a table on SQL server. Specially if the
table get change, then it will log who change it and what's been insert to
the table?
>

Money, SQL Server and C#

Argggg...

Please help.

I need to store money in SQL Server.
I am using C# and a stored procedure to insert.

How do you accomplish this? Specifically what datatype should the money variable be in C# during the insert? It's initial value is a string as it is entered from a text field.

I have been trying for over an hour now to simply insert money into SQL Server using C# and have it stored as a money type!

Thanks

Try using decimal. hth

|||

I did get it working using decimal.. thanks!

Decimal rate = Convert.ToDecimal(txtRate.Text);

Stored procedure looks like this.

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER PROCEDURE sp_UpdateHorsepowerRate

@.HorsePower int,
@.Rate money,
@.UserId uniqueidentifier,
@.EmployerId int

AS

INSERT INTO EmployerHorsePower (HorsePower, Rate, UserId, EmployerId) VALUES (@.HorsePower, @.Rate, @.UserId, @.EmployerId)

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Rob

|||

I would recommend that you not begin your stored procedures with "sp" (refer to:http://www.sql-server-performance.com/rd_optimizing_sp_recompiles.asp).

Also, when setting up the SqlParameter be sure that you consider the precision and scale. For themoney datatype, it would be precision=19, scale = 4.