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.
| 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 importselect HO_IDfrom `all$`But before I import also I want to update HO_ID from 1 to 2select HO_IDfrom `all$`SET HO_ID = 1WHERE HO_ID = 2I am getting syntax errorsAs a newbie I would very much appreciate your helpRegard1st 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" |
 |
|
|
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 21st Round KO |
 |
|
|
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" |
 |
|
|
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" |
 |
|
|
|
|
|