Solved

varchar length

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
set default date format in mssql to mm/dd/yyyy 22 69
SQL Query stumper 3 37
SQL Server stored proc 2 13
Sql Query Datatype 2 19
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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 utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now