Click here to Skip to main content
11,717,509 members (79,215 online)
   

Database

 
AnswerRe: xBase question Pin
Kevin Marois14-May-12 11:40
memberKevin Marois14-May-12 11:40 
QuestionRe: xBase question Pin
DavidCrow14-May-12 17:22
memberDavidCrow14-May-12 17:22 
AnswerRe: xBase question Pin
Kevin Marois15-May-12 6:35
memberKevin Marois15-May-12 6:35 
QuestionRe: xBase question Pin
DavidCrow15-May-12 6:55
memberDavidCrow15-May-12 6:55 
AnswerRe: xBase question Pin
Kevin Marois15-May-12 7:01
memberKevin Marois15-May-12 7:01 
GeneralRe: xBase question Pin
DavidCrow15-May-12 7:30
memberDavidCrow15-May-12 7:30 
GeneralRe: xBase question Pin
Kevin Marois15-May-12 7:31
memberKevin Marois15-May-12 7:31 
GeneralRe: xBase question Pin
DavidCrow15-May-12 7:37
memberDavidCrow15-May-12 7:37 
GeneralRe: xBase question Pin
Kevin Marois15-May-12 7:44
memberKevin Marois15-May-12 7:44 
QuestionOracle: Replace single occurrence of a character Pin
Lash2014-May-12 8:21
memberLash2014-May-12 8:21 
AnswerRe: Oracle: Replace single occurrence of a character Pin
rana ray15-May-12 0:56
memberrana ray15-May-12 0:56 
GeneralLinq to Sql Pin
sindhuan14-May-12 1:10
membersindhuan14-May-12 1:10 
GeneralRe: Linq to Sql Pin
Kevin Marois14-May-12 11:45
memberKevin Marois14-May-12 11:45 
QuestionDoubt in a piece of code [Transact-SQL database audit]. Pin
vValkir13-May-12 21:54
membervValkir13-May-12 21:54 
Hi all,

Trying to discover an appropiate way to perform the audit of a database, I have discovered a piece of code that seems to be quite appropiate. This is there:

http://www.simple-talk.com/sql/database-administration/pop-rivetts-sql-server-faq-no.5-pop-on-the-audit-trail/[^]

What matters right now is the following lines of code, which are difficult for me to be understood properly:

-- 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

This piece of code is placed inside a trigger writen on Transact-SQL (SQLServer) code. I understand more or less what is the programmer trying to get by using these lines, but what I don't understant (probably because I'm quite new on SQLServer) is what are the 'i.' and 'd.' references. By accessing the link you can discover the full code, but I had not been able to discover anythink on the code preceding it.

Another part of the code above that is a bit confusing is the following:

@PKCols = COALESCE(@PKCols + ' and', ' on')

COALESCE returns the first non-null expression, but it's difficult for me to understand the meaning of the sentence inside the complete expression shown above.

Thanks in advance, any kind of help (links, direct answer...) will be wellcome.

modified 14-May-12 4:25am.

AnswerRe: Doubt in a piece of code [Transact-SQL database audit]. Pin
Mycroft Holmes13-May-12 22:36
memberMycroft Holmes13-May-12 22:36 
GeneralRe: Doubt in a piece of code [Transact-SQL database audit]. Pin
vValkir13-May-12 22:54
membervValkir13-May-12 22:54 
AnswerRe: Doubt in a piece of code [Transact-SQL database audit]. Pin
djj5514-May-12 4:08
memberdjj5514-May-12 4:08 
QuestionOracle Question: Split String into two Pin
Lash2011-May-12 5:57
memberLash2011-May-12 5:57 
AnswerRe: Oracle Question: Split String into two Pin
Jörgen Andersson11-May-12 9:08
memberJörgen Andersson11-May-12 9:08 
AnswerRe: Oracle Question: Split String into two Pin
Lash2011-May-12 9:33
memberLash2011-May-12 9:33 
GeneralRe: Oracle Question: Split String into two Pin
Jörgen Andersson11-May-12 9:47
memberJörgen Andersson11-May-12 9:47 
Questiontimestamp Pin
vijaylumar11-May-12 1:39
membervijaylumar11-May-12 1:39 
AnswerRe: timestamp Pin
Eddy Vluggen11-May-12 1:42
memberEddy Vluggen11-May-12 1:42 
QuestionWhat is database SQL query to display the name of the table only in to datagrid? Pin
LAPEC10-May-12 1:04
memberLAPEC10-May-12 1:04 
AnswerRe: What is database SQL query to display the name of the table only in to datagrid? Pin
PIEBALDconsult10-May-12 3:16
memberPIEBALDconsult10-May-12 3:16 
AnswerRe: What is database SQL query to display the name of the table only in to datagrid? Pin
vvashishta10-May-12 4:17
membervvashishta10-May-12 4:17 
GeneralRe: What is database SQL query to display the name of the table only in to datagrid? Pin
Eddy Vluggen10-May-12 7:05
memberEddy Vluggen10-May-12 7:05 
Questionchoosing a database Pin
davood_b8-May-12 1:19
memberdavood_b8-May-12 1:19 
AnswerRe: choosing a database Pin
PIEBALDconsult8-May-12 3:16
memberPIEBALDconsult8-May-12 3:16 
QuestionRe: choosing a database Pin
Eddy Vluggen8-May-12 5:05
memberEddy Vluggen8-May-12 5:05 
GeneralRe: choosing a database Pin
PIEBALDconsult8-May-12 18:42
memberPIEBALDconsult8-May-12 18:42 
AnswerRe: choosing a database Pin
Eddy Vluggen8-May-12 5:08
memberEddy Vluggen8-May-12 5:08 
Questionusing xquery to populate a table variable in sql Pin
swjam6-May-12 4:34
memberswjam6-May-12 4:34 
QuestionRead LFD(log ) file SQLserver 2008 Pin
jojoba20114-May-12 17:38
memberjojoba20114-May-12 17:38 
AnswerRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen4-May-12 23:11
memberEddy Vluggen4-May-12 23:11 
QuestionRe: Read LFD(log ) file SQLserver 2008 Pin
jojoba20114-May-12 23:19
memberjojoba20114-May-12 23:19 
AnswerRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen4-May-12 23:31
memberEddy Vluggen4-May-12 23:31 
GeneralRe: Read LFD(log ) file SQLserver 2008 Pin
jojoba20115-May-12 20:31
memberjojoba20115-May-12 20:31 
GeneralRe: Read LFD(log ) file SQLserver 2008 Pin
Mycroft Holmes5-May-12 23:00
memberMycroft Holmes5-May-12 23:00 
JokeRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen6-May-12 6:08
memberEddy Vluggen6-May-12 6:08 
AnswerRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen6-May-12 0:37
memberEddy Vluggen6-May-12 0:37 
GeneralRe: Read LFD(log ) file SQLserver 2008 Pin
jojoba20116-May-12 23:30
memberjojoba20116-May-12 23:30 
AnswerRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen7-May-12 0:30
memberEddy Vluggen7-May-12 0:30 
GeneralRe: Read LFD(log ) file SQLserver 2008 Pin
jojoba20117-May-12 17:37
memberjojoba20117-May-12 17:37 
GeneralRe: Read LFD(log ) file SQLserver 2008 Pin
JohnPayton7-May-12 18:10
memberJohnPayton7-May-12 18:10 
GeneralRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen8-May-12 0:17
memberEddy Vluggen8-May-12 0:17 
QuestionRe: Read LFD(log ) file SQLserver 2008 Pin
jojoba20119-May-12 17:52
memberjojoba20119-May-12 17:52 
AnswerRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen10-May-12 0:07
memberEddy Vluggen10-May-12 0:07 
QuestionRe: Read LFD(log ) file SQLserver 2008 Pin
jojoba201111-May-12 17:28
memberjojoba201111-May-12 17:28 
AnswerRe: Read LFD(log ) file SQLserver 2008 Pin
Eddy Vluggen12-May-12 0:45
memberEddy Vluggen12-May-12 0:45 

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
Web02 | 2.8.150901.1 | Last Updated 3 Sep 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid