Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 The multi-part identifier "Ship_b.Load_#"

Author  Topic 

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-10-01 : 15:54:03
I'm trying to perform a simple insert into an existing table Ship_b and I only want records from table Ship_a that have different Load_# from records that are already in table Ship_b. Looks like my where statement should get rid of any of the records from Ship_a that are the same as the records in Ship_b.

INSERT INTO [Ship_b]
([Load_#]
,[Ship_#]
,[Billing address])
SELECT ([Load_#]
,[Ship_#])
,[Billing address]
FROM [Ship_a]
WHERE [Ship_b].[Load_#] <> [Ship_a].[Load_#]

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-10-01 : 21:32:46
[code]INSERT INTO
[Ship_b] ([Load_#], [Ship_#],[Billing address])
SELECT a.[Load_#], a.[Ship_#], a.[Billing address]
FROM [Ship_a] a
LEFT JOIN
[Ship_b] b
On a.[Load_#] = b.[Load_#]
WHERE b.[Load_#] IS NULL;[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-02 : 03:05:12
also

INSERT INTO
[Ship_b] ([Load_#], [Ship_#],[Billing address])
SELECT a.[Load_#], a.[Ship_#], a.[Billing address]
FROM [Ship_a] a
WHERE NOT EXISTS(SELECT 1 FROM [Ship_b] b
WHERE a.[Load_#] = b.[Load_#])


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-10-03 : 13:59:09
Russel and visakh16 thanks for taking the time to help me your solutions worked and your help is greatly appreciated!!!!
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-10-03 : 22:59:28
Glad to help
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-04 : 09:34:42
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -