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
 sql dynamic data type

Author  Topic 

dardar4
Starting Member

3 Posts

Posted - 2011-07-31 : 02:34:52
Hi guys.
as a newbie in sql world i have a small question.
i need to make a new table in our DB and one of the columns suppose to hold a string with various length (the goal is to save , for example, a txt file that is length is unknown).
is there a dynamic data type to support saving long strings?
i don't want to define nvarchar(MAX) because :
A.the string can be between 300 chars to 30,000 chars (it's unknown)
B.i don't even know if nvarchar(MAX) can support this length.

thanks in advance
Amir

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-31 : 02:38:27
use varchar(max) if you dont want to store other language characters. it can stor upto 2 GB. if you need to store even more and are using sql 2008 then configure FILESTREAM access.

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

Go to Top of Page

dardar4
Starting Member

3 Posts

Posted - 2011-07-31 : 02:54:12
is nvarchar(max) a dynamic data type? if i will have txt file with 1000 chars and a second one with 10,000 chars - will they both take the same space or each one will be exactly as the length of the txt file?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-31 : 03:40:17
each one will take exactly the length of file. varchar itself means variable character

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

Go to Top of Page

dardar4
Starting Member

3 Posts

Posted - 2011-07-31 : 03:52:22
Great
u solved my problem

thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-31 : 05:41:26
welcome

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

Go to Top of Page
   

- Advertisement -