Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Practice InterviewNew Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

MSSQL Interview Questions and Answers

Ques. How To Add a New Column to an Existing Table with "ALTER TABLE ... ADD" in MS SQL Server?
Ans. If you have an existing table with existing data rows, and want to add a new column to that table, you can use the "ALTER TABLE ... ADD" statement. The tutorial script below shows you a good example:

ALTER TABLE test ADD author VARCHAR(40)
GO

sp_columns test
GO
TABLE_OWNER TABLE_NAME COLUMN_TABLE TYPE_NAME ...
dbo test id int ...
dbo test subject varchar ...
dbo test description varchar ...
dbo test create_date datetime ...
dbo test author datetime ...

SELECT * FROM test
GO
id subject description create_date author

This SQL script added a new column called "author" to the "test" table. NULL values were added to this column on all existing data rows.
Is it helpful? Yes No

Most helpful rated by users:

©2020 WithoutBook