Solved

varchar length

Posted on 2002-07-09
6
650 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: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 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: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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Count with a subquery showing details 10 42
string fuctions 4 25
Linked Server Issue with SQL2012 3 24
How to search for strings inside db views 4 25
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

776 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