user475353
user475353

Reputation:

SQL Server Generate Script to Alter Data Type

Im using SQl Server management studio, trying to change a Datatype from char(8) to char(10) however it won't let me actually "save" the generate script (I have to send the script to someone off site)

Is there a way to do this in SQL Management Studio (it's 2008R2 for the actual database)

Upvotes: 0

Views: 1335

Answers (2)

Saic Siquot
Saic Siquot

Reputation: 6513

ALTER TABLE table_name ALTER COLUMN column_name new_datatype nullability

Plese be careful, add null or not null to the end of sentence in replace of nullability as this may change in other case

Just to show how nullability can annoy: sqlfiddle here

Upvotes: 2

Tim Lehner
Tim Lehner

Reputation: 15251

SSMS can generate the change script in a database diagram. Simply add your table to a new diagram, make your change, and, without saving, then hit the "Generate Change Script" button (or menu item).

Or you can write the correct alter table statement from scratch.

Upvotes: 0

Related Questions