|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Today @ 11:00 AM
Points: 16,
Visits: 145
|
|
| Yeah, I'm with most others. I find the question more interesting that the solution. Why was it he needed that?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, October 27, 2011 8:03 AM
Points: 5,
Visits: 7
|
|
Have you ever worked up a example to display dynaimc source to destination data column mapppings using the same technique, and also the matching of data items from source column to destination columns, basically a frgament of code that replicates the SSIS data mapper, removing the need to map source to destination in SSIS...?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 7:38 AM
Points: 1,184,
Visits: 3,414
|
|
sanjay.patel 30254 (10/25/2011)
Have you ever worked up a example to display dynaimc source to destination data column mapppings using the same technique, and also the matching of data items from source column to destination columns, basically a frgament of code that replicates the SSIS data mapper, removing the need to map source to destination in SSIS...?  In one of the datamarts I work with, the ordinal position of columns between Dev, QA, and Production are different. What I've done is create a view for each table that gets bulk inserted, and then I reference the view in SSIS or BCP. I've found that to be easier and more maintainable than fooling with the data mapper or bcp format files.
"Winter Is Coming"
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, October 27, 2011 8:03 AM
Points: 5,
Visits: 7
|
|
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.....
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 8:23 PM
Points: 338,
Visits: 443
|
|
thisisfutile (10/25/2011) 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
I agree TOP can't be trusted to pull the first rows in a table, that's why I included the caveat of ORDER BY Ordinal_Position in the filter.
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Wednesday, June 12, 2013 2:10 AM
Points: 535,
Visits: 2,295
|
|
I am intrigued as to why anyone would need this technique in a normalised database. Was this developer wrestling with a pivot table by any chnce that had been saved as a table?
Best wishes,
Phil Factor Simple Talk
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: 2 days ago @ 9:11 PM
Points: 54,
Visits: 923
|
|
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
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 1:41 PM
Points: 33,108,
Visits: 27,032
|
|
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..... 
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 "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."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, October 31, 2011 7:48 AM
Points: 3,
Visits: 78
|
|
| A minor point - the spelling of 'dyanamic'
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 7:38 AM
Points: 1,184,
Visits: 3,414
|
|
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.
"Winter Is Coming"
|
|
|
|