excel 2007 duplication in table - excel-2007

how i compare records in a table , to make sure its record is not duplicates. using excel 2007
i don't wan't them to delete after comparison.

Iif cells, A2, A3 and so on have the data then in B2 put
=IF(AND(ISNA(VLOOKUP(A8,A9:$A$10000,1,FALSE)),ISNA(VLOOKUP(A8,$A$1:A7,1,FALSE))),"unique","duplicate")
and copy down

Related

Picking column names from an excel sheet in sql server while writing a macro

I am writing a macro for automating some task where i need to pick column names from an excel sheet , use that columns in select statement in sql and then fetch the values for those columns from database table. is there any way through which i can acheive this.
e.g.
in my DB there is a table employee having column names as - empname,empadd,empcontact ,empsal,dep,branch,location and 50 more columns.
my excel sheet is having 3 column names empname,empadd,laction.
now i want my code to pick only those 3 columns which are in excel and fetch the values from employee database.
i.e. select empname,empadd, location from employee;
i tried multiple things but no luck.
it would be great if anyone can suggest some way. thanks

Merging Columns

I have data from column 'D' to 'N' that I want to merge into one column without losing the data. I have tried this using the 'Merge Cells' option in the Home tab but then it discards all my data.
Is this possible to do in VBA?
Functions are of no use to me by the way.
Insert column after N if not already blank
Enter formula =CONCATENATE(D1,E1,F1,G1,H1,I1,J1,K1,L1,M1,N1) in O1
Fill down
highlight column O and copy
right click column O and select select paste special then values
Delete columns D-N O is now your merged column and after delete is in Col D.
Assumption here are:
there is no other data in D:O that you care about.
having one column with all data is acceptable, you don't need the outer cells to remain independant.

Replacing a value in an Excel column, based on its value in another sheet

I have a exported Excel sheet from SQL with records for insurance policies held by vendors that visit our office. There are two separate tables that identify the Insurer and the Vendor by a code. The table with the records of all the policies just has the codes for both of them.
Is there a formula that can look at another sheet for a value, and pull in another column from that sheet? Basically there is a key code for each vendor, and I need to replace that code with their actual name from another excel sheet.
Or if there is a simpler way to do this in SQL I could try that too.
In SQL you can JOIN the tables together:
SELECT i.col1,i.col2,v.col1
FROM Insurer i
JOIN Vendor v
ON i.key_code = v.key_code
Adjusting which columns you return as needed, without sample data it's unclear if there needs to be additional criteria in the JOIN.
In Excel you can use VLOOUKUP(), but I prefer INDEX() and MATCH(), below would try to match the value in B1 to a value on Sheet2 in B1:B20, and return the value from the corresponding row from Sheet2 A1:A20:
=INDEX(Sheet2!$A$1:$A$20,MATCH(B1,Sheet2!$B$1:$B$20,0))
There are numerous illustrated examples of either excel method that will be easy to follow.

Compare column names in excel sheet with column names in a table in SQL

I have an excel sheet a large number of columns (~500) and a DB table with similar number of columns. I can run SQL queries on the database. What I want to achieve is to find the columns that are in my DB table but not in the spreadsheet. Checking it manually seems really inefficient.
Have you thought of using ODBC functionality within excel? You should be able to open up the table in excel then use count formulas to ensure that the numbers match.
You may try next semi-manual approach:
select top 1 * from [your table]
In SSMS right click to query results and select "Copy with headers"
Paste special->Transpose into Excel (pivot rows to columns)
Select headers in the existing excel, copy them, paste special-> transpose beside previous
Sort and compare columns

select into a table with different column names

In SQL, Select into ... copies rows into a different (backup) table. Is this possible if the backup table has different structure (or different column names)? If not, what is the best way to achieve this?
Here is what I want to do: TableA has columns a1,a2,a3. I want to copy some rows from this table to another table TableB which has column b1,b2,b3,b4. Content of a1 to go into b1, a2 to b2 etc.
The column names do not matter at all, as long as data types match (or can be cast in the assignment).
If the data types of the columns don't match, try casting the values accordingly. Just try with small dummy tables. Be sure to list the target columns explicitly to avoid confusion. Like this:
INSERT INTO TableB (b1, b2, b3)
SELECT a1, a2, a3
FROM TableA
WHERE <some condition>;
More details in the SQLite manual here.