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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert Excel data in Database SQL SERVER 2005

Author  Topic 

Vassily Zaitsev
Starting Member

13 Posts

Posted - 2012-04-27 : 15:39:52
Hello Guys
I'm new to the forum and i have a doubt.
I have a table created in Excel 2007 and want to update the table through this data in SQL Server 2005 table.
I already have the connection created so missing commands INSERT, UPDATE, and DELETE
I click the button and make the action work
I have a sample table: http://www.sendspace.com/file/mlgbds
Who can help me I thank you very much
a few weeks ago to this information.
Regards to all.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-27 : 15:46:12
use linked server or OPENROWSET

see

http://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-workbench/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Vassily Zaitsev
Starting Member

13 Posts

Posted - 2012-04-27 : 16:00:14
Thanks buddy for the quick response, I look at the link and study hard
you have any examples created with this my need?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-27 : 16:00:46
the link has working code itself.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Vassily Zaitsev
Starting Member

13 Posts

Posted - 2012-04-27 : 16:01:49
thank you friend
Go to Top of Page

Vassily Zaitsev
Starting Member

13 Posts

Posted - 2012-05-04 : 15:40:52
even with the link sent I did not managed to solve my problem
I want to update the worksheet data in a column "A"
two columns are
example:
[A] [B]
1 Maria
Aline 2
3 Alex

I want to update the numbers in column "A"
[A] [B]
55 Maria
56 Aline
57 Alex
this is what I do, just update the data in column "A".
Who can help me thank you.
Go to Top of Page

Vassily Zaitsev
Starting Member

13 Posts

Posted - 2012-05-04 : 15:43:30
in my spreadsheet I have 3 buttons
[INSERT]
[UPDATE]
[DELETE]
Just missing the button UPDATE
I click on UPDATE to update the column and the codes
Go to Top of Page

RL
Starting Member

15 Posts

Posted - 2012-05-04 : 16:51:12
Looks like the UPDATE applies the current value to all rows in the Clientes table. Since the final value is 12, all rows end up with that value.

Your SQL needs a WHERE clause to identify which row to update for each value. Something like this (VBA code may not be 100% correct):


cn.Execute "UPDATE Clientes Set Clientes.Codigo =('" & Worksheets("Plan1").Cells(i, 1).Value & "')
WHERE Clientes.Nome = ('" & Worksheets("Plan1").Cells(i, 2).Value & "')"

Go to Top of Page

Vassily Zaitsev
Starting Member

13 Posts

Posted - 2012-05-04 : 17:12:12
You're the man, you helped me more
tava breaking head two weeks
I am more than eight hours working with VBA and was not able to solve this problem
a big hug my friend.
Thank you.
Go to Top of Page

RL
Starting Member

15 Posts

Posted - 2012-05-04 : 17:21:11
You're welcome, glad I could help! -- RL
Go to Top of Page
   

- Advertisement -