Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2005, 09:24 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data type change from int to Varchar

Hi,

I use sql server 2003 data base. I want to change one of the field in a table from int to varchar without losing any data. Is it possible? If so, please let me know how to do it.

Thanks in advance.

GG

 
Old April 29th, 2005, 09:59 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

create a new column of varchar and update it with exisitng column
UPDATE myTable
SET NewvarcharCol = CONVERT(varchar(20),intcolumn)

Check your data and drop the original column..

why are you converting your column data type..?

there is no SQL Server 2003.. (SQL server 2000 only)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cast varchar as int SQL Server 2005 mr_pc1963 SQL Language 2 April 23rd, 2008 06:09 AM
Error converting data type varchar to int. - SQL baysaa SQL Server ASP 1 March 16th, 2008 11:56 PM
Is maxium size of varchar data type is 8000? kawrat SQL Server 2000 7 February 5th, 2007 04:08 AM
Error converting data type varchar to float. Trojan_uk SQL Server ASP 5 April 27th, 2004 02:56 AM
change data type to date kherboon Access 2 July 29th, 2003 10:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.