Monday, February 20, 2012

Reduce field data Length

Hi All,
I am facing some problem in the field data(Description field in Item table[table1]). In that table one field(Description field)data legth is 255 and type: nvarchar. In some operation this field data transfer to another table(Ex; table2) field. That table2 field length is 100. For some reason i can;t change the structure of the table. So allways i will get error data type mismatch or related error to data type. When i update table1 (Description field)field with null data and run the operation in database application i don;t get any error. The error causing because data length. I have 200,000 records in the table. I m planning to update the records (the description field) to reduce the length of data using sql command. If anyone know sql command for reducing the length of data(Not a field length-If its field i can restrict the length but my question is only reduce the length of data) please help me to resolve.

ThanksIt sounds like you dont want to run the ALTER TABLE but just want to chop the
contents of the field, if so you can even do this in the update query to table 2
but KISS would go like this

update table1
set longer_fieldie = substr(longer_fieldie, 1,100)

Ciao|||

Quote:

Originally Posted by tifoso

update table1 set longer_fieldie = substr(longer_fieldie, 1,100)
Ciao


By this way you are going to loose your data by chopping it to fit your size.|||

Quote:

Originally Posted by debasisdas

By this way you are going to loose your data by chopping it to fit your size.


i am getting error when i execute ur command
Here my code:
update IMA
set IMA_ITEMNAME = substr(IMA_ITEMNAME, 1,100)
WHERE IMA_itemid like N'316%'

and i m getting error:
'substr' is not a recognized function name.

No comments:

Post a Comment