3

I just attempted to post a sql query to SO. Upon attempting to post it, I got an extremely unhelpful error, "An error occurred submitting the question". I know it's something to do with the query, as I tried submitting without it, and of course that submitted fine, too bad for me (given that in the 8 seconds between submitting the post and deleting it, someone downvoted me for not including the query, durp. At least rep gets added back a couple minutes later if you delete your question, I also just learned...)

Of course I can't submit the query in this question here, either, with the same error, so as was requested in this question, I'm attaching it externally (this is not a dup, due to the fact that the guy in that question didn't actually post his code on request, so it couldn't be reproduced).

edit: apparently, as was discovered, you can't submit it, but you can edit it in. This is indeed the same query I couldn't submit originally:

Declare @result VARCHAR(8000)

SELECT @result = ''

SELECT @result += temp.temp
FROM
(
  SELECT DISTINCT ('Posted Date' + CAST(POSTED_DATE as char) + ',') as temp
  FROM [LACDC].[dbo].[PS_CDC_JRNL_LSR_VW]
  where JOURNAL_ID = @ID and JOURNAL_DATE = @Date
) AS temp 

So, first question, is this a bug? I'm guessing it is, but correlarily, if there are characters or sequences of characters that I actually am not allowed to put in a question, could the specifics of that requirement at least be made more obvious? I do see a couple other posts on meta.SO with that same error, but one says the answer is don't submit questions more than 30,000 characters (my question was about 1,000) and was then marked as a dup of another one that says errors should be more obvious, as they're currently tucked away in a corner ("right of the textbox, blended in with the Careers 2.0 ad." - I don't see either of those things.)

(Also amusingly, in the time between when I tried unsuccessfully to post that to SO, and now, I figured out the issue with the query on my own, so thanks SO for being a good teddy bear!)

23
  • I was able to edit your question and include the query (the edit is in the edit queue though). – Stijn Nov 25 '13 at 16:34
  • @Stijn Weird, I definitely reproduced not being able to add it here. Maybe editing goes through a different code path than creating a new question? I admittedly didn't try that. – neminem Nov 25 '13 at 16:36
  • @Stijn not really relevant, Meta got no quality filters. – Shadow The Vaccinated Wizard Nov 25 '13 at 16:38
  • @ShaWizDowArd OP did mention he also tried to include the query in this meta question. – Stijn Nov 25 '13 at 16:39
  • @Stijn oh, missed that. So maybe we're dealing with browser plugin breaking things - it won't be the first time. – Shadow The Vaccinated Wizard Nov 25 '13 at 16:41
  • @neminem what browser you use exactly? Can you try and disable all extensions/plugins/add-ons of the browser to see if it helps? – Shadow The Vaccinated Wizard Nov 25 '13 at 16:42
  • @ShaWizDowArd Conveniently, I checked (using the formatting sandbox), and I couldn't post the same post as an answer, either, with an equivalent error ("an error occurred submitting the answer"). I'm running FF26.0, and it certainly has a bunch of plugins, but I just tried posting it the same place on a very stock Chrome install (31.0.1650.57 m), and got the same error. – neminem Nov 25 '13 at 16:47
  • Off topic to your question here but that approach to string concatenation in SQL Server is not guaranteed and prone to breaking if the execution plan changes. Better to use XML PATH – Martin Smith Nov 25 '13 at 16:53
  • @MartinSmith Indeed offtopic, since the original question I was trying to post made it quite clear that I was working in an extremely legacy system (sql2000, we have no control over it), or none of this would have been necessary. (The original question being, "why does that query work in sql2008 but not in sql2000", and the answer was, "because sql2000 didn't even support the += operator".) The original query back in the beginning did use XML Path, which of course, is also not supported, we discovered the first time we deployed. :( – neminem Nov 25 '13 at 16:59
  • (As a different, off-topic and completely pedantic aside, don't ever declare/define variable types like char without length in T-SQL. This has nothing to do with version, like the other problems you've encountered, but it will bite you later if you continue to use it. Another piece of advice is to not develop on a later version than the one you're deploying to.) – Aaron Bertrand Nov 25 '13 at 17:03
  • @AaronBertrand The first, where am I doing that? I'm not an expert at all, but I only see one declare, and it's declared as the max for sql2000, 8000 characters? To the second, yes, I would like that very much, I've been asking for a VM with sql2000 on it, but we don't have one. (We don't have any direct access to this particular client's system, we can only give them sessions and have them run them.) – neminem Nov 25 '13 at 17:14
  • @neminem CAST(POSTED_DATE as char) – Aaron Bertrand Nov 25 '13 at 17:15
  • @AaronBertrand Huh, that counts? I really would have assumed that if you CAST, it would give you a string the size of the item you just casted, since it would know what size that is by that point. It doesn't!? That is craziness, but if so, also good to know. (And yes, this is totally off topic.) – neminem Nov 25 '13 at 17:16
  • 1
    @neminem try SELECT CAST('1234567890 1234567890 1234567890' AS CHAR); - or just read the link. In some cases it defaults to 1, in others 30; in both cases it can silently truncate, so you don't even know you've lost data. – Aaron Bertrand Nov 25 '13 at 17:18
  • 1
    @neminem If I remember correctly, another user had a similar user, and it was caused by a proxy/firewall that rejected POST bodies it deemed potentially dangerous. Maybe try from a different network connection. That wouldn't explain why an edit works though. – Joshua Dwire Nov 25 '13 at 19:10

Browse other questions tagged .