|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 8:23 PM
Points: 338,
Visits: 443
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Tuesday, January 15, 2013 11:11 AM
Points: 1,945,
Visits: 2,782
|
|
Why did you encourage him? Sounds like time for re-education
Books in Celko Series for Morgan-Kaufmann Publishing Analytics and OLAP in SQL Data and Databases: Concepts in Practice Data, Measurements and Standards in SQL SQL for Smarties SQL Programming Style SQL Puzzles and Answers Thinking in Sets Trees and Hierarchies in SQL
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 2:04 AM
Points: 1,968,
Visits: 1,819
|
|
CELKO (10/24/2011)
Why did you encourage him? Sounds like time for re-education  I agree.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, May 09, 2013 5:58 AM
Points: 184,
Visits: 360
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 6:37 AM
Points: 6,
Visits: 78
|
|
if was just a means to an end then just do a SELECT * FROM and dont bother with the schema extract. Cringe, really bad a * but so.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 12:01 PM
Points: 2,677,
Visits: 2,273
|
|
| What was the answer to the question 'why?'?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, October 27, 2011 8:03 AM
Points: 5,
Visits: 7
|
|
Excellent, removes the need for Cursors, and is very flexible to build up a totally dynamic Select clause that is very very useful indeed...
More like this please.....
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, April 29, 2013 9:23 AM
Points: 3,
Visits: 42
|
|
For select dthe columns without remove last comma
SELECT TOP 10 @columnName = COALESCE(@columnName + ',' + QUOTENAME(COLUMN_NAME), QUOTENAME(COLUMN_NAME)) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @tableName AND TABLE_SCHEMA = 'DBO' ORDER BY ORDINAL_POSITION ASC
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: 2 days ago @ 9:15 AM
Points: 56,
Visits: 487
|
|
I've been coming to these forums long enough to know that Joe Celko was going to respond to this one. I recall Joe discussing the TOP clause in another forum long ago. Correct me if I'm wrong Joe, but TOP isn't to be trusted to pull the "first rows in a table" because tables don't store rows in any particular order. Is that what you were going for in your re-education reprimand? I've always felt it was a little misleading...it should have been called LIMIT or something like that because that's all it's really doing...limiting the result set.
IMHO.
Gabe
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 5:03 AM
Points: 1,162,
Visits: 3,328
|
|
CELKO (10/24/2011)
Why did you encourage him? Sounds like time for re-education  On a slow day, even the best of us may become so distracted by the challenge of solving some small puzzle that we forget to probe into why the puzzle was there to begin with.
"Wise people understand the 10,000 things without going to each one. They know them without having to look at each one, and they transform all without acting on each one." - The Tao Te Ching: Verse 47
|
|
|
|