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 2005 Forums
 Transact-SQL (2005)
 delete columns in the following table.

Author  Topic 

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-08 : 13:42:00
i need to delete the columns in the table if they exist
CREATE TABLE [dbo].[tblServiceProvider](
[ProviderID] [int] NOT 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,
[NewProvider] [bit] NOT NULL,
CONSTRAINT [PK_tblServiceProvider] PRIMARY KEY CLUSTERED
(
[ProviderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO


These are the columns:

[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

Any help would be awesome.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-08 : 13:42:42
You can use ALTER TABLE DROP COLUMN for that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-08 : 13:44:34
any help?

Any help would be awesome.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-08 : 13:48:55
What part are you having problems with? I provided the command you'll need to use for this. Do you have Books Online installed to lookup the syntax? Show us what you have so far.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-08 : 13:50:46
thanks

Any help would be awesome.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-08 : 14:21:22
Is "Any help would be awesome." your signature or do you need additional help?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-03-08 : 14:30:57
ALTER TABLE tblServiceProvider DROP COLUMN FinancialContactPrefix
ALTER TABLE tblServiceProvider DROP COLUMN FinancialContact
ALTER TABLE tblServiceProvider DROP COLUMN FinancialPosition
ALTER TABLE tblServiceProvider DROP COLUMN FinancialPhone
ALTER TABLE tblServiceProvider DROP COLUMN FinancialExtension
ALTER TABLE tblServiceProvider DROP COLUMN FinancialFax
ALTER TABLE tblServiceProvider DROP COLUMN FinancialEmail


Any help would be awesome.
Go to Top of Page
   

- Advertisement -