Author |
Topic  |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 04/02/2013 : 09:27:09
|
Dear All,
I have one column with newID Varchar(36). Our team plan to change it to INT. Can anyone please tell me how to change the datatype ? So my existing columns value also will change to INT datatype (like 1,2,3 etc).
Thanks and Regard's Harish Patil |
|
MIK_2008
Flowing Fount of Yak Knowledge
Pakistan
1054 Posts |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 04/02/2013 : 10:05:49
|
Dear Mik,
You min to say If I will alter the column to INT then it reflect the values into table also. Now I am store varchar(36) with newID() means ID getting store 36 varchar. If I am changing to INT then automatically my column value also will change to 1,2,3 etc.
Write?
Thanks and Regard's Harish Patil |
 |
|
Lamprey
Flowing Fount of Yak Knowledge
4614 Posts |
Posted - 04/02/2013 : 12:07:50
|
So you have a VARCHAR(36) column that is storing GUIDs and you want to convert that column to an INT? What ae your business rules for converting a GUID to an INT?
Or are you saying you want to replace the VARCHAR(36) column with an IDENTITY column?
This is where posting a proper question with DDL, DML and expected output really helps us to help you. Here are some links on how to post your question so that it is easier for us to help you and you can get tested code:
http://www.sqlservercentral.com/articles/Best+Practices/61537/ http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
Edited by - Lamprey on 04/02/2013 12:17:20 |
 |
|
MIK_2008
Flowing Fount of Yak Knowledge
Pakistan
1054 Posts |
Posted - 04/02/2013 : 12:51:29
|
quote: Originally posted by hspatil31
Dear Mik,
You min to say If I will alter the column to INT then it reflect the values into table also. Now I am store varchar(36) with newID() means ID getting store 36 varchar. If I am changing to INT then automatically my column value also will change to 1,2,3 etc.
Write?
Thanks and Regard's Harish Patil
It was with assumption that the data is currently in integer format in a column having datatype as varchar. But if the data is in string format then alter won't even work and will throw an error. So as Lamprey mention, we need more explanation.
Cheers MIK |
 |
|
|
Topic  |
|