Sample SQL Code
way0utwest
Redgate › Posts: 312 Rose Gold 1
Sample code used to create some tables for the missing report.
CREATE TABLE ConstosoProduct<br>(ProductID INT IDENTITY(1,1) NOT NULL CONSTRAINT ContosoProductPK PRIMARY KEY<br>, ProductLevel1 VARCHAR(100)<br>, ProductLevel2 VARCHAR(100)<br>, ProductLevel3 VARCHAR(100)<br>, ProductName VARCHAR(100)<br>)<br>GO<br>INSERT dbo.ConstosoProduct<br> (ProductLevel1<br> , ProductLevel2<br> , ProductLevel3<br> , ProductName)<br> VALUES<br> ( 'Audio', 'MP4&MP3', '', ''),<br> ( 'Audio', 'Recorder', '', ''),<br> ( 'Audio', 'Radio', '', ''),<br> ( 'Audio', 'Recording Pen', '', ''),<br> ( 'TV and Video', 'Televisions', '', ''),<br> ( 'TV and Video', 'VCD & DVD', '', ''),<br> ( 'TV and Video', 'Home Theater System', '', ''),<br> ( 'Computers', 'Laptops', '', 'Fabrikam Laptop19W M9800 Black'),<br> ( 'Computers', 'Desktops', '', 'Adventure Works Desktop PC2.30 MD230 Silver')
<div><br></div>CREATE TABLE UserSample<br>( UserName VARCHAR(100)<br> , OrgLevel1 VARCHAR(20)<br> , OrgLevel2 VARCHAR(20)<br> , OrgLevel3 VARCHAR(20));<br>GO<br><br>INSERT dbo.UserSample<br> (UserName<br> , OrgLevel1<br> , OrgLevel2<br> , OrgLevel3)<br>VALUES<br> ('User g', 'someOrg', 'other Org', null),<br> ('User B', 'someOrg', 'other Org', 'thirdOrg'),<br> ('User C', 'someOrg', '', 'thirdOrg'),<br> ('User D', '', 'other Org', 'thirdOrg'),<br> ('User E', '', 'other Org', ''),<br> ('User F', '', 'other Org', '')
CREATE TABLE [dbo].[ProductSample](<br> [ProductName] [varchar](100) NULL,<br> [ProductLevel1] [varchar](20) NULL,<br> [ProductLevel2] [varchar](20) NULL,<br> [ProductLevel3] [varchar](20) NULL<br>) ON [PRIMARY]<br>GO<br>INSERT INTO dbo.ProductSample<br> (ProductName<br> , ProductLevel1<br> , ProductLevel2<br> , ProductLevel3)<br>VALUES<br>( 'Product A', 'somecat', 'other cat', 'thirdcat' ), <br>( 'Product B', 'somecat', 'other cat', 'thirdcat' ), <br>( 'Product C', 'somecat', '', 'thirdcat' ), <br>( 'Product D', '', 'other cat', 'thirdcat' ), <br>( 'Product E', '', 'other cat', '' ), <br>( 'Product F', '', 'other cat', '' )<br>
Editor, SQLServerCentral
Tagged:
Comments