Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting into Sybase from Excel Spreadsheet

Status
Not open for further replies.

Dudek

Technical User
Jan 14, 2002
27
MY
Hi there..

I was wondering whether it is possible to insert into a table in Sybase from an MS Excel spreadsheet..

basically i have two tables, one in Excel and one in Sybase like below:

Excel_table
account amount
1000 25
1002 77
.....

sybase_table
account address
1000 address1
1002 address2
...
and it goes on... (>1 mill rows for both tables)

what i need to do is to insert into *another* sybase table this select statement:

select a.account, a.amount, b.address
from excel_table as a, sybase_table as b
where a.account = b.account

is this even possible?

Thanks

JD
 
Try this:

1. Create a new table that is based from an excel spreadsheet.

CREATE excel_table (
account char(4) null,
amount int null
)

Then insert data from Excel spreadsheet using INSERT INTO command:

INSERT INTO excel_table
Values (1000, 25)

INSERT INTO excel_table
VALUES (1002, 77)

and so on.... until the end of the spreadsheet.

2. Create a new Sybase table that has the following columns (account, amount, address)
Sample:

CREATE new_table (
account char(4) null,
amount decimal(15,2) null,
address char(50) null
)

3. Use INSERT INTO command again to insert data from two tables into this new table.

Sample:

INSERT INTO new_table
SELECT a.account, a.amount, b.address
FROM excel_table a, sybase_table b
WHERE a.account = b.account

Try this and it should work.

-bRyce ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top