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.
-- CharlieUpdate 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
>
Friday, March 23, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment