Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-12-07 : 09:30:01
|
| Babloo writes "Hi,I need to declare a dynamic size of a varchar datatype in a stored procedure. some thing like this...select @size=(select count(*) from emp) * 20declare @name varchar(@size)...How do i do this?Actually my requirement is to select all the UserID for a given message ID (It should come as 1 row ';' seperated...)Table cols,MessageID intUserID intCC bit ...I have written a cursor for that. But I have problems in giving the size for the data used for storing the concatinated value...plz help me in this problemregds,babloo" |
|
|
shankarc
Starting Member
37 Posts |
Posted - 2001-12-07 : 09:44:34
|
| Varchar itself allocates memory depending on the value stored. If you know what would be the maximum size of the data that you want to store then you can declare the variable as varchar of that size.say for e.g., if at the max, your var is going to hold 1000 chars, then declare varchar(1000). If you are going to store only 10 chars then 10 bytes will be allocated in the memory. |
 |
|
|
|
|
|