Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
deanglen
Yak Posting Veteran
65 Posts |
Posted - 2012-07-23 : 08:54:58
|
HiIn a table called Order I have a column called Notes that currently showsNotes (ntext, null)If I wanted to change this to 200 characters what would the script be?I tried ALTER TABLE Order MODIFY Notes varchar(200)But I can't get it to work. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-07-23 : 09:11:02
|
[code]ALTER TABLE Order MODIFY ALTER COLUMN Notes varchar(200)[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
deanglen
Yak Posting Veteran
65 Posts |
Posted - 2012-07-23 : 10:09:15
|
HiTried that but I think there are some columns where there are already more than 200 characters. Msg 8152, Level 16, State 10, Line 1String or binary data would be truncated.The statement has been terminated.So I need to alter those records that are 200 or more I guess?I tried SELECT *FROM OrderWHERE LEN(Notes) >200;But get thisMsg 8116, Level 16, State 1, Line 1Argument data type ntext is invalid for argument 1 of len function.Any ideas? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-23 : 10:12:28
|
use datalengthSELECT *FROM OrderWHERE DATALENGTH(Notes) >200 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
deanglen
Yak Posting Veteran
65 Posts |
Posted - 2013-05-03 : 06:12:19
|
Brilliant! thanks worked fine |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-03 : 06:18:43
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|