Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Check FK Violations


Check FK Violations

Author
Message
Man inTheMiddle
Man inTheMiddle
Forum Newbie
Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: General Forum Members
Points: 0 Visits: 95
Comments posted to this topic are about the item Check FK Violations
Matt Minnis
Matt Minnis
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 146
When I ran it I got the following error:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'aes.MSSQLLM$COLUMNLOG'.
I changed the dbo references to aes since all our db objects are owned by a user aes.
Is there a way to get it to skip/log errors like this instead of bombing out entirely as it did?
don.schaeffer
don.schaeffer
SSC Journeyman
SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)

Group: General Forum Members
Points: 87 Visits: 1057
You could replace the insert statement with this one to get the correct table schemas and avoid those errors. We too use multiple schemas, for organizational purposes.

INSERT INTO @FKTable (tbl_ForeignKey, tbl_TableSchema, tbl_TableName, tbl_ColumnName, tbl_ReferenceTableNameSchema, tbl_ReferenceTableName, tbl_ReferenceColumnName, tbl_UpdateAction, tbl_DeleteAction)
SELECT --sc.constid [FKId]
-- , sc.colid
so.name [ForeignKey]
, ss2.name [TableSchema]
-- , sc.id [FKTableId]
, so2.name [TableName]
-- , sfk.fkey [FKColumnId]
, sco.name [ColumnName]
, ss3.name AS [ReferenceTableNameSchema]
-- , sfk.fkeyid
-- , sfk.rkeyid [PKTableId]
, so3.name [ReferenceTableName]
-- , sfk.rkey [PKColumnId]
, sco2.name [ReferenceColumnName]
, CASE objectproperty(sc.constid, 'CnstIsUpdateCascade') WHEN 0 THEN 'NO ACTION' WHEN 1 THEN 'CASCADE' WHEN 2 THEN 'SET NULL' WHEN 3 THEN 'SET DEFAULT' ELSE '' END [UpdateAction]
, CASE objectproperty(sc.constid, 'CnstIsDeleteCascade') WHEN 0 THEN 'NO ACTION' WHEN 1 THEN 'CASCADE' WHEN 2 THEN 'SET NULL' WHEN 3 THEN 'SET DEFAULT' ELSE '' END [DeleteAction]
-- , CASE objectproperty(sc.constid, 'CnstIsNotRepl') WHEN 1 THEN 'NOT FOR REPLICATION' ELSE '' END AS [EnforceForReplication]
-- , sfk.keyno
FROM sysconstraints sc
INNER JOIN sys.objects so ON so.object_id = sc.constid
INNER JOIN sys.objects so2 ON so2.object_id = sc.id
INNER JOIN sys.schemas ss2 ON ss2.schema_id = so2.schema_id
INNER JOIN sysforeignkeys sfk ON sfk.constid = sc.constid
INNER JOIN sys.objects so3 ON so3.object_id = sfk.rkeyid
INNER JOIN sys.schemas ss3 ON ss3.schema_id = so3.schema_id
INNER JOIN sys.columns sco ON sco.object_id = sc.id AND sco.column_id = sfk.fkey
INNER JOIN sys.columns sco2 ON sco2.object_id = sfk.rkeyid AND sco2.column_id = sfk.rkey
WHERE (sc.status & 3) = 3
ORDER BY so.name ASC, sfk.keyno ASC
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search