473,714 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing data-types

Hi All,

I have a varchar(255) column for storing text in english and in
hebrew.
It was a stupid mistake to set the data type to be varchar, because
now I need to store text in german and francais too.

Question: Is it safe to change the data type from varchar to nvarchar,
without damaging the data that's already present?
(I have more than 1000000 records stored...)

Thanks,
Danny

Sep 4 '07 #1
4 4092
This should work, but note it'll take awhile and your DB may be unavailable
during that time.

--
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html

"Danny" <ad*********@gm ail.comwrote in message
news:11******** **************@ o80g2000hse.goo glegroups.com.. .
Hi All,

I have a varchar(255) column for storing text in english and in
hebrew.
It was a stupid mistake to set the data type to be varchar, because
now I need to store text in german and francais too.

Question: Is it safe to change the data type from varchar to nvarchar,
without damaging the data that's already present?
(I have more than 1000000 records stored...)

Thanks,
Danny

Sep 4 '07 #2
Yes, it is safe, even though it will seriously impact server performance
during the conversion, cost a lot of log space (temporarily). Also, you
should expect serious growth of the required space for the table, expect
the current table size * 2.

BTW, the simple test below proves the change is safe.

CREATE TABLE Test (a varchar(255))
INSERT INTO Test VALUES ('a')
INSERT INTO Test VALUES (REPLICATE('b', 255))
INSERT INTO Test DEFAULT VALUES
SELECT * FROM Test
go
ALTER TABLE Test ALTER COLUMN a nvarchar(255)
go
SELECT * FROM Test
DROP TABLE Test

--
Gert-Jan
Danny wrote:
>
Hi All,

I have a varchar(255) column for storing text in english and in
hebrew.
It was a stupid mistake to set the data type to be varchar, because
now I need to store text in german and francais too.

Question: Is it safe to change the data type from varchar to nvarchar,
without damaging the data that's already present?
(I have more than 1000000 records stored...)

Thanks,
Danny
Sep 4 '07 #3
Danny (ad*********@gm ail.com) writes:
I have a varchar(255) column for storing text in english and in
hebrew.
It was a stupid mistake to set the data type to be varchar, because
now I need to store text in german and francais too.

Question: Is it safe to change the data type from varchar to nvarchar,
without damaging the data that's already present?
(I have more than 1000000 records stored...)
Provided that the collation of the column is a Hebrew collation, yes.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Sep 4 '07 #4
On Sep 5, 1:12 am, Erland Sommarskog <esq...@sommars kog.sewrote:
Danny (adler.da...@gm ail.com) writes:
I have a varchar(255) column for storing text in english and in
hebrew.
It was a stupid mistake to set the data type to be varchar, because
now I need to store text in german and francais too.
Question: Is it safe to change the data type from varchar to nvarchar,
without damaging the data that's already present?
(I have more than 1000000 records stored...)

Provided that the collation of the column is a Hebrew collation, yes.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se

Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx
Thanks you guys.

Danny

Sep 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2329
by: z0ink | last post by:
I am working on a small graphing application. In the process of graphing I use 3 seperate scripts for getting the job done. The first is the page that the use sees and selects all the data from. This selected data gets passed internally using session variables to the next page. This page takes the passed data, runs it for error checking and determines where to send it next. I have gotten most of the desired results through this method...
9
10911
by: Jon Brunson | last post by:
Is it possible to use a DataAdapter to fill a DataTable, change the DataColumns of that DataTable (and maybe even it's name) and then commit those changes to the database (in my case SQL Server 2000)? Eg: Dim dc As New SqlCommand("SELECT TOP 0 * FROM SomeTable", SomeSqlConnection)
7
6059
by: Stefan Finzel | last post by:
Hi, is there a way to change the display property on Windows Mobile 2003 SE Mobile/Pocket Internet Explorer? See following example. Please note: visibilty property has the same problem. Is there any other way to display/undisplay parts of web pages? TIA
13
2913
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify the field type when running a make table query? Thanks, Sven
10
15375
by: Marizel | last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I often find myself with a query which I'd like to reuse, but with a different datasource. These datasources generally have identical field names. The queries select a subset of the fields, so "Select *" is not really an option. Is there an easy way to change the source of a query, either in the design grid or SQL display? I suppose I could copy the SQL into WordPad...
1
3077
by: Rolln_Thndr | last post by:
I'm vey new to network programing and have a few rather fundemental questions. I'm creating a very basic UDP proxy server and having a few issues regarding the sockets. Is it possible to change the properties of a socket WITHOUT closing it and creating a new one? Basically, I need to change the port of a bound socket, but the only way I have found to do this so far is to close the exisitng socket and create a new one. This in itself...
32
3682
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's RecordSource like this? Am I asking for trouble doing this with a memo field? Thanks in advance. Private Sub cmdNextNote_Click() Dim lngNid As Long If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
4
1473
by: aqazi | last post by:
Hi guys I am having a problem with arrayu manipulation. in my php script i am reading from a csv file. the content of file is like this: name,color,quantity,price; apple,red,10,$2; mango,green,12,$2.5; orange,orange,8,$1.5;
4
1838
by: andychambers2002 | last post by:
I'm working on a "TempFile" class that stores the data in memory until it gets larger than a specified threshold (as per PEP 42). Whilst trying to implement it, I've come across some strange behaviour. Can anyone explain this? The test case at the bottom starts a TempFile at size 50 and prints its type. It then increases the size to the threshold at which point "self" is changed to being a TemporaryFile. It seems that the next call...
4
4895
by: John Kotuby | last post by:
Hi all, I have a simple user-form which accepts contact and profile information for the user to edit and save. All the textboxes are working fine and displaying the expected data, both when the screen is first displayed and after a save of changed data. The text boxes are being populated during the Page_Load event. However, when I change the TextMode property to PassWord, as I have 2 password textboxes (one for confirmation) no data...
0
9314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3158
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.