Quantcast
Channel: Shailendra Saxena
Viewing all articles
Browse latest Browse all 18

Alter table Change Data Type in SQL Server

$
0
0
Hi,

Following are the few inportnat queries whih is needed when one need to alter table.


1. Alter table and change data type.
alter table tbldelegates
ALTER COLUMN de_lastname VARCHAR(50)

2. alter table add new column with default.
ALTER TABLE tblCourse
ADD NewCol VARCHAR(50) Default '' Not null

3. Alter table drop column with constraint
       a. First drop the constraint
      ALTER TABLE Course
      drop constraint DF__Course__NewCol__1BFD2C07

      b. then drop the column
     ALTER TABLE Course
     DROP column NewCol

Viewing all articles
Browse latest Browse all 18

Trending Articles