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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help in Cast function!

Author  Topic 

padsp
Starting Member

21 Posts

Posted - 2006-03-08 : 16:09:35
Hi,

I have a table with the following structure:
Table: Meeting
ID integer not null
Desc text null

Here Col 'Desc' is a text type stores description. I have used the following UPDATE query:
UPDATE Meeting SET Desc='New Updated text......' + ' ' + CAST(Desc as varchar) WHERE ID=100

Issues:
1. Since i did'nt specify lenth for varchar it takes only 30 chars from existing value and added to the edited text.
2. If i give like this CAST(Desc as varchar(8000)); it might take only first 8000 chars; remaining would be truncated correct? I assume that will happen.
3. If i don't use CAST i get error msg: "Invalid operator for type.."
Is there any work around in this situation? or better way to do it.

Looking for your help.
Thanks
BoB

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-03-08 : 16:34:20
Did you try the vachar(8000) cast to see what happens? That's the best way to learn. And don't try it on production data, throw a quick little test together. Let us know how it goes.
Go to Top of Page

padsp
Starting Member

21 Posts

Posted - 2006-03-08 : 17:05:13
Hi
Thank you for asking me to try. I did try. when i check the LEN for Desc col - shows 8000 chars.

Go to Top of Page
   

- Advertisement -