March 10, 2022 at 9:27 pm
I have a table with approx. 1700 rows of data and I need to update the fields based on the csv.
I have exported the fields I need to update to the csv column-a and I have the required updated data in column-b .
e.g.
How can I script this?
C
March 10, 2022 at 9:37 pm
Is this a for real question or a homework assignment?
You could import the data to another table, and join the two on ColumnA from your sheet and show the value from Column B.
March 10, 2022 at 9:44 pm
If I knew how to do it I wouldn't be asking or maybe I'm just posting for the fun of it?
The image is only an example.
Or maybe you could point me to another sql forum for people who have no idea how to use it??
March 11, 2022 at 4:15 pm
Or maybe you could be less rude to someone who replied with a suggestion, despite your post not having much information.
The best answers usually are to posts that clearly explain the problem, have actual data, table definitions, show what you've tried so far and show the error if applicable.
March 11, 2022 at 8:23 pm
If I knew how to do it I wouldn't be asking or maybe I'm just posting for the fun of it?
The image is only an example.
Or maybe you could point me to another sql forum for people who have no idea how to use it??
What part of pietlinden's answer don't you understand?
Step 1, import the data from the spreadsheet into a second table.
Step 2, create and execute a query that will update the data in the first table with the second table.
In SQL Server there is an import / export wizard that is pretty intuitive and easy to use. The instructions on how to use that are in "Help" menu in SQL Server Management Studio.
As for creating the query, is this something you have ever attempted? Do you have any familiarity with the SQL language? If not, there are some very good learning resources on this site that will provide you with a significant understanding.
All of the Stairways can be found here: https://www.sqlservercentral.com/stairways
Since you have only provided an example with your image, we can only provide you with an example. There are not many more specifics we can provide with the limited information we can gather from an image.
Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
March 11, 2022 at 11:49 pm
Okay, let me try that again.
Since you're new... one thing that's extremely helpful to know is in Jeff Moden's article about how to ask a question so that it gets answered. Forum Etiquette: How to post data/code on a forum to get the best help
You say
I have a table with approx. 1700 rows of data and I need to update the fields based on the csv.
I have exported the fields I need to update to the csv column-a and I have the required updated data in column-b .
But we can't see the table with the 1700 rows in it. As such, there's not much concrete help we can offer. That's why I wanted to know about the structure of that table. Likely, it's either a simple inner join in your query, or an update on the original table using that query.
UPDATE tableMissingData
SET emptyColumn = SourceColumn
WHERE tableMissingData.joinKey = Lookuptable.SourceColumnForeignKey
but without real table names and some data, it's harder to give an exact answer.
March 15, 2022 at 12:09 pm
This was removed by the editor as SPAM
March 15, 2022 at 12:10 pm
This was removed by the editor as SPAM
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply