Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VarChar Length>8000

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
0
0
IN
I want to use a variable in a stored procedure whose length exceeds 8000. If I use

DECLARE
@sql varchar(12000)

an error is generated saying that the max length is 8000. So how do I declare & then use a variable whose length is greater than 8000?

Thanks,

Arpan
 
You cannot declare a variable longer than 8000 characters. You cannot declare local variables of type text or ntext. You can however concantenate variables.

Declare @sql1 varchar(8000), @sql2 varchar(8000)

Exec(@sql1 + @sql2) Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Thanks Terry. I've read that before but glossed right over the fact the BOL says they cannot be used as variables.

Guess the day hasn't been a waste.

Lawrence M.
 
Terry,
Out of curiosity, is there a maximum statement length for select, inserts, etc?
 
According to SQL Setver BOL, the maximum "length of a string containing SQL statements (batch size) is 65,536 * Network packet size" where the network packet size is typically 4k. I've never come close to creating a query or procedure that was that long. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top