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!)
XML PATH
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.)CAST(POSTED_DATE as char)
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.