Showing posts with label basically. Show all posts
Showing posts with label basically. Show all posts

Thursday, March 8, 2012

Audit Triggers SQL 2000

In the past I have used a poor mans audit trigger for my SQL tables. I basically created another identical table with "_Audit" at the end of it with the same fields. I simply did a trigger like this to copy the entire contents of the Row being updated, deleted, or Inserted.

CREATE TRIGGER fileAudit ON [dbo].[Table1]
FOR INSERT, UPDATE, DELETE
AS
insert Table1_audit
select
*
from inserted i
return

This is bad in several ways and I know that, but it was giving me Audit history that was better than nothing. The one thing I hate most about the above approach is that it copies the enitre record set even if only one field was updated or deleted and the fact I have an audit table for every table in the database.

I want to enhance my Audit Trail to include only one Audit_Table. I would like to mimic this approach that is using CLR for SQL 2005. My Only problem is I am forced to use SQL 2000 for legacy application on the database server. I do not have the ability to migrate to SQL 2005 at this time.

http://sqljunkies.com/Article/4CD01686-5178-490C-A90A-5AEEF5E35915.scuk

All of my Tables have an Auto-increment PK

Could some one point me in the right way to accomplish this.

I recommend to use the following structure;

TableName NVarchar(1000)

OperationDateTime DateTime

Operation smallint (1-Insert, 2-Update, 3-Delete)

Data Text (Common Delimited or XML value of the affected row)

The real challenge here is getting back – querying - the data. For that probably you can design your own UI where you can parse these values for display.

But again these audit trail operations are additional overhead on your data manipulation.

|||

TableName NVarchar(1000)

OperationDateTime DateTime

Operation smallint (1-Insert, 2-Update, 3-Delete)

Data Text (Common Delimited or XML value of the affected row)


Structure should depends on the purposes of audit. Because using this structure it is possible that you could never answer the question who changed some order or what have done John with another orders.
|||

don't use the '*' for auditting or you have to be very carefull of the datatype. you can't read timestamps, text, ... columns from the virtual inserted and deleted tables...

regards

skafever

Thursday, February 16, 2012

attaching system database

Hi,
I would like to ask if system database from other server can be
attached to other server. So basically, the process is, the existing
system database(including user databases) will be replaced by other
set of database(system and user databases) the new set of the
databases are just located in a separate drive in a cluster
environment. Will this procedure can apply?
http://support.microsoft.com/kb/224071
I am not sure if this will work. Just need to verify.
Thanks.
This will work. In some cases, you can simply copy the MDF/LDF files on the
same location where the system database files exist while the SQL Server
service is stopped. Once it starts, it should see those files. I used this
approach when I needed to set the collation settings for my tempdb. Instead
of rebuilding the master database, I just copied the model database files
from one server which has the same collation settings I need for my tempdb
and it worked
"Bry" <fqies_bry@.yahoo.com> wrote in message
news:1186108853.215054.30080@.j4g2000prf.googlegrou ps.com...
> Hi,
> I would like to ask if system database from other server can be
> attached to other server. So basically, the process is, the existing
> system database(including user databases) will be replaced by other
> set of database(system and user databases) the new set of the
> databases are just located in a separate drive in a cluster
> environment. Will this procedure can apply?
> http://support.microsoft.com/kb/224071
> I am not sure if this will work. Just need to verify.
> Thanks.
>
|||What if I have to use the other drive where they put the database
files? like I will modify the SQL(as KB said) to modify the drive of
the system database. will there be implications/problems?
|||I was about to say this...this is very important as your backups will not
work
"Jonathan Psaila-Depasquale" <nospam@.nospamplease.com> wrote in message
news:OLlqTka1HHA.3916@.TK2MSFTNGP02.phx.gbl...[vbcol=seagreen]
> Hi,
> Make sure that your destination SQL Server instance is patched up to the
> same build as the instance from which you are taking the system databases.
> Jonathan
>
> Bry wrote:

attaching system database

Hi,
I would like to ask if system database from other server can be
attached to other server. So basically, the process is, the existing
system database(including user databases) will be replaced by other
set of database(system and user databases) the new set of the
databases are just located in a separate drive in a cluster
environment. Will this procedure can apply?
http://support.microsoft.com/kb/224071
I am not sure if this will work. Just need to verify.
Thanks.This will work. In some cases, you can simply copy the MDF/LDF files on the
same location where the system database files exist while the SQL Server
service is stopped. Once it starts, it should see those files. I used this
approach when I needed to set the collation settings for my tempdb. Instead
of rebuilding the master database, I just copied the model database files
from one server which has the same collation settings I need for my tempdb
and it worked
"Bry" <fqies_bry@.yahoo.com> wrote in message
news:1186108853.215054.30080@.j4g2000prf.googlegroups.com...
> Hi,
> I would like to ask if system database from other server can be
> attached to other server. So basically, the process is, the existing
> system database(including user databases) will be replaced by other
> set of database(system and user databases) the new set of the
> databases are just located in a separate drive in a cluster
> environment. Will this procedure can apply?
> http://support.microsoft.com/kb/224071
> I am not sure if this will work. Just need to verify.
> Thanks.
>|||What if I have to use the other drive where they put the database
files? like I will modify the SQL(as KB said) to modify the drive of
the system database. will there be implications/problems?|||Hi,
Make sure that your destination SQL Server instance is patched up to the
same build as the instance from which you are taking the system databases.
Jonathan
Bry wrote:
> Hi,
> I would like to ask if system database from other server can be
> attached to other server. So basically, the process is, the existing
> system database(including user databases) will be replaced by other
> set of database(system and user databases) the new set of the
> databases are just located in a separate drive in a cluster
> environment. Will this procedure can apply?
> http://support.microsoft.com/kb/224071
> I am not sure if this will work. Just need to verify.
> Thanks.
>|||I was about to say this...this is very important as your backups will not
work
"Jonathan Psaila-Depasquale" <nospam@.nospamplease.com> wrote in message
news:OLlqTka1HHA.3916@.TK2MSFTNGP02.phx.gbl...[vbcol=seagreen]
> Hi,
> Make sure that your destination SQL Server instance is patched up to the
> same build as the instance from which you are taking the system databases.
> Jonathan
>
> Bry wrote:

attaching system database

Hi,
I would like to ask if system database from other server can be
attached to other server. So basically, the process is, the existing
system database(including user databases) will be replaced by other
set of database(system and user databases) the new set of the
databases are just located in a separate drive in a cluster
environment. Will this procedure can apply?
http://support.microsoft.com/kb/224071
I am not sure if this will work. Just need to verify.
Thanks.This will work. In some cases, you can simply copy the MDF/LDF files on the
same location where the system database files exist while the SQL Server
service is stopped. Once it starts, it should see those files. I used this
approach when I needed to set the collation settings for my tempdb. Instead
of rebuilding the master database, I just copied the model database files
from one server which has the same collation settings I need for my tempdb
and it worked
"Bry" <fqies_bry@.yahoo.com> wrote in message
news:1186108853.215054.30080@.j4g2000prf.googlegroups.com...
> Hi,
> I would like to ask if system database from other server can be
> attached to other server. So basically, the process is, the existing
> system database(including user databases) will be replaced by other
> set of database(system and user databases) the new set of the
> databases are just located in a separate drive in a cluster
> environment. Will this procedure can apply?
> http://support.microsoft.com/kb/224071
> I am not sure if this will work. Just need to verify.
> Thanks.
>|||What if I have to use the other drive where they put the database
files? like I will modify the SQL(as KB said) to modify the drive of
the system database. will there be implications/problems?|||Hi,
Make sure that your destination SQL Server instance is patched up to the
same build as the instance from which you are taking the system databases.
Jonathan
Bry wrote:
> Hi,
> I would like to ask if system database from other server can be
> attached to other server. So basically, the process is, the existing
> system database(including user databases) will be replaced by other
> set of database(system and user databases) the new set of the
> databases are just located in a separate drive in a cluster
> environment. Will this procedure can apply?
> http://support.microsoft.com/kb/224071
> I am not sure if this will work. Just need to verify.
> Thanks.
>|||I was about to say this...this is very important as your backups will not
work
"Jonathan Psaila-Depasquale" <nospam@.nospamplease.com> wrote in message
news:OLlqTka1HHA.3916@.TK2MSFTNGP02.phx.gbl...
> Hi,
> Make sure that your destination SQL Server instance is patched up to the
> same build as the instance from which you are taking the system databases.
> Jonathan
>
> Bry wrote:
>> Hi,
>> I would like to ask if system database from other server can be
>> attached to other server. So basically, the process is, the existing
>> system database(including user databases) will be replaced by other
>> set of database(system and user databases) the new set of the
>> databases are just located in a separate drive in a cluster
>> environment. Will this procedure can apply?
>> http://support.microsoft.com/kb/224071
>> I am not sure if this will work. Just need to verify.
>> Thanks.