Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1617181920»»

Forum Etiquette: How to post data/code on a forum to get the best help Expand / Collapse
Author
Message
Posted Sunday, July 14, 2013 11:18 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 5:02 PM
Points: 299, Visits: 1,193
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

Post #1473370
Posted Thursday, September 05, 2013 11:03 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Sunday, September 29, 2013 1:24 AM
Points: 429, Visits: 1,721
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!

Post #1491887
Posted Thursday, September 05, 2013 5:30 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:03 PM
Points: 35,956, Visits: 30,244
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." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1492002
Posted Thursday, September 05, 2013 5:36 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:03 PM
Points: 35,956, Visits: 30,244
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." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1492003
Posted Thursday, September 05, 2013 6:01 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 5:02 PM
Points: 299, Visits: 1,193
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.
Post #1492006
Posted Thursday, September 05, 2013 7:29 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:03 PM
Points: 35,956, Visits: 30,244
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." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1492014
Posted Friday, September 06, 2013 7:35 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:44 PM
Points: 11,970, Visits: 10,995
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1492232
Posted Friday, September 06, 2013 7:50 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, March 17, 2014 3:24 PM
Points: 60, Visits: 173
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.
Post #1492247
Posted Friday, September 06, 2013 9:08 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:03 PM
Points: 35,956, Visits: 30,244
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." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1492291
Posted Friday, September 06, 2013 9:09 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:03 PM
Points: 35,956, Visits: 30,244
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." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1492292
« Prev Topic | Next Topic »

Add to briefcase «««1617181920»»

Permissions Expand / Collapse