4

I get the error message below while posting an answer-

enter image description here

Not sure if this is the correct place to post this question.

Update: I was able to post the answer fine when I removed 15 lines of text. Is there a char limit for answers?

EDIT: Here is the part of answer that was causing the issue. I still cannot add that text to this question. So attaching an image of the code Code that was causing the issue

Update: Copied code from srutzky's answer below and pasted it and it worked.

CREATE TRIGGER [TR_CaptureDBChanges] ON DATABASE
FOR CREATE_PROCEDURE, ALTER_PROCEDURE,DROP_PROCEDURE,
CREATE_TABLE, ALTER_TABLE,DROP_TABLE,CREATE_TRIGGER,
ALTER_TRIGGER,DROP_TRIGGER,CREATE_VIEW,ALTER_VIEW,
DROP_VIEW, CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION
AS
BEGIN DECLARE @ed XML SET @ed = EVENTDATA() 
DECLARE @ip VARCHAR(32) = (SELECT client_net_address
FROM sys.dm_exec_connections WHERE session_id = @@SPID);
INSERT INTO DBChangesLogs
            ( EventDate,DBName)VALUES(GetDate(),
            @ed.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(256)'))
END
7
  • 2
    There may be a char limit, but if this is the answer in question, then you were far from reaching it, even counting the removed 15 lines. People have posted much larger answers. So the issue was probably not the size.
    – Andriy M
    Commented Nov 10, 2015 at 7:17
  • Yes, that was the answer. I wrote larger answers than that one and never saw the error message..
    – sql_handle
    Commented Nov 10, 2015 at 21:24
  • 1
    @PaulWhite I tried to add the code that was causing the issue, but it shows 'An error occurred submitting the edit'. I took a screenshot and updated the question.
    – sql_handle
    Commented Nov 14, 2015 at 7:13
  • 1
    How did you get that text that won't work? Did you copy from the displayed / rendered text of the Question, or did you go to "edit" and copy and paste the "raw" text? I will assume that you didn't re-type it all ;-) But I am wondering if there is a "hidden" character in there that isn't appreciated. I suppose pasting it into Notepad (not Notepad++) and then re-copying and pasting into here would eliminate any hidden characters if they were in there. Commented Nov 18, 2015 at 0:28
  • 1
    @srutzky +1 that's a valid point, but I did try to paste it in notepad and then into the answer that failed as well. I did not type the code, that's from the question itself. All I did was add a 'AS' before the BEGIN.
    – sql_handle
    Commented Nov 18, 2015 at 0:32
  • Interesting that Notepad didn't "cleanse" it as it seems to kill anything interesting ;-). But, did you copy the rendered or raw text? I want to try to reproduce this and want to make sure that I do the exact same thing. Commented Nov 18, 2015 at 0:34
  • @srutzky I copied the code directly from the question. Not sure how the OP was able to post the same code.
    – sql_handle
    Commented Nov 18, 2015 at 3:48

2 Answers 2

3

So just to test this, I went to the question ( DDL trigger permission Error ) and copied the text in the rendered code block (not the "raw" text from clicking on "edit", just to be clear), and will paste it below and add the word "AS":

CREATE TRIGGER [TR_CaptureDBChanges] ON DATABASE
FOR CREATE_PROCEDURE, ALTER_PROCEDURE,DROP_PROCEDURE,
CREATE_TABLE, ALTER_TABLE,DROP_TABLE,CREATE_TRIGGER,
ALTER_TRIGGER,DROP_TRIGGER,CREATE_VIEW,ALTER_VIEW,
DROP_VIEW, CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION
AS
BEGIN DECLARE @ed XML SET @ed = EVENTDATA() 
DECLARE @ip VARCHAR(32) = (SELECT client_net_address
FROM sys.dm_exec_connections WHERE session_id = @@SPID);
INSERT INTO DBChangesLogs
            ( EventDate,DBName)VALUES(GetDate(),
            @ed.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(256)'))
END

Tests:

  1. Simple copy and paste worked. Next will try apply "code" formatting.
  2. Simple addition of code formatting worked. Next will format same as image in this Question.
  3. Formatting the same as shown in the image in the Question seems to work. Next test needs to be the O.P. attempting to copy and paste the code I have above into this Question, since that did not work before.
2
  • 1
    +1 I just copied the code from your answer and pasted it in my question and it seemed to work without error.
    – sql_handle
    Commented Nov 22, 2015 at 19:52
  • @sql_handle Not sure what happened then. Can you reproduce it by copying from the original question again and paste into your question here or even an answer here? Just to see if it happens again? Commented Nov 22, 2015 at 20:14
2

I've occasionally had issues posting code that includes certain terms - for example, CREATE TABLE. In my case, I believe this was being blocked by a content filter at my place of employment - I was able to post the code successfully from home.

It's possible you encountered something similar.

You must log in to answer this question.

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