Solved

varchar length

Posted on 2002-07-09
6
644 Views
Last Modified: 2008-07-03
I am facing a problem with the varchar data type in Microsoft SQL Server 7.0

Whenever I use this datatype its length doesnot automatically increases to accomodate the characters although they are less than 100 characters let alone 8K limit.

Even after repeated tries I am unable to make the length flexible.

Please advise
0
Comment
Question by:Pragam
  • 3
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7141643
Did you try:

Declare @Variable varchar(8000)

Otherwise try posting your code.

Anthony
0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 7141644
When you define a column, the length you specify specifies the maximum length that column can reach.  For example:

CREATE TABLE anyTable (col1 VARCHAR(50))

col1 cannot exceed 50 characters; SQL will not automatically increase the max length of the column to allow it tho hold more data, it will simply truncate (chop off) the value.



0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 50 total points
ID: 7141647
If needed, you can increase the length of the table by altering the column.  For example:

ALTER TABLE anyTable
    ALTER COLUMN col1 VARCHAR(2000)

would increase the max length of col1 to 2000 characters.
0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 7141649
By the way, if you don't specify a length, it will default to ONE (except in CAST/CONVERT, in which case it defaults to 30).
0
 

Expert Comment

by:CleanupPing
ID: 9280171
Pragam:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now