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 July 17th, 2003, 07:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default sql datatype change be changed

Hi,

I am try to change the sql datatype
varchar to numeric,
it is give message that datatype can not be changed.
and data will lost.

How I can change the datatype without lost of data.
I have thousands of records in a table.

Mateen
 
Old July 17th, 2003, 08:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Why don't you copy the records before you change the data type, then if anything nasty happens, you've still got your records. Use a simple SELECT INTO query, like this:
Code:
SELECT * INTO NewTable
FROM TableYouWantToChange
 
Old July 17th, 2003, 08:34 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

You will need to check the size of your varchar data to see if exceeds the numeric data type size.

If not the error raised should be arithmetic overflow. Did you get this message?

Regards

Nickie
 
Old July 18th, 2003, 03:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for response.

I have copy the records before changing.
but it is not change the datatype,
if datatype changed and data lost
how I can re-enter the records into the changed table
from the backup table.
I have thusanads of records.




Quote:
quote:Originally posted by pgtips
 Why don't you copy the records before you change the data type, then if anything nasty happens, you've still got your records. Use a simple SELECT INTO query, like this:
Code:
SELECT * INTO NewTable
FROM TableYouWantToChange





Similar Threads
Thread Thread Starter Forum Replies Last Post
datatype of sql MunishBhatia SQL Server 2005 4 January 5th, 2007 10:22 PM
Sql servere datatype monika.vasvani SQL Server 2000 2 December 14th, 2006 03:11 PM
SQL Text Datatype bekim ASP.NET 1.0 and 1.1 Professional 2 March 28th, 2006 12:05 AM
SQL Datatype rain_uk SQL Server ASP 2 July 5th, 2005 01:34 AM
Search and update SQL database if value is changed jakvike VBScript 1 August 4th, 2004 06:32 AM





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