hi i'm a new user to ms sql 2005.

Can anyone please tell me how can i make a existing null constraint column of a table
as a not null .....

i.e If a column already exists and can hv null value ,then how can i convert it into not null column so that i can make it primary , using Queries only.

eg:

create table dbs
(
ename varchar(20),
phn numeric
)

by default both ename and integer is nullable........
Now if i want to convert ename into not nullable then how can I do this??

so that it can be later on be a primary key
plz help me out....

You can use the ALTER TABLE statement to do this...

ALTER TABLE dbs
ALTER COLUMN ename varchar(20) NOT NULL;
GO

ALTER TABLE dbs
ADD CONSTRAINT pk_ename PRIMARY KEY (ename);
GO
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.