Created
June 23, 2014 13:52
-
-
Save ketanghumatkar/2b4ab16ba1c32b7f7895 to your computer and use it in GitHub Desktop.
Procedure to create and insert warehouses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE GenerateWarehouseTbl | |
AS | |
BEGIN | |
-- create warehouse table | |
CREATE TABLE IMQCDev.dbo.Warehouses ( id int IDENTITY(1,1) NOT NULL, name varchar(50) NOT NULL, siteId varchar(50) NOT NULL, PRIMARY KEY(id), UNIQUE(name, siteId) ); | |
-- fetch warehouses from IMQCdev and insert into warehouses table | |
INSERT INTO IMQCDev.dbo.Warehouses (name, siteId) SELECT DISTINCT SUBSTRING(CONVERT(varchar(10), WhseLocID), 0, 3) as WhseName, SiteID as SiteId FROM IMQCDev.dbo.WhseLocDesc WHERE WhseLocID >= 10000 ORDER BY WhseName asc; | |
-- fetch warehouses from IMQCSitesdev and insert into warehouses table | |
INSERT INTO IMQCDev.dbo.Warehouses (name, siteId) SELECT DISTINCT SUBSTRING(CONVERT(varchar(10), WhseLocID), 0, 3) as WhseName, SiteID as SiteId FROM IMQCSitesDev.dbo.WhseLocDesc WHERE WhseLocID >= 10000 ORDER BY WhseName asc; | |
END |
WhseLocID columb has many invalid entries. According to Jon's bacecamp post only 5 digit entries are valid row entries
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's with the
WhseLocID >= 10000
check?