?
Solved

varchar length

Posted on 2002-07-09
6
Medium Priority
?
656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Scott Pletcher
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:
Scott Pletcher earned 200 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:Scott Pletcher
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

762 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