SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


String length?


String length?

Author
Message
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)

Group: General Forum Members
Points: 144433 Visits: 18651
Awesome Loop.

Great question.

Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Learn Extended Events

Nils Gustav Stråbø
Nils Gustav Stråbø
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6743 Visits: 3575
da-zero (4/12/2010)
A small question:

isn't the variable @InputStr stored somewhere? As the loop goes on forever, at some point in time that variable will become too large to reside in memory/physical location. So some sort of out of memory exception has to take place, right?
SQL Server controls the amount of memory each request gets, and will spill to tempdb if the required memory exceeds the memory your request needs. So, no, you will not run out of memory. I did some testing, and it seems that when a variable exceeds 512KB it will start to use tempdb for storage. I have not found any information that can confirm my tests.

Also, the trailing spaces are removed for nvarchar and varchar data types, so the length of the variable in this specific example will always be six bytes.
KevinC.
KevinC.
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1081 Visits: 504
Awesome question. Thanks. Cool
ColdCoffee
ColdCoffee
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21069 Visits: 5555
Wow... awesome question.. i misread "while" to "If" in the question and was thinking why this one will end up in a loop.. lol..:-D

good loopy question w00t
Ben Leighton
Ben Leighton
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1210 Visits: 359
Surely the only sensible output from running this is: "Query was cancelled by user.";-)
ColdCoffee
ColdCoffee
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21069 Visits: 5555
Ben Leighton (4/13/2010)
Surely the only sensible output from running this is: "Query was cancelled by user.";-)


precisely.. :-D
webrunner
webrunner
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16782 Visits: 4141
Paul White NZ (4/11/2010)
Very clever question - with some well-thought-out wrong answers :-)

First one to whinge about the explanation being 'incomplete' gets a banana w00t :-P

Well done.


Yes, this was a good question, including the possible answers. I need to better understand use of LEN versus DATALENGTH.

- webrunner

-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and says Can I join you?
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Tom Thomson
Tom Thomson
SSC Guru
SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)

Group: General Forum Members
Points: 50686 Visits: 13159
Nice question. Fun.

Tom

Tom Thomson
Tom Thomson
SSC Guru
SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)

Group: General Forum Members
Points: 50686 Visits: 13159
Paul White NZ (4/12/2010)
Christian Buettner-167247 (4/12/2010)
Paul White NZ (4/11/2010)
First one to whinge about the explanation being 'incomplete' gets a banana w00t :-P

Me want the banana *whingingabouttheexplanation*! BigGrin

No results returned, as an infinite loop is invoked. But even if there was no infinite loop, no results would be returned, as the variable is not defined as OUTPUT.


But still, good question & explanation. More of that please!

Excellent, Christian!



Drat Crying, Christian beat me to it! Now there's no point in dreaming up some monkey business with the explanation.

Tom

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