开发者

Comparing with SQL

I need to compare the values of one excel column开发者_如何学Python with the column in the sql database table. How will i do this?


One way would be to import the Excel values into a temporary SQL Server table (e.g. using the Import Data wizard in SQL Server) and then use one of the several good SQL data compare tools like Red-Gate SQL Data Compare or ApexSQL SQL Data Diff to compare the two tables in SQL Server.


The solution from marc_s is the preferential option, as you can then perform SQL queries on the data, including WHERE NOT IN.

Another way is to do a SELECT * from the table (make sure your Management Studio is set to show enough rows), copy/paste this into Excel next to your existing data, then sort both columns in Excel the same way.

Then if you expect them to be pretty close and are just looking for a couple of mismatches, add a comparison equation to a third column (=A1=B1 or =EXACT(A1,B1) if you want case-sensitivity) dragging this equation down for all rows. Of course this is going to be 'off' after the first wrong one, meaning you either shift the rows down from the other column at this point to compensate after each error (leaving a "blank" entry in one of the columns for this row), or simply grab a diff tool as mentioned below.

If you expect them to diverge significantly or already have a tool handy, a comparison/diff tool like BeyondCompare, instead of the comparison column, would make this comparison operation easiest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜