October 25, 2011 at 1:02 pm
I'm not going to judge the merits of the problem. But I am going to point out a small but important thing that I see crop up frequently:
'[' + COLUMN_NAME + ']'
isn't a whole lot better than just COLUMN_NAME - what if they have a ']' in a column name ?
QUOTENAME(COLUMN_NAME,'[')
is much better
October 25, 2011 at 6:22 pm
sanjay.patel 30254 (10/25/2011)
What I would like to see is a source to destination dynamic data mapper, which is all referenced by using the dynaim columns as in the exmaple you have used, only extended to to also reference a second table, which agin the ordinal positions are sorted to relfect the data mapping, and then having further SQL conditions tagged on to allow a filter to be put in place.I want two tables, ordinal position to relfect the data mapping sequence, the source and destination columns and condition blocks may exist in either table, a dynamic process to put it all together, just the SQL part, don't want to execute it.....:-P
Actually, this article gave you enough information to easily write your own. When you're done, you should write an article about it. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
October 26, 2011 at 6:50 am
A minor point - the spelling of 'dyanamic'
October 26, 2011 at 7:06 am
I think the article presents a good enough solution to a specific problem. If I ever have a need to select the TOP X columns from a table, then it would be an ad-hoc query I need right then and there, and I'd rather use someone elses code than waste time rolling my own solution. Obviously it's something that wouldn't belong in the application.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
October 27, 2011 at 7:44 am
My question is rather why do you want the top 10 columns rather then how
November 2, 2011 at 11:00 am
This just smacks of laziness on the developers part, to go to google and look up the API of their language's SQL Data Reader object. Pretty much every DB API allows you to select things based on column ordinal. C# will even allow you to get the name of the column back.
Time for clue-bat application 😉
Viewing 6 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply