Click here to Skip to main content
       

Database

 
GeneralRe: xBase question PinmemberKevin Marois15-May-12 7:44 
QuestionOracle: Replace single occurrence of a character PinmemberLash2014-May-12 8:21 
AnswerRe: Oracle: Replace single occurrence of a character Pinmemberrana ray15-May-12 0:56 
GeneralLinq to Sql Pinmembersindhuan14-May-12 1:10 
GeneralRe: Linq to Sql [modified] PinmemberKevin Marois14-May-12 11:45 
QuestionDoubt in a piece of code [Transact-SQL database audit]. [modified] PinmembervValkir13-May-12 21:54 
AnswerRe: Doubt in a piece of code [Transact-SQL database audit]. PinmemberMycroft Holmes13-May-12 22:36 
GeneralRe: Doubt in a piece of code [Transact-SQL database audit]. PinmembervValkir13-May-12 22:54 
The code preceding the lines I pasted above are the following:
 
CREATE TRIGGER tr_trigtest ON trigtest FOR INSERT, UPDATE, DELETE
AS
 
DECLARE @bit INT ,
       @field INT ,
       @maxfield INT ,
       @char INT ,
       @fieldname VARCHAR(128) ,
       @TableName VARCHAR(128) ,
       @PKCols VARCHAR(1000) ,
       @sql VARCHAR(2000), 
       @UpdateDate VARCHAR(21) ,
       @UserName VARCHAR(128) ,
       @Type CHAR(1) ,
       @PKSelect VARCHAR(1000)
       
 
--You will need to change @TableName to match the table to be audited
SELECT @TableName = 'trigtest'
 
-- date and user
SELECT         @UserName = SYSTEM_USER ,
       @UpdateDate = CONVERT(VARCHAR(8), GETDATE(), 112) 
               + ' ' + CONVERT(VARCHAR(12), GETDATE(), 114)
 
-- Action
IF EXISTS (SELECT * FROM inserted)
       IF EXISTS (SELECT * FROM deleted)
               SELECT @Type = 'U'
       ELSE
               SELECT @Type = 'I'
ELSE
       SELECT @Type = 'D'
 
-- get list of columns
SELECT * INTO #ins FROM inserted
SELECT * INTO #del FROM deleted
 
-- Get primary key columns for full outer join
SELECT @PKCols = COALESCE(@PKCols + ' and', ' on') 
               + ' i.' + c.COLUMN_NAME + ' = d.' + c.COLUMN_NAME
       FROM    INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk ,
 
              INFORMATION_SCHEMA.KEY_COLUMN_USAGE c
       WHERE   pk.TABLE_NAME = @TableName
       AND     CONSTRAINT_TYPE = 'PRIMARY KEY'
       AND     c.TABLE_NAME = pk.TABLE_NAME
       AND     c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME
 
So, there are no mentions about 'd.' or 'i.'. Are "d" and "i" alias for these tables by default?
AnswerRe: Doubt in a piece of code [Transact-SQL database audit]. Pinmemberdjj5514-May-12 4:08 
QuestionOracle Question: Split String into two PinmemberLash2011-May-12 5:57 
AnswerRe: Oracle Question: Split String into two PinmemberJörgen Andersson11-May-12 9:08 
AnswerRe: Oracle Question: Split String into two PinmemberLash2011-May-12 9:33 
GeneralRe: Oracle Question: Split String into two PinmemberJörgen Andersson11-May-12 9:47 
Questiontimestamp Pinmembervijaylumar11-May-12 1:39 
AnswerRe: timestamp PinmemberEddy Vluggen11-May-12 1:42 
QuestionWhat is database SQL query to display the name of the table only in to datagrid? PinmemberLAPEC10-May-12 1:04 
AnswerRe: What is database SQL query to display the name of the table only in to datagrid? PinmemberPIEBALDconsult10-May-12 3:16 
AnswerRe: What is database SQL query to display the name of the table only in to datagrid? Pinmembervvashishta10-May-12 4:17 
GeneralRe: What is database SQL query to display the name of the table only in to datagrid? PinmemberEddy Vluggen10-May-12 7:05 
Questionchoosing a database Pinmemberdavood_b8-May-12 1:19 
AnswerRe: choosing a database PinmemberPIEBALDconsult8-May-12 3:16 
QuestionRe: choosing a database PinmemberEddy Vluggen8-May-12 5:05 
GeneralRe: choosing a database PinmemberPIEBALDconsult8-May-12 18:42 
AnswerRe: choosing a database PinmemberEddy Vluggen8-May-12 5:08 
Questionusing xquery to populate a table variable in sql Pinmemberswjam6-May-12 4:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 18 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid