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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 need to get information from one table

Author  Topic 

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-09 : 10:34:52
Given the source table

DESTINATION TABLE where whre Provider ID is the join.
CREATE TABLE [dbo].[tblContactHistory](
[HistoryID] [int] NOT NULL,
[ProviderID] [int] NULL,
[Type] [nvarchar](20) NULL,
[EffectiveDate] [datetime] NULL,
[Information] [nvarchar](250) NULL,
[FinancialContactPrefix] [nvarchar](4) NULL,
[FinancialContact] [nvarchar](50) NULL,
[FinancialPosition] [nvarchar](50) NULL,
[FinancialPhone] [nvarchar](14) NULL,
[FinancialExtension] [nvarchar](4) NULL,
[FinancialFax] [nvarchar](14) NULL,
[FinancialEmail] [nvarchar](50) NULL,
CONSTRAINT [PK_tblContactHistory_1] PRIMARY KEY CLUSTERED
(
[HistoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[tblContactHistory] WITH CHECK ADD CONSTRAINT [FK_tblContactHistory_tblServiceProvider] FOREIGN KEY([ProviderID])
REFERENCES [dbo].[tblServiceProvider] ([ProviderID])
GO

ALTER TABLE [dbo].[tblContactHistory] CHECK CONSTRAINT [FK_tblContactHistory_tblServiceProvider]
GO

---------------------------------------------------
INSERT INTO tblFinancialContact (
[FinancialContactID],
[ProviderID],
[FinancialContactPrefix],
[FinancialContact],
[FinancialPosition],
[FinancialPhone],
[FinancialExtension] ,
[FinancialFax] ,
[FinancialEmail]
)
[FinancialContactPrefix],
[FinancialContact],
[FinancialPosition],
[FinancialPhone],
[FinancialExtension] ,
[FinancialFax] ,
[FinancialEmail]
FROM dbo.tblContactHistory where tblContactHistory.ProviderID = tblServiceProvider.ProviderID

???????

Any help would be awesome.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-09 : 10:37:50
[code]
FROM dbo.tblContactHistory
INNER JOIN tblServiceProvider
ON tblContactHistory.ProviderID = tblServiceProvider.ProviderID
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-09 : 11:10:19
INSERT INTO tblContactHistoryTest (
[FinancialContactPrefix],
[FinancialContact],
[FinancialPosition],
[FinancialPhone],
[FinancialExtension] ,
[FinancialFax] ,
[FinancialEmail]
)
[FinancialContactPrefix],
[FinancialContact],
[FinancialPosition],
[FinancialPhone],
[FinancialExtension] ,
[FinancialFax] ,
[FinancialEmail]
FROM dbo.tblContactHistoryTest
INNER JOIN tblServiceProvider
ON tblContactHistoryTest.ProviderID = tblServiceProvider.ProviderID

Msg 102, Level 15, State 1, Line 11
Incorrect syntax near 'FinancialContactPrefix'.

Any help would be awesome.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-03-09 : 11:19:22
quote:
Originally posted by mcupryk

INSERT INTO tblContactHistoryTest (
[FinancialContactPrefix],
[FinancialContact],
[FinancialPosition],
[FinancialPhone],
[FinancialExtension] ,
[FinancialFax] ,
[FinancialEmail]
)
SELECT
[FinancialContactPrefix],
[FinancialContact],
[FinancialPosition],
[FinancialPhone],
[FinancialExtension] ,
[FinancialFax] ,
[FinancialEmail]
FROM dbo.tblContactHistoryTest
INNER JOIN tblServiceProvider
ON tblContactHistoryTest.ProviderID = tblServiceProvider.ProviderID

Msg 102, Level 15, State 1, Line 11
Incorrect syntax near 'FinancialContactPrefix'.

Any help would be awesome.



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

Go to Top of Page
   

- Advertisement -