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
 string type datatype

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-08 : 00:23:53
Hi again and again. I have problem on varchar coz it cannot handle more than 8000 characters. Is there any datatype to use instead of varchar? I tried to use ntext and text but they are not allowed to use in query analyzer.

DECLARE @religion varchar (8000)
set @religion = 'aaasdsassssss...........'

thanks.
-Ron-

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-08 : 00:29:35
are you using SQL Server 2005 ? SQL Server 2005 supports use varchar(max)


KH

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-08 : 00:29:56
You can't use ntext and text for declaring local variables, they are only allowed as column data types of table.


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-08 : 00:34:40
"are you using SQL Server 2005 ? SQL Server 2005 supports use varchar(max)"

yes. sql server 2005. the max value for varchar is 8000. so, varchar(max) is also equal to varchar(8000)

-Ron-
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-08 : 00:38:08
Nope. Refer to BOL

From 2005 BOL
quote:

varchar [ ( n | max ) ]
Variable-length, non-Unicode character data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of data entered + 2 bytes. The data entered can be 0 characters in length. The SQL-2003 synonyms for varchar are char varying or character varying.



Or the online BOL http://msdn2.microsoft.com/en-us/library/ms176089.aspx if you do not have BOL


KH

Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-08 : 00:44:25
DECLARE @religion varchar (max)
set @religion = 'sdsadsdsd....thousand characters....'

is it the proper syntax?
edit: Ok thanks I got it.yahoooo.
thanks
-ron-
Go to Top of Page
   

- Advertisement -