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
 Varchar(50) or Varchar(Max)

Author  Topic 

asm
Posting Yak Master

140 Posts

Posted - 2007-10-31 : 03:39:32
Hi

I my database i am using varchar(50) data type and problem
is for every filed i have to assign the size of varchar i.e. varchar(10), varchar(100) etc...
Problem occur when the programmer forget to fixed the length of acceptance of data in frot end and user give the data more than 10 digit .. it will display an error message.

So, In Sql Server 2005 .. data type is varchar(max) ,
So I want to know I can change the data type of every varchar(1), varchar(10), varchar(100) etc... to varchar(max)

thanks



jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2007-10-31 : 04:02:41
Even though it is tempting to use this method , from a db architecture point of view , the data model should constrain the size and act as a rough guid to the user interface

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-31 : 04:16:43
You need to restrict users at front end typing more than the allowed length of characters

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-10-31 : 08:54:36

you can't use as such varchar(max) in database as it quite' possible that different entries in same field are of varing length
like
f_name
-------
rahul
ashish
ram
johnalexzender

so in that case if restrict the length by max it will have to be done by buisness logic that first find the
length ofeach entry in same field then find maximum of those
and then decided the length of column it may be done at front end of your application
like at click event of any button bt CAN't BE APPLIED DIRECTLY in database

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2007-10-31 : 09:01:24
quote:

Posted - 10/31/2007 : 08:54:36
--------------------------------------------------------------------------------

you can't use as such varchar(max) in database as it quite' possible that different entries in same field are of varing length
like
f_name
-------
rahul
ashish
ram
johnalexzender

so in that case if restrict the length by max it will have to be done by buisness logic that first find the
length ofeach entry in same field then find maximum of those
and then decided the length of column it may be done at front end of your application
like at click event of any button bt CAN't BE APPLIED DIRECTLY in database

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA



eh? i think OP meant using the datatype varchar(max) i.e. the SQL2005 replacement for text datatype

Em
Go to Top of Page
   

- Advertisement -