Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
It’s been a while since I post a question here, but I am stuck on one issue. I have over 500 rows and many rows have different locations, so that means the total number of rows are much higher. What I am trying to figure out how to mass update one table using the below data, but with only one location. It does not matter which one.Here is an example raw data.ID | addr1 | City |....5 | 203 N Main | Rochester5 | 574 Church ST | Austin5 | 512 Pocnoc | Lax8 | 4535 Church | Lewistown8 | 3423 Apple | BudaDesired Result ID | addr1 | City |....5 | 203 N Main | Rochester8 | 4535 Church | Lewistown
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2014-06-03 : 12:50:25
What version of SQL are you using? You might be able to make use of the ROW_NUMBER function:
SELECT ID, Addr1, City, ...FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY ID ORDER BY ID) AS RowNum FROM TableName ) AS TempWHERE Temp.RowNum = 1
ugh3012
Yak Posting Veteran
62 Posts
Posted - 2014-06-03 : 13:46:01
Thanks! That helped a lot. I have SQL Server 2008.