Book Image

Microsoft SQL Server 2008 R2 Master Data Services

Book Image

Microsoft SQL Server 2008 R2 Master Data Services

Overview of this book

Table of Contents (18 chapters)
Microsoft SQL Server 2008 R2 Master Data Services
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Adding members to collections


Once we have created a collection, the obvious next step is to add members to it. This is achieved by adding records to the staging table mdm.tblStgRelationship.


In the following example, we will add records to the staging table that will add two of our new stores ("Number One Bike Co" and "Metropolitan Bicycle Supply") to the "2011 Campaign Targets" collection:

/* Insert records into the staging table that 
will add members to a collection         */
USE MDS -- replace with the name of your master data repository
GO

/* Declare the variables for use in the insert statement */
DECLARE @ModelName nvarchar(50)
DECLARE @EntityName nvarchar(50)

/* Set the variables appropriately */
SET    @ModelName  = 'Store' 
SET    @EntityName  = 'Store'

/* Insert records into the relationship staging table   */
INSERT INTO mdm.tblStgRelationship
( 
        ModelName 
        ,EntityName 
        ,MemberType_ID 
        ,MemberCode
        ,TargetCode
        ,TargetType_ID...