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
 appending dolar sign to ntext type

Author  Topic 

anjali5
Posting Yak Master

121 Posts

Posted - 2011-11-30 : 15:36:28
I am trying to append a '$$$' sign to a type of ntext
so I have this col1, I am trying to so

select '$$$' +[summary]+ '$$$' summary
from table A

I am getting an error
The data types varchar and ntext are incompatible in the add operator.

How can I achevie this without getting an error.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-11-30 : 16:13:50
Use UPDATETEXT

Note that ntext is deprecated. If you're storing character data, should be using nvarchar anyway.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-01 : 00:22:15
if its 2005 or later, since you're not storing concatenated value anywhere and its just in select, easiest method would be to cast ntext to nvarchar(max) and then do the concatenation

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jassi.singh
Posting Yak Master

122 Posts

Posted - 2011-12-01 : 04:16:42
Hi,

Please refer some casting examples, you will get an idea and clarity
http://msdn.microsoft.com/en-us/library/ms177561.aspx
http://www.techrepublic.com/blog/10things/10-reasons-to-explicitly-convert-sql-server-data-types/324
http://msdn.microsoft.com/en-us/library/aa276862%28v=sql.80%29.aspx
Go to Top of Page

anjali5
Posting Yak Master

121 Posts

Posted - 2011-12-01 : 12:39:53
I thought there is a limit of 4000 caharacters on varchar and nvarchar. What is the limit on nvarcar(max). I am storing 8000 character data in this field.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-01 : 12:44:49
quote:
Originally posted by anjali5

I thought there is a limit of 4000 caharacters on varchar and nvarchar. What is the limit on nvarcar(max). I am storing 8000 character data in this field.


nvarchar(max) is a BLOB data type and it can store upto 2 GB of data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

anjali5
Posting Yak Master

121 Posts

Posted - 2011-12-01 : 13:16:36
Thanks Visakh!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-02 : 01:03:33
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -