Jason
Jason

Reputation: 11615

Convert Column from String to Int - Alter Script MSSQL

Can you change a column from a varchar to an int.

I have a table with a zipcode column and I want the zips to be ints instead of varchars.

Upvotes: 1

Views: 3207

Answers (2)

Flipster
Flipster

Reputation: 4401

Actually, I suggest you do NOT make that change at all. You are in a better position for future growth if you can support the alphanumeric ZIPs outside of the US, and to do that your ZIP code column should remain a varchar.

For instance, just 2 minutes ago, I received an order from:

Hever, Belgium
VLA3191

Upvotes: 3

hunter
hunter

Reputation: 63522

ALTER TABLE [TableName]
ALTER COLUMN ZipCode INT

Upvotes: 6

Related Questions