Click here to Skip to main content
14,923,204 members
Home / Discussions / Database
   

Database

 
GeneralRe: xBase question Pin
Kevin Marois15-May-12 7:31
professionalKevin Marois15-May-12 7:31 
GeneralRe: xBase question Pin
David Crow15-May-12 7:37
MemberDavid Crow15-May-12 7:37 
GeneralRe: xBase question Pin
Kevin Marois15-May-12 7:44
professionalKevin 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
professionalKevin 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
professionalMycroft 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
Corporal Agarn14-May-12 4:08
professionalCorporal Agarn14-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
professionalJö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
professionalJö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
professionalEddy 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
professionalPIEBALDconsult10-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
professionalEddy 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
professionalPIEBALDconsult8-May-12 3:16 
QuestionRe: choosing a database Pin
Eddy Vluggen8-May-12 5:05
professionalEddy Vluggen8-May-12 5:05 
GeneralRe: choosing a database Pin
PIEBALDconsult8-May-12 18:42
professionalPIEBALDconsult8-May-12 18:42 

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

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