Friday, February 24, 2012

Join Problem, I do not understand

I have some tables that I need to join. On two that I need to join the
columns are the same except for one, but I want to join them once and from
then on, only when a value has changed. How can this be done.
Thank you
DeeWe need some more details. Please provide DDL for your tables and DML to
load some sample data into those tables, and tell us the result you want
from that sample data.
Tom
"Dee" <Dee@.discussions.microsoft.com> wrote in message
news:2AE674DF-C48C-46FF-9567-F239A62535BC@.microsoft.com...
>I have some tables that I need to join. On two that I need to join the
> columns are the same except for one, but I want to join them once and from
> then on, only when a value has changed. How can this be done.
> Thank you
> Dee|||This is very lengthy:
CREATE TABLE [dbo].[GG Products](
[id] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[path] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[name] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[abstract] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[code] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[price] [decimal](18, 2) NULL,
[sale-price] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[cost] [decimal](18, 2) NULL,
[margin] [int] NULL,
[ship-weight] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[availability] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[orderable] [bit] NOT NULL,
[taxable] [bit] NOT NULL,
[seat-size1] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[arm-height] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[back-size] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[capacity] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[weight] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[exterior-size] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[height] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[width] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[overall-dimensions] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[main] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[bridge] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[return] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[sale-price-text] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[seat-height] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[seat-thickness] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[seat-width] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[recliner] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ottoman] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[shipping-info] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[shipping-options] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[color-options] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[dims] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[diameter] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[quantity-per-carton] [nvarchar](75) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[right-column] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[out-of-stock] [bit] NOT NULL,
[custom-order] [bit] NOT NULL,
[quickship] [bit] NOT NULL,
[60-day-guarantee] [bit] NOT NULL,
[free-shipping] [bit] NOT NULL,
[is-top-seller] [bit] NOT NULL,
[template-number] [nvarchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[credenza] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[hutch] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[custom-options] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[contents] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[optional] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[related-samples] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[caption] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[flat-ship-rate1] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[shipping-cost] [int] NULL,
[Manufacturer] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[mpn] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[UPC] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ISBN] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ASIN-Amazon Number] [nvarchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[collection] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[options] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[delivery] [real] NULL,
[shipping-price] [int] NULL,
[keywords] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[product-type] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[made-in] [nvarchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[age-range] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Promo] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Free-shipping2] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[department] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[materials] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[gender] [nvarchar](6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[artist-designer] [nvarchar](60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[green-certified] [bit] NOT NULL,
[CA Product Summary] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[CA Product Short Name] [nvarchar](100) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL,
[CA Promo Text] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[product-url] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Vendor] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Completed] [bit] NOT NULL,
[Updated] [datetime] NULL,
[map-price] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[leaf] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[depth] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[interior-size] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[length] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[degree-of-swivel] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[seat-depth] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[back-height-from-seat] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[UserID] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Inside-delivery] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[s_GUID] [uniqueidentifier] NULL,
[Gen_abstract] [int] NULL,
[Gen_caption] [int] NULL,
[Gen_color-options] [int] NULL,
[Gen_contents] [int] NULL,
[Gen_custom-options] [int] NULL,
[Gen_dims] [int] NULL,
[Gen_mpn] [int] NULL,
[Gen_optional] [int] NULL,
[Gen_options] [int] NULL,
[Gen_Promo] [int] NULL,
[Gen_related-samples] [int] NULL,
[Gen_right-column] [int] NULL,
[s_ColLineage] [image] NULL,
[s_Generation] [int] NULL,
[s_Lineage] [image] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Both tables are pretty much the same except for one added column in the
other table. I would like to first combine them into another table, then
update that table only when a value has changed. In other words how to I
check the values. I know that one thing I could do to combine the tables is
add a column to the first table.
Also if other columns are added I do not understand how to do a left join.
This info is coming from an access data base and has to be updated nightly
so I need to know how to do that as well. I do know what I can use the
maintenance tool for that, but do not know how to put to the script I will
use.
Thank you
Dee
"Tom Cooper" wrote:
> We need some more details. Please provide DDL for your tables and DML to
> load some sample data into those tables, and tell us the result you want
> from that sample data.
> Tom
> "Dee" <Dee@.discussions.microsoft.com> wrote in message
> news:2AE674DF-C48C-46FF-9567-F239A62535BC@.microsoft.com...
> >I have some tables that I need to join. On two that I need to join the
> > columns are the same except for one, but I want to join them once and from
> > then on, only when a value has changed. How can this be done.
> >
> > Thank you
> > Dee
>
>

No comments:

Post a Comment