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 add columns to a table

Author  Topic 

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-09 : 10:14:38
I have the following columns to add
[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,
------------------------------
CREATE TABLE [dbo].[tblContactHistory](
[HistoryID] [int] NOT NULL,
[ProviderID] [int] NULL,
[Type] [nvarchar](20) NULL,
[EffectiveDate] [datetime] NULL,
[Information] [nvarchar](250) 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

Any help would be awesome.

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2011-03-09 : 10:28:25
Are you creating the table? or had the table been created with the code provided?

You could try:
ALTER TABLE tblContactHistory
ADD [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
Go to Top of Page

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-09 : 10:35:35
the table is created.

Any help would be awesome.
Go to Top of Page

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-09 : 10:46:11
nice job djj55

Any help would be awesome.
Go to Top of Page
   

- Advertisement -