I have about 200 columns in my database with VARCHAR
type which is unable to store the rupee symbol. Now I have to change the datatype of all the columns from VARCHAR
to NVARCHAR
.
Can anyone please tell me the short way to accomplish this? And why does the VARCHAR
support the pound sign and not the rupee sign? I'm asking because I have to change the pound symbol to rupee symbol.
6条答案
按热度按时间w6mmgewl1#
You can view all the columns, their data types and the table they belong using the ff query:
From the query above, you want to generate a dynamic sql that will change all your
VARCHAR
columns toNVARCHAR
.relj7zay2#
I met this issue today and Felix's answer worked quite well with one exception- if the column has default value defined. I researched a little bit and came up with the following script that drops and restores the default value.
Edited is_nullable line based on Fredrik's comment.
qoefvg9y3#
Normally in sqlserver
VARCHAR
datatype allows only the ANSI Characters, ButNVARCHAR
allows UNICODE Character sets also, Pound symbol(156-ascii number), $ symbols are comes under ANSI character set.So
VARCHAR
allows those.But when u comes to the Rupee Symbol its recently invented so it comes under UNICODE character set, to achieve the rupee symbol we need to use rupees font or glyphs... Hope you understood y Pound comes under
VARCHAR
and Rupee Comes underNVARCHAR
...mefy6pfw4#
Adding on to Felix Pamittan's answer if you need to include schema.
z9zf31ra5#
This will loop through all tables and their columns, and will generate query for updating those which have datatype as
varchar
kqqjbcuj6#