To manually set weight values, you must have access to the MDS database. At a minimum, you should be able to read these tables:



Similar documents
How to schedule and automate backups of SQL Server databases in SQL Server Express Editions

Using SQL Server Management Studio

Course ID#: W 35 Hrs. Course Content

Querying Microsoft SQL Server 20461C; 5 days

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

Querying Microsoft SQL Server Course M Day(s) 30:00 Hours

MINION BACKUP : QUICK START

Querying Microsoft SQL Server

Cello How-To Guide. Pickup List Management

MOC QUERYING MICROSOFT SQL SERVER

Oracle Database: SQL and PL/SQL Fundamentals NEW

Querying Microsoft SQL Server 2012

Course 10774A: Querying Microsoft SQL Server 2012

Course 10774A: Querying Microsoft SQL Server 2012 Length: 5 Days Published: May 25, 2012 Language(s): English Audience(s): IT Professionals

Microsoft Microsoft SQL Server 2005 Implementation & Maintenance

Darshan Institute of Engineering & Technology PL_SQL

SalesPad for Dynamics GP Credit Card Processing Setup and Credit Card Payments

Oracle Database: SQL and PL/SQL Fundamentals

Introducing Microsoft SQL Server 2012 Getting Started with SQL Server Management Studio

MOC 20461C: Querying Microsoft SQL Server. Course Overview

Siemens Teamcenter Oracle -to-sql Server 2008 Migration Guide

sqlite driver manual

Towards a Sufficient Set of Mutation Operators for. Structured Query Language (SQL)

Product: DQ Order Manager Release Notes

Performance. Optimizing Performance. Microsoft Dynamics CRM 3.0. White Paper. Date: January 10,

When an exception occur a message which explains its cause is received. PL/SQL Exception message consists of three parts.

SQL Server An Overview

Guide to Migrating from DB2 to SQL Server

Database Design Standards. U.S. Small Business Administration Office of the Chief Information Officer Office of Information Systems Support

Chancery SMS Database Split

Oracle Database: SQL and PL/SQL Fundamentals

ATTACHMENT 6 SQL Server 2012 Programming Standards

Oracle SQL. Course Summary. Duration. Objectives

SQL Server Table Design - Best Practices

WINDOWS AZURE SQL DATA SYNC

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

Relational databases and SQL

Performance Implications of Various Cursor Types in Microsoft SQL Server. By: Edward Whalen Performance Tuning Corporation

Auditing In SQL Server. SQL Saturday #486 - RVA Presented By Brad McKuhen

Best Approaches to Database Auditing: Strengths and Weaknesses.

Sophos Enterprise Console Auditing user guide. Product version: 5.2

Introduction to SQL for Data Scientists

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours

SQL Server 200x Optimizing Stored Procedure Performance

Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

Improving SQL Server Performance

T-SQL STANDARD ELEMENTS

ROLAP with Column Store Index Deep Dive. Alexei Khalyako SQL CAT Program Manager

Once the schema has been designed, it can be implemented in the RDBMS.

Choosing a Data Model for Your Database

Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

SQL Server Replication Guide

MS ACCESS DATABASE DATA TYPES

[MS-WSSDM]: Windows SharePoint Services: Content Database Data Migration Communications Protocol Specification

Embedded SQL. Unit 5.1. Dr Gordon Russell, Napier University

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

DDL is short name of Data Definition Language, which deals with database schemas and descriptions, of how the data should reside in the database.

SQL Server Database Coding Standards and Guidelines

USER GUIDE Appointment Manager

A basic create statement for a simple student table would look like the following.

A Brief Introduction to MySQL

White Paper

10+ tips for upsizing an Access database to SQL Server

LAB 1: Getting started with WebMatrix. Introduction. Creating a new database. M1G505190: Introduction to Database Development

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

Oracle Database 11g SQL

Dynamics NAV/SQL Server Configuration Recommendations

Microsoft. MCSA upgrade to SQL Server 2012 Certification Courseware. Version 1.0

In This Lecture. Security and Integrity. Database Security. DBMS Security Support. Privileges in SQL. Permissions and Privilege.

Programming Database lectures for mathema

Creating Database Tables in Microsoft SQL Server

COURSE SYLLABUS COURSE TITLE:

MYSQL DATABASE ACCESS WITH PHP

EASRestoreService. Manual

Oracle Database 12c: Introduction to SQL Ed 1.1

A Migration Methodology of Transferring Database Structures and Data

How To Create A Table In Sql (Ahem)

Using ODBC with MDaemon 6.5


Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Introduction This document s purpose is to define Microsoft SQL server database design standards.

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

Master Data Services. SQL Server 2012 Books Online

DIPLOMA IN WEBDEVELOPMENT

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

Advanced Queries and Linked Servers

An Introduction to PL/SQL. Mehdi Azarmi

PHP Language Binding Guide For The Connection Cloud Web Services

PUBLIC. How to Use in SAP Business One. Solutions from SAP. SAP Business One 2005 A SP01

Tech Note 663 HMI Reports: Creating Alarm Database (WWALMDB) Reports

A table is a collection of related data entries and it consists of columns and rows.

Querying Microsoft SQL Server (20461) H8N61S

HP Quality Center. Upgrade Preparation Guide

Migrating from Sybase to SQL Server

Transcription:

In MDS, you can set weight values on members in a collection, so that certain members count more than others when you do analysis in a subscribing system. For example, in this sample collection that is used to determine royalties for our MDS book, Tyler (my coauthor) and I are equals. The collection contains both of us, and we both get half of the massive royalties we re expecting. Imagine there is a second edition of the book, and we decide that Carlos, our technical reviewer, will take over my part of the book. I ll still get some royalties, but not the full amount. You can use this collection to accurately calculate what s owed to Carlos, Tyler, and me. In general, for each member in the collection, you specify an integer. And you want every level in your collection to equal 1.00. Setting Weight Values To set weight values in MDS, you open the collection (CN) table for the entity and update the weight value for each member in the collection. You can do this manually or by using a stored procedure. When you create a subscription view with the Collections format, a Weight column includes the values you set. This view is used by subscribing systems to consume the data. Security prerequisites To manually set weight values, you must have access to the MDS database. At a minimum, you should be able to read these tables: mdm.tblmodel mdm.tblentity A collection table (ending in CN) for the entity that s enabled for collections And you must be able to update the collection table that contains the weight values (a table that ends in CM).

If you re going to use the stored procedure, you must also be able to read mdm.tbluser. How to set the weight values manually To find the collection table where you will update the weight value, complete the following steps: 1. Open mdm.tblmodel. Note the model s ID in the ID column. 2. Open mdm.tblentity. Find the entity that s enabled for (use the model ID in the Model_ID column for assistance). The names of the collection tables are displayed in this row. The model and entity IDs are combined to determine the name of the collection tables. For example, if the model ID is 4 and the entity ID is 12, the collection tables are tbl_4_12_cn and tbl_4_12_cm. 3. Open the CN table, which lists all collections for the entity. Based on the value in the Name column, note the ID in the ID column. 4. Open the CM table, which lists all members in the collection. In this table, in the Parent_CN_ID column, the ID of the collection (from step 3) is listed. In this example, we can see that there are only two members in the collection with an ID of 1 in the Parent_CN_ID column. 5. Update the value in the Weight column for each member. Remember that each level in your collection should equal 1. How to set the weight values by using a stored procedure Step 1: Create stored procedure called udpcollectionmemberaddwithweight Paste the following text into a new SQL query window. Execute to create the stored procedure. USE [DATABASENAME] SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON

CREATE PROCEDURE [mdm].[udpcollectionmemberaddwithweight] @User_ID INT, @Version_ID INT, @Entity_ID INT, @Collection_ID INT, @Child_ID INT, @ChildType_ID TINYINT, @WEIGHT Decimal(10,3), @Remove TINYINT=0 WITH EXECUTE AS N'mds_schema_user' AS SET NOCOUNT ON; DECLARE @TranCounter INT, @ErrorMessage NVARCHAR(4000); SET @TranCounter = @@TRANCOUNT; IF @TranCounter > 0 SAVE TRANSACTION TX; ELSE TRANSACTION; TRY DECLARE @SQL AS NVARCHAR(MAX), @CollectionMemberTableName AS sysname, @CollectionTableName AS sysname, @Member_ID AS INT, @RecordExists AS BIT; --Get Collection Member table name SELECT @CollectionMemberTableName = mdm.udftablenamegetbyid(@entity_id, 5); IF @Remove = 1 --Delete the existing record DELETE FROM mdm.' + quotename(@collectionmembertablename) + N' WHERE Version_ID = ' + CONVERT(NVARCHAR(30), @Version_ID) + N' AND ' + CASE @ChildType_ID WHEN 1 THEN N'Child_EN_ID' WHEN 2 THEN N'Child_HP_ID' WHEN 3 THEN N'Child_CN_ID' END + N' = ' + CONVERT(NVARCHAR(30), @Child_ID) + N' AND ChildType_ID = ' + CONVERT(NVARCHAR(30), @ChildType_ID) + N' AND Parent_CN_ID = ' + CONVERT(NVARCHAR(30), @Collection_ID) + N' AND Status_ID = 1;'; EXEC sp_executesql @SQL; END ELSE --Create the record --Validate @Collection_ID IF @Collection_ID IS NULL '%Collection_ID'); END;--if --Get Collection table name SELECT @CollectionTableName = mdm.udftablenamegetbyid(@entity_id, 3); --Check to see if a record with the Collection_ID exists SET @RecordExists = 0;

IF EXISTS ( SELECT 1 FROM mdm.' + quotename(@collectiontablename) + N' WHERE ID = ' + CONVERT(NVARCHAR(30), @Collection_ID) + N' AND Version_ID = ' + CONVERT(NVARCHAR(30), @Version_ID) + N' ) SET @RecordExists = 1;'; EXEC sp_executesql @SQL, N'@RecordExists BIT OUTPUT', @RecordExists OUTPUT; IF @RecordExists = 0 '%Collection_ID'); --Validate @ChildType_ID IF (@ChildType_ID IS NULL) OR (@ChildType_ID < 1 OR @ChildType_ID > 3) '%ChildType_ID'); --Validate @Child_ID --Check to see if a record with the Child_ID exists SET @RecordExists = 0; IF EXISTS ( SELECT 1 FROM mdm.' + quotename(mdm.udftablenamegetbyid(@entity_id, @ChildType_ID)) + N' WHERE ID = ' + CONVERT(NVARCHAR(30), @Child_ID) + N' AND Version_ID = ' + CONVERT(NVARCHAR(30), @Version_ID) + N' ) SET @RecordExists = 1;'; EXEC sp_executesql @SQL, N'@RecordExists BIT OUTPUT', @RecordExists OUTPUT; IF @RecordExists = 0 '%Child_ID');

--Insert into the Correct Collection Member Table INSERT INTO mdm.' + quotename(@collectionmembertablename) + N' ( Version_ID, Status_ID, Parent_CN_ID, ChildType_ID, Child_EN_ID, Child_HP_ID, Child_CN_ID, SortOrder, Weight, EnterDTM, EnterUserID, EnterVersionID, LastChgDTM, LastChgUserID, LastChgVersionID ) SELECT ' + CONVERT(NVARCHAR(30), @Version_ID) + N', 1, --Status ' + ISNULL(CONVERT(NVARCHAR(30), NULLIF(@Collection_ID, 0)), N'NULL') + N', --Parent_CN_ID ' + CONVERT(NVARCHAR(30),@ChildType_ID) + N', -- ChildType_ID ' + CASE @ChildType_ID WHEN 1 THEN CONVERT(NVARCHAR(30), @Child_ID) ELSE N'NULL' END + N', --Child_EN_ID ' + CASE @ChildType_ID WHEN 2 THEN CONVERT(NVARCHAR(30), @Child_ID) ELSE N'NULL' END + N', --Child_HP_ID ' + CASE @ChildType_ID WHEN 3 THEN CONVERT(NVARCHAR(30), @Child_ID) ELSE N'NULL' END + N', --Child_CN_ID ISNULL(MAX(ID), 0) + 1, @WEIGHT, GETUTCDATE(), ' + CONVERT(NVARCHAR(30),@User_ID) + N', ' + CONVERT(NVARCHAR(30),@Version_ID) + N', GETUTCDATE(), ' + CONVERT(NVARCHAR(30),@User_ID) + N', ' + CONVERT(NVARCHAR(30),@Version_ID) + N' N'; OUTPUT; FROM mdm.' + quotename(@collectionmembertablename) + SET @Member_ID = SCOPE_IDENTITY();'; EXEC sp_executesql @SQL, N'@Member_ID INT OUTPUT', @Member_ID --Commit only if we are not nested IF @TranCounter = 0 COMMIT TRANSACTION; RETURN(0);

END TRY --Compensate as necessary CATCH DECLARE @ErrorSeverity INT, @ErrorState INT, @Error INT; ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(), @Error = @@ERROR; END; IF @TranCounter = 0 ROLLBACK TRANSACTION; ELSE IF XACT_STATE() <> -1 ROLLBACK TRANSACTION TX; RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState); --On error, return NULL results --SELECT @Return_ID = NULL; RETURN(1); END CATCH; SET NOCOUNT OFF; Step 2: Run the stored procedure The variables for the stored procedure are: @User_ID The ID column from mdm.tbluser. @Version_ID The Version_ID column from the CN table. @Entity_ID The ID column from mdm.tblentity. @Collection_ID The ID column from the CN table. @Child_ID - The Child_EN_ID column from the CM table. @ChildType_ID The ChildType_ID from the CM table. @WEIGHT An integer of your choice. Example EXEC [mdm].[udpcollectionmemberaddwithweight] @User_ID=1, @Version_ID=4, @Entity_ID=12, @Collection_ID=2, @Child_ID=1,@ChildType_ID=1,@WEIGHT=.5 When you create a subscription view with the Collections format, a Weight column includes the values you set.