Wrox Programmer Forums
|
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 September 19th, 2005, 08:04 AM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing Datatypes

Hi,

I need to change a varchar field in my DB to a small date/time field. The problem is I don't want to lose the data, as I have quite a lot of records. Is there a way I can convert the varchar into a date?

TIA

 
Old September 19th, 2005, 11:47 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You might try ADDING a small date/time field to the same table, then do an update query to basically copy the data from your varchar field to the small date/time field, and then delete the varchar field.

Alternatively, you could use DTS to move the data over to a new table with the same format, except for the one field's data type.

HTH


mmcdonal
 
Old September 22nd, 2005, 06:29 AM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mmcdonal
 You might try ADDING a small date/time field to the same table, then do an update query to basically copy the data from your varchar field to the small date/time field, and then delete the varchar field.

Alternatively, you could use DTS to move the data over to a new table with the same format, except for the one field's data type.

HTH


mmcdonal

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
datatypes of sql server MunishBhatia SQL Server 2005 1 February 25th, 2008 02:36 AM
can i use method and datatypes if we inherite base jaychandra_1983 C# 2005 1 December 18th, 2006 04:30 AM
Query for Column Names and Datatypes rstelma SQL Server 2000 3 August 23rd, 2005 02:52 PM
Datatypes in Active Directory urs Classic ASP Databases 0 April 22nd, 2004 02:16 AM





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