want to allow null values

want to set
date, orderid, trackingnumber, shipper, cost, void, name,address


to allow null values
(from not null to null)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[trackingnumbers](
	[trackingnumberid] [int] IDENTITY(1,1) NOT NULL,
	[date] [datetime] NOT NULL CONSTRAINT [DF_trackingnumbers_date]  DEFAULT (getdate()),
	[orderid] [varchar](50) NOT NULL,
	[trackingnumber] [varchar](50) NOT NULL,
	[shipper] [varchar](10) NOT NULL,
	[cost] [decimal](10, 2) NOT NULL,
	[void] [varchar](20) NOT NULL,
	[name] [varchar](100) NOT NULL,
	[address] [varchar](100) NOT NULL,
 CONSTRAINT [PK__trackingnumbers__2B3F6F97] PRIMARY KEY CLUSTERED 
(
	[trackingnumberid] 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
SET ANSI_PADDING OFF

Open in new window

LVL 1
rgb192Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tigin44Commented:
use this
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[trackingnumbers](
        [trackingnumberid] [int] IDENTITY(1,1) NOT NULL,
        [date] [datetime] CONSTRAINT [DF_trackingnumbers_date]  DEFAULT (getdate()),
        [orderid] [varchar](50),
        [trackingnumber] [varchar](50),
        [shipper] [varchar](10),
        [cost] [decimal](10, 2),
        [void] [varchar](20),
        [name] [varchar](100),
        [address] [varchar](100),
 CONSTRAINT [PK__trackingnumbers__2B3F6F97] PRIMARY KEY CLUSTERED 
(
        [trackingnumberid] 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
SET ANSI_PADDING OFF

Open in new window

0
Aneesh RetnakaranDatabase AdministratorCommented:
CREATE TABLE [dbo].[trackingnumbers](
      [trackingnumberid] [int] IDENTITY(1,1) NOT NULL,
      [date] [datetime] NULL CONSTRAINT [DF_trackingnumbers_date]  DEFAULT (getdate()),
      [orderid] [varchar](50) NULL,
      [trackingnumber] [varchar](50) NULL,
      [shipper] [varchar](10) NULL,
      [cost] [decimal](10, 2) NULL,
      [void] [varchar](20) NULL,
      [name] [varchar](100) NULL,
      [address] [varchar](100) NULL,
 CONSTRAINT [PK__trackingnumbers__2B3F6F97] PRIMARY KEY CLUSTERED
(
      [trackingnumberid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]


or for an existing table

ALTER TABLE [dbo].[trackingnumbers] alter column [orderid] [varchar](50)  NULL   --
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:


trackingnumbers is an existing table

would i do this
ALTER TABLE [dbo].[trackingnumbers] alter column [orderid] [varchar](50)  NULL   --

for every column
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

tigin44Commented:
instead copy the current data to a temporary table ... recreate the table and move the data back to the original table
0
tigin44Commented:
this should do that
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO

SELECT * INTO trackingnumbers_TMP
FROM trackingnumbers

DROP TABLE trackingnumbers

CREATE TABLE [dbo].[trackingnumbers](
        [trackingnumberid] [int] IDENTITY(1,1) NOT NULL,
        [date] [datetime] CONSTRAINT [DF_trackingnumbers_date]  DEFAULT (getdate()),
        [orderid] [varchar](50),
        [trackingnumber] [varchar](50),
        [shipper] [varchar](10),
        [cost] [decimal](10, 2),
        [void] [varchar](20),
        [name] [varchar](100),
        [address] [varchar](100),
 CONSTRAINT [PK__trackingnumbers__2B3F6F97] PRIMARY KEY CLUSTERED 
(
        [trackingnumberid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

INSERT INTO trackingnumbers
SELECT * FROM trackingnumbers_TMP

GO
SET ANSI_PADDING OFF

Open in new window

0
rgb192Author Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.