|
i have a data in microsoft excel which always come columns and the columns are many (like 50 columns or more) which i need to update a particular column in the database table. which script can i used to accomplished this task to update this column in my table? and the destination table looks like this: This data is much, and it comes very often, how can i achieved this.
(comments are locked)
|
And the useful bit You haven't really said what SQL Server version you're on - this is 2005+ Just for Thomas - here's the dynamic version. Note that it has to be in a real table for access to the meta-data. Doesn't this depend upon the Maji's records always having those fields and only those fields? Sorry - I'm feeling a bit hyper-critical today!
Jul 27 '10 at 01:31 PM
ThomasRushton ♦
@ThomasRushton - Not 'only those fields', no - any additional fields would be ignored. If the fields are variable, then that's a reasonably simple bit of Dynamic SQL, then bob's your mother's brother.
Jul 27 '10 at 01:39 PM
Matt Whitfield ♦♦
@Matt - ah, right. Thanks for the clarification. "reasonably simple" - I like that.
Jul 27 '10 at 01:51 PM
ThomasRushton ♦
@ThomasRushton - there you go, edited - reasonably simple :)
Jul 27 '10 at 01:59 PM
Matt Whitfield ♦♦
@Matt: :-)
Jul 27 '10 at 02:02 PM
ThomasRushton ♦
(comments are locked)
|
|
I would use Excel to format the data in the right way as it allows for a range of data to be copied and pasted transposed (use Paste Special from right click options). Once the data is fixed then there are loads of ways to import it, OPENROWSET, using linked server, bcp, LogParser and so on. I guess the details behind "much" and "often" will dictate the best option to use.
(comments are locked)
|
|
please, can someone show me how to attach sample data for clearer understanding of the source data and the destination table structure. @Maji - I don't think you can. Also, please use comments rather than adding an answer to your own question...
Jul 29 '10 at 02:07 PM
Matt Whitfield ♦♦
@Maji - tricky. You can post a simplified schema & a few rows of sample data into your question, or, for bigger problems, I guess you're looking at some sort of free hosting. Google Documents, perhaps. And then posting a link to your document in the question.
Jul 29 '10 at 02:19 PM
ThomasRushton ♦
(comments are locked)
|

