Re: sql nvarchar(50)

From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 01/20/05


Date: Thu, 20 Jan 2005 13:28:09 -0600

There is probably more to this than that. This script works:

create table someTable
(
 CategoryName nvarchar(50)
)
go

insert into someTable
select replicate('*',75)
go

alter table sometable
 alter column CategoryName nvarchar(75)
go

insert into someTable
select replicate('*',75)
go

select * from someTable
go

drop table someTable

First time it fails, second time not. I would check:

1. The actual size of the string. It might be larger then 75, without
realizing it (my first test case was.) Use len(<value>) before your insert
to make doubly sure
2. Script out your table to make sure that the column size is actually
larger.
2. Code. Could there be triggers or something like that.causing your
issue?

-- 
----------------------------------------------------------------------------
Louis Davidson - drsql@hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design - 
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are interested in 
consulting services.  All other replies may be ignored :)
"psb" <pbellman@msn.com> wrote in message 
news:O8BgILy$EHA.3120@TK2MSFTNGP12.phx.gbl...
>I have a table with a column CategoryName as nvarchar(50).  A new category
> name I am trying to add has 59 charaters in it.  I get the typical data 
> will
> be truncated message.  I then increase the table and sp to nvarchar(75), 
> and
> I am still getting that error.  It only allows 50.  Are nvarchars stuck!!
> Can these not be changed once they are set?  I keep having problems with
> nvarchars in dbs.  this was an inherited db.  I usually stick to char or
> varchar
>
> thanks for any reply,
> ~psb
>
> 


Relevant Pages

  • Re: automate tool to change column type?
    ... schema ahead of time. ... is the change such that you can do it with ALTER TABLE? ... but save and carefully review the script. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (microsoft.public.sqlserver.tools)
  • Re: Rewritten play
    ... playwright is the soul of the theatre and the writer's script is at the heart of what we do. ... To alter it to fit one's own concept is to be a traitor to the theatre. ... Dave: So, you'd be willing to give up evil for Lisa? ... Johnny Johnson: Teaching English as a second language. ...
    (rec.arts.theatre.plays)
  • Re: ALTER IDENTITY setting...
    ... Enterprise Manager would do. ... I also would suggest you use EM and save the script. ... Pro SQL Server 2000 Database Design - ... > I just need to alter column with Identity. ...
    (microsoft.public.sqlserver.programming)
  • Re: Row size and DBCC SHOWCONTIG
    ... Andrew J. Kelly SQL MVP ... > Since I had to drop all dependent objects before issuing the ALTER COLUMN, ... >> Amy, ... >> Sorry but I didn't even see the script the first time. ...
    (microsoft.public.sqlserver.programming)
  • Re: Alter Table and ORA-00054 (only one connection)?
    ... I have an update script for a schema that changes a number of tables, ... When I run the ALTER commands separately, ... Session 1.) ...
    (comp.databases.oracle.misc)