October 6, 2014 at 4:18 am
Hi,
I have a requirement to create a new table - MG_EDI_CONVERSION. The issue I am stuck on is to populate one of the column values (INTERNAL_VALUE) in the new table using column (DUNS) from an existing table - MG_COMPANY.
In other words, MG_EDI_CONVERSION will need to connect to MG_COMPANY table (where MG_EDI_CONVERSION.INTERNAL_VALUE = MG_COMPANY.DUNS)
Can somebody please advise how to include the above functionality in the CREATE statement of the new table - MG_EDI_CONVERSION.
Thanks.
Please find the DDL of the 2 tables below:
CREATE TABLE [dbo].[MG_COMPANY](
[COMPANY_ID] [numeric](10, 0) NOT NULL,
[VALIDATED_FLG] [char](1) NOT NULL,
[DUNS] [varchar](10) NULL,
[COMPANY_NAME] [varchar](70) NOT NULL,
[COUNTRY_CD] [varchar](2) NOT NULL,
[CITY] [varchar](35) NULL
)
CREATE TABLE [dbo].[MG_EDI_CONVERSION](
[EDI_PARTNER_CD] [numeric](10, 0) NOT NULL,
[OUTBOUND_FLG] [char](1) NOT NULL,
[INTERNAL_VALUE] [varchar](2000) NOT NULL,
[LAST_UPDATE_USER_ID] [decimal](10, 0) NOT NULL,
[LAST_UPDATE_DT] [datetime] NOT NULL,
[CREATE_USER_ID] [decimal](10, 0) NOT NULL,
[CREATE_DT] [datetime] NOT NULL,
[DELETED_FLG] [char](1) NOT NULL,
PRIMARY KEY CLUSTERED
(
[EDI_PARTNER_CD] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
October 6, 2014 at 4:34 am
You need something with which to associate the two tables. Column EDI_PARTNER_CD looks like the only column in MG_EDI_CONVERSION which might be related to COMPANY_ID or COMPANY_NAME.
Do you have a table in your db which contains EDI_PARTNER_CD and either of COMPANY_ID or COMPANY_NAME?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 6, 2014 at 4:47 am
ChrisM@Work (10/6/2014)
You need something with which to associate the two tables. Column EDI_PARTNER_CD looks like the only column in MG_EDI_CONVERSION which might be related to COMPANY_ID or COMPANY_NAME.Do you have a table in your db which contains EDI_PARTNER_CD and either of COMPANY_ID or COMPANY_NAME?
Thanks Chris.
You are right, COMPANY_ID is related to EDI_PARTNER_CD. Would you know how to include this relation in the CREATE statement for MG_EDI_CONVERSION ?
Thanks.
October 6, 2014 at 4:52 am
pwalter83 (10/6/2014)
ChrisM@Work (10/6/2014)
You need something with which to associate the two tables. Column EDI_PARTNER_CD looks like the only column in MG_EDI_CONVERSION which might be related to COMPANY_ID or COMPANY_NAME.Do you have a table in your db which contains EDI_PARTNER_CD and either of COMPANY_ID or COMPANY_NAME?
Thanks Chris.
You are right, COMPANY_ID is related to EDI_PARTNER_CD. Would you know how to include this relation in the CREATE statement for MG_EDI_CONVERSION ?
Thanks.
Presumably you have a table which contains both columns. Can you post the structure of this table with INSERTs to put in a few sample rows?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply