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
 Import and Export Data (32-bit) Wizard

Author  Topic 

1STROUNDKO
Starting Member

2 Posts

Posted - 2012-04-27 : 09:20:01
Hi,

I want to import an excel file to sql server 2008 using the wizard.

I can import and use the sql query to limit collumn import

select HO_ID
from `all$`

But before I import also I want to update HO_ID from 1 to 2

select HO_ID
from `all$`

SET HO_ID = 1
WHERE HO_ID = 2

I am getting syntax errors

As a newbie I would very much appreciate your help

Regard

1st Round KO

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-04-27 : 09:30:26
If you want to change a value, you shouldm't be using SELECT.
The proper command would be UPDATE.

UPDATE [all$] SET HO_ID = 1 WHERE HO_ID = 2



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

1STROUNDKO
Starting Member

2 Posts

Posted - 2012-04-27 : 09:38:19
quote:
Originally posted by SwePeso

If you want to change a value, you shouldm't be using SELECT.
The proper command would be UPDATE.

UPDATE [all$] SET HO_ID = 1 WHERE HO_ID = 2



N 56°04'39.26"
E 12°55'05.63"




Thanks but what is the complete code to just import the HO_ID collumn and make the change from 1 to 2

1st Round KO
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-04-27 : 13:07:19
INSERT dbo.TargetTable (HO_ID)
SELECT 1 AS HO_ID FROM dbo.SourceTable WHERE HO_ID = 2



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-04-27 : 15:16:14
SELECT CASE WHEN HO_ID = 2 THEN 1 ELSE HO_ID END AS HO_ID FROM [all$]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -