What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

If I enter a code snippet in Stack Overflow, starting with the keyword 'declare' like this (for some TSQL question, etc.):

DECLARE @myVar int
SET @myVar = ...

And then click the Post Your Question button, the page hangs for about 15-30 seconds and then an error page comes up with a picture of a cat that says this isn't my fault, it's Stack Overflow's. This behavior has been consistent.

My work-around is simply to not start the code snippet with 'DECLARE' -- took a while to figure that out though.


EDIT Here are some specific details to help repro:

I had to change 'DECLARE' to 'ECLARE' to below to get this to post.

Although the message is for a connection timeout -- try again later, etc. -- I don't think high traffic / firewall / etc. is the problem, as all I have to do is remove the word DECLARE and it seems to work fine (even in this bug report here)

1) The post I attempted to answer is here: T-SQL String Concatenating multiple rows
2) This is the answer I tried to give:

You could turn this into a function...

DECLARE @PartNumber varchar(6)
DECLARE @ProductCodeCSV as varchar(max)    
SET @PartNumber = '111222'

select @ProductCodeCSV = COALESCE(@ProductCodeCSV + ', ', '') + [product_code]
from table
where [part_number] = @PartNumber

select @ProductCodeCSV 

3) This is the url for the error page: T-SQL String Concatenating multiple rows
4) doesn't seem to matter if it's a code block or not -- will not submit 5) Error from page source:

  • title: The connection was reset
  • short desc: The connection to the server was reset while the page was loading.
  • long desc:
    • The site could be temporarily unavailable or too busy. Try again in a few moments.
    • If you are unable to load any pages, check your computer's network connection.
    • If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
share|improve this question
    
OK -- let me try to get some conditions for it then -- thanks. I did it about 6 times over 2 days earlier this week...I'll see if I can figure out how now... –  kuru kuru na... Aug 4 '11 at 23:28
1  
Next time try grabbing the error message from the source; that might help –  Michael Mrozek Aug 4 '11 at 23:40
    
@Michael -- thanks -- i didn't know that was there. Will do next time. –  kuru kuru na... Aug 4 '11 at 23:43
    
Most likely, the system is rejecting your post because it detected code that was not properly formatted as code. That's why both Siva's answer and your own answer to this question worked. Make sure that you indent the line containing DECLARE with a minimum of 4 spaces, and it will work every time. –  Cody Gray Aug 5 '11 at 5:46
1  
can you provide the actual post text somewhere? –  Jeff Atwood Aug 5 '11 at 7:15
    
@Jeff -- I might have to wait for it to happen again as I can't remember which posts it was now. If/as soon as it happens again, I'll reference the post I was trying to answer, my attempted answer, and also the error message from the source. My sloppy bug report this time... –  kuru kuru na... Aug 5 '11 at 14:00
    
OK -- it happened again (sort of) -- no cat picture, but a page that says the connection was reset. Details above... –  kuru kuru na... Aug 9 '11 at 23:52
    
I just now edited this post, and it passed the tests with no problem. (adding the D, then turning it in to a code block). It failed those same tests earlier today. I'm at a loss. If you have any ideas, I'm happy to help. Otherwise, I probably won't spend much more time on this as I don't know what else I can try. –  kuru kuru na... Aug 10 '11 at 4:35

3 Answers 3

DECLARE @This_is_SQL_Variable NVARCHAR(MAX)
SET @This_is_SQL_Variable = 'Test the issue OP mentioned in his question.'
PRINT 'I don''t see any issue in code starting with DECLARE. Do you?'

I don't see any issue in code starting with DECLARE.

Make sure that you indent the line starting with DECLARE with at least 4 spaces to indicate that it is a block of code. See the markdown formatting page for more information.

UPDATE: Based on OP's newly added information.

Did you try posting like this?

Screen 1

share|improve this answer
    
I tried both ways -- as a code block (by highlighting the code and pressing the curley-brace button in the toolbar), and then as normal text. Also -- in my edited original post -- if you try to edit it by putting the letter 'D' in front of the two 'ECLARE' words, you should be able to get the same connection timeout. –  kuru kuru na... Aug 10 '11 at 4:23

Answering my own question with a 'declare' code snippet:

DECLARE @
WHATEVER

asdf

share|improve this answer
    
well that worked great –  kuru kuru na... Aug 4 '11 at 23:29

Trying again... (copy/paste from the original post as normal text.)

You could turn this into a function...

ECLARE @PartNumber varchar(6) ECLARE @ProductCodeCSV as varchar(max) SET @PartNumber = '111222'

select @ProductCodeCSV = COALESCE(@ProductCodeCSV + ', ', '') + [product_code] from table where [part_number] = @PartNumber

select @ProductCodeCSV

Editing...(adding the D to ECLARE, still normal text.) You could turn this into a function...

DECLARE @PartNumber varchar(6) DECLARE @ProductCodeCSV as varchar(max) SET @PartNumber = '111222'

select @ProductCodeCSV = COALESCE(@ProductCodeCSV + ', ', '') + [product_code] from table where [part_number] = @PartNumber

select @ProductCodeCSV

Editing...(using a code block) You could turn this into a function...

ECLARE @PartNumber varchar(6) ECLARE @ProductCodeCSV as varchar(max)
SET @PartNumber = '111222'

select @ProductCodeCSV = COALESCE(@ProductCodeCSV + ', ', '') + [product_code] from table where [part_number] = @PartNumber

select @ProductCodeCSV 

Editing...(using a code block with D...) You could turn this into a function...

DECLARE @PartNumber varchar(6) DECLARE @ProductCodeCSV as varchar(max)
SET @PartNumber = '111222'

select @ProductCodeCSV = COALESCE(@ProductCodeCSV + ', ', '') + [product_code] from table where [part_number] = @PartNumber

select @ProductCodeCSV 
share|improve this answer
    
all 4 tests passed... –  kuru kuru na... Aug 10 '11 at 4:29
    
if I edit the original post by adding the D, it won't save. But copy/pasting that same text here doesn't give a problem. –  kuru kuru na... Aug 10 '11 at 4:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .