-
Simple questions
I have some simple questions but cant seem to find the ansewer to them.
One: How do you change the date type or the datatype Length once the column is already made? With just sql querys.
Two: How do you set a primary key so every record has its own unique number?
Kesper
-
Someone correct me if needed...
1)
ALTER TABLE <table>
ALTER COLUMN <field> <datatype> <additional params>
-
2)
If exist colum with you want make Primary Key of the table ...
ALTER TABLE <table>
ADD [CONSTRAINT <constraint name>]
PRIMARY KEY [CLUSTERED | NONCLUSTERED ] (<colname> [ASC | DESC][,<colname>...])
EXAMPLE:
ALTER TABLE aaa ADD CONSTRAINT aaa_PK PRIMARY KEY (col1)
-----
If not , first you must add column with unique values and than make ALTER TABLE...