Re: How to alter a Varchar column to a shorter length (with data in it)
From: Geoff N. Hiten (SRDBA_at_Careerbuilder.com)
Date: 06/28/04
- Next message: Paul S Randal [MS]: "Re: Maintenance Job failure"
- Previous message: Paul S Randal [MS]: "Re: SQL Database Maintenance"
- In reply to: C. Ming Lu: "How to alter a Varchar column to a shorter length (with data in it)"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 28 Jun 2004 14:36:51 -0400
Update table Unit
set Unit_Name = left(Unit_Name, 15)
where len(Unit_Name) > 15
Then run your alter table command.
-- Geoff N. Hiten Microsoft SQL Server MVP Senior Database Administrator Careerbuilder.com I support the Professional Association for SQL Server www.sqlpass.org "C. Ming Lu" <cminglu@qmxs.com> wrote in message news:OA8na3TXEHA.2844@TK2MSFTNGP12.phx.gbl... > Hi, > > I am trying to write a script to trim the length of a paticular column > 'Unit_Name' (its orginial length is: 256). There are already data in the > table (with length over 15 chararters). > > The following script gives me a erro and aborted. > Alter table Unit alter column Unit_Name varchar (15) null > go > > Question: > The data can be truncated, how do I suppress the error and force the > script finish ? > > Thanks. > > --- Charlie > >
- Next message: Paul S Randal [MS]: "Re: Maintenance Job failure"
- Previous message: Paul S Randal [MS]: "Re: SQL Database Maintenance"
- In reply to: C. Ming Lu: "How to alter a Varchar column to a shorter length (with data in it)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|