Forum Etiquette: How to post data/code on a forum to get the best help

  • Just a quick note on sample data generation, (forgive me) without reading all 18 pages of this thread.

    I altered what you posted to run like this, because if there's a NULL value anywhere in your table, you get a whole column of NULLs. I know there's a setting somewhere for altering SSMS behavior when concatenating NULLs (at least in 2k5), but I couldn't find it right off in 2k12.

    SELECT 'SELECT '

    + QUOTENAME(coalesce(ID, ''),'''')+','

    + QUOTENAME(coalesce(DateValue, ''),'''')+','

    + QUOTENAME(coalesce(Value, ''),'''')+','

    + QUOTENAME(coalesce(YearValue, ''),'''')+','

    + QUOTENAME(coalesce(MonthValue, ''),'''')

    + ' UNION ALL'

    FROM yourtable

  • Great article Jeff. Perhaps you could add the point that when inserting code into the "Code" IFCode tags that tabs should be converted to spaces before pasting in the code. A minor point but tabs tend to screw up the formatting. Maybe that's asking too much of posters who won't even try to ask questions in a planned and logical way!

  • Steven Willis (9/5/2013)


    Great article Jeff. Perhaps you could add the point that when inserting code into the "Code" IFCode tags that tabs should be converted to spaces before pasting in the code. A minor point but tabs tend to screw up the formatting. Maybe that's asking too much of posters who won't even try to ask questions in a planned and logical way!

    Good point and thank you for the feedback. I did try to emphasize readability but that's a good enough point to include it separately. Even some of the very well meaning responders post code with tabs in it and it does sometimes make a huge mess.

    This article has been around for quite a while and some excellent suggestions have been made along the way. Perhaps a rewrite is in order. I just need to find the time.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • erikd (7/14/2013)


    Just a quick note on sample data generation, (forgive me) without reading all 18 pages of this thread.

    I altered what you posted to run like this, because if there's a NULL value anywhere in your table, you get a whole column of NULLs. I know there's a setting somewhere for altering SSMS behavior when concatenating NULLs (at least in 2k5), but I couldn't find it right off in 2k12.

    SELECT 'SELECT '

    + QUOTENAME(coalesce(ID, ''),'''')+','

    + QUOTENAME(coalesce(DateValue, ''),'''')+','

    + QUOTENAME(coalesce(Value, ''),'''')+','

    + QUOTENAME(coalesce(YearValue, ''),'''')+','

    + QUOTENAME(coalesce(MonthValue, ''),'''')

    + ' UNION ALL'

    FROM yourtable

    My apologies for missing this. This is a good suggestion. Although I'd hope people would be smart enough to use ISNULL or COALESCE on nullable columns, it many times seems to not be the case.

    Thanks for the feedback, Erik.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (9/5/2013)


    erikd (7/14/2013)


    Just a quick note on sample data generation, (forgive me) without reading all 18 pages of this thread.

    I altered what you posted to run like this, because if there's a NULL value anywhere in your table, you get a whole column of NULLs. I know there's a setting somewhere for altering SSMS behavior when concatenating NULLs (at least in 2k5), but I couldn't find it right off in 2k12.

    SELECT 'SELECT '

    + QUOTENAME(coalesce(ID, ''),'''')+','

    + QUOTENAME(coalesce(DateValue, ''),'''')+','

    + QUOTENAME(coalesce(Value, ''),'''')+','

    + QUOTENAME(coalesce(YearValue, ''),'''')+','

    + QUOTENAME(coalesce(MonthValue, ''),'''')

    + ' UNION ALL'

    FROM yourtable

    My apologies for missing this. This is a good suggestion. Although I'd hope people would be smart enough to use ISNULL or COALESCE on nullable columns, it many times seems to not be the case.

    Thanks for the feedback, Erik.

    No apologies necessary. You are the man when it comes to these three letters.

    I just wouldn't want someone in my (unfortunate) position (before I started reading this website 🙂 ) to run some code to post table data and run screaming from a giant column of NULLs.

  • Based on people's fine suggestions over the last 6 years, there are some things I need to add to this article. Since I'm great as misplacing things, here's the short list of things to add. If any of you can think of other things, please feel free to add them to the list. Keep in mind that the article has to remain short enough so that someone who's got their back against the wall will still have the time to read the important parts.

    These items are posted in the order I've found them by rereading all of the posts on this thread.

    1.Add expected results. Ok to do in a spreadsheet. Just don’t post data in a spreadsheet.

    2.Don’t cross post. It won’t actually get you an answer more quickly. Posting correctly will.

    3.At least try first, if not by code, then by search.

    4.Include possible advice on better construction of the “Subject”… although many people wouldn’t know enough about what they’re asking to add a more appropriate subject.

    5.Keep the problem short. We’re not a free software development house. For example, don’t post 500 lines of code and ask what’s wrong with it or can we speed it up. And don’t ask for how to do something like build an entire inventory system. This very much goes along with “What did you try?”

    6.Tips on using the IFCodes.

    7.Post on the correct forum.

    8.Respondents need to observe the forum, as well. No 2012-only answers on a 2005 forum, please.

    9.How to post XML and other non-TSQL code.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff one other thing that might make an excellent addition to this article is an explanation of how to collect the information. There are many times that people say something like "ok I will post the ddl, but I have no idea how to create it". Often the people looking for help are so green they don't yet have those basic skills and an explanation about how to script the object would be a big boost.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • I go to this thread more than any other. There is not only good information on posting to forums, but I find the techniques in here useful in my day-to-day activities.

  • Sean Lange (9/6/2013)


    Jeff one other thing that might make an excellent addition to this article is an explanation of how to collect the information. There are many times that people say something like "ok I will post the ddl, but I have no idea how to create it". Often the people looking for help are so green they don't yet have those basic skills and an explanation about how to script the object would be a big boost.

    Good idea. I'll also explain how to "edit" that information so that we don't have people posting DDL with 137 columns unless it's absolutely required.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • gitmo (9/6/2013)


    I go to this thread more than any other. There is not only good information on posting to forums, but I find the techniques in here useful in my day-to-day activities.

    Very cool feedback. Thanks, gitmo.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I'm not sure who suggested it or when, but the idea of delivering this article to all new subscribers is great.

    Some of us old dogs have been around the block long enough to read a while and get a feel for the general rules of any new forum before we dive in...but I see an awful lot of newbs who just rapid fire their stuff and then get all huffy when referred to the proper way to ask for help.

  • Hi... How do I attach a screenshot in my question? When I clicked on image---> but how do I insert there? I dont want to make attachment.

  • dallas13 (3/24/2015)


    Hi... How do I attach a screenshot in my question? When I clicked on image---> but how do I insert there? I dont want to make attachment.

    When you click on image it assumes it is an image on the internet somewhere. An easy way around this is to upload an attachment. Then when you are done posting you can right click the attachment to get the URL and edit your post with the image URL. A bit of a hack but it is what most of us do around here. 😉

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • dallas13 (3/24/2015)


    Hi... How do I attach a screenshot in my question? When I clicked on image---> but how do I insert there? I dont want to make attachment.

    At the next section down (Post Options), you have to do the "Edit Attachments" thing where you upload your graphic. Once you've done the upload, it will appear as an attachment. If you want it to appear in your post, right click on the attachment and select [Properties]. Copy and paste the URL of the attachment in between the IMG IFCode Shortcuts.

    You could refer to a different URL not on SSC but if that URL ever goes away, so will the image on SSC so I don't recommend that method.

    {edit} Posted at the same time Sean did above so apologies for any duplicate information.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (3/24/2015)


    dallas13 (3/24/2015)


    Hi... How do I attach a screenshot in my question? When I clicked on image---> but how do I insert there? I dont want to make attachment.

    At the next section down (Post Options), you have to do the "Edit Attachments" thing where you upload your graphic. Once you've done the upload, it will appear as an attachment. If you want it to appear in your post, right click on the attachment and select [Properties]. Copy and paste the URL of the attachment in between the IMG IFCode Shortcuts.

    You could refer to a different URL not on SSC but if that URL ever goes away, so will the image on SSC so I don't recommend that method.

    {edit} Posted at the same time Sean did above so apologies for any duplicate information.

    But that is a really cool image...WAY better than my boring old plain text explanation. 😛

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 15 posts - 181 through 195 (of 212 total)

You must be logged in to reply to this topic. Login to reply