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

Creating new collections


As we saw in Chapter 4, a collection is a grouping of members that isn't defined by one of the existing attributes. Creating collections is very similar to the process for creating new members. The syntax is exactly the same, other than setting the MemberType_ID to 3, populating the MemberName column with the name of the collection, and populating the MemberCode column with a unique code for the collection. The syntax for this can be seen shortly.

In this example, we are creating a new collection for stores where we want to include a marketing campaign named "2011 Campaign Targets":

/* Create a new collection in the staging tables */
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 staging table. ...