This is a mirror of official site: http://jasper-net.blogspot.com/

Change Column DataTypes

| Monday, October 18, 2010
There are times when I feel like writing that I am a day old in SQL Server. In fact, there are many who are looking for solution that is simple enough. Have you ever searched online for something very simple. I often do and enjoy doing things which are straight forward and easy for change.

In this blog post, we will see how to change the datatypes of the column.

We will create a sample table and change the column datatypes.

USE tempdb
GO
CREATE TABLE dbo.SampleTable
(ID INT, FirstCol VARCHAR(10), SecondCol DATETIME)
GO
ALTER TABLE dbo.SampleTable
ALTER COLUMN ID VARCHAR(100)
GO
ALTER TABLE dbo.SampleTable
ALTER COLUMN FirstCol VARCHAR(100)
GO
ALTER TABLE dbo.SampleTable
ALTER COLUMN SecondCol VARCHAR(100)
GO
sp_help 'SampleTable'
GO

In our example, it was possible to change the data types easily. If you face any errors, as per your error, you will have to adjust your business logic.

Read more: Journey to SQL Authority with Pinal Dave

Posted via email from .NET Info

0 comments: