Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how can i use declare text in sql store procedure


how can i use declare text in sql store procedure

Author
Message
solutionsdxb
solutionsdxb
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 46
Hi ,

I am using a store procedure where i am creating a query dynamic , but query size is increasing the limit of varchar(8000) size , how i can use the data type text in the store procedure to store the created query and then run using the command Exec(@query)

I tried declaring it using the method below :

DECLARE @Query text(16000)

but giving me the error below :

Msg 131, Level 15, State 3, Procedure csplitsubtable_loop, Line 11
The size (16000) given to the type 'text' exceeds the maximum allowed for any data type (8000).
pushpa.kumari
pushpa.kumari
SSC-Enthusiastic
SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)

Group: General Forum Members
Points: 126 Visits: 97
Hi,

text datatype can have maximum length of 8000.
I think you should break your dynamic query into 2-3 parts.
Madhivanan-208264
Madhivanan-208264
SSC-Addicted
SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 Visits: 476
You cannot specify a column width on data type text.



Madhivanan

Failing to plan is Planning to fail
solutionsdxb
solutionsdxb
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 46
nvarchar(max)

solved my purpose , thanks a lot !
Grant Fritchey
Grant Fritchey
SSC-Insane
SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)

Group: General Forum Members
Points: 20970 Visits: 32393
pushpa.kumari (5/6/2009)
Hi,

text datatype can have maximum length of 8000.
I think you should break your dynamic query into 2-3 parts.



Text doesn't actually have a limit that low. Large Objects, LOB or BLOB for the binary large objects, are stored on disk, seperate from the table. However, use of the BLOB types are discouraged in 2005/2008.

The OP found the right answer, using VARCHAR(MAX) is the way to go. If you were working with a binary it would be VARBINARY (MAX).

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search