Print Page | Close Window

Changing DataType

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12193
Printed Date: 28 March 2026 at 10:19am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Changing DataType
Posted By: Misty
Subject: Changing DataType
Date Posted: 15 October 2004 at 3:25pm
I just realized that I made a big mistake with one of my fields. I had set it to nvarchar instead of int. There's already a lot of records in this database. I get an error message in SQL Server when I try to change the datatype. How do I get it to let me change the datatype from nvarchar to int without losing the data?



Replies:
Posted By: michael
Date Posted: 15 October 2004 at 5:21pm
You can only change that without an error if the table holds integer values. There will be a warning in EM nonethless cause EM does not verify the data. Generally use
ALTER TABLE MyTable ALTER COLUMN ColumnToChange int NOT NULL
to change the data type. values that are not int will be dropped thus as in that case it's NOT NULL you will get an error.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net