| Author |
Topic |
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 17:08:45
|
| I'm importing a text field that is called advertiserTYPE. It will be one of four options in the parenthesis below:advertiserTYPE (FSBO,BROKER,DEVELOPER,REALTOR) VarChar(50)I need to be able to construct a statement that says something like:If advertiserTYPE = FSBOThen INSERT INTO [COLUMN1]If advertiserTYPE = BROKERThen INSERT INTO [COLUMN2If advertiserTYPE = DEVELOPERThen INSERT INTO [COLUMN3]Am I on the right track?? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-23 : 17:09:58
|
| Well you insert into a table not a column. So what values are you going to put for the other columns in the table?Tara Kizeraka tduggan |
 |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 17:22:08
|
| Ok This is what I have:-- Table BrokerType that I'm inserting intoINSERT INTO [DB1].[dbo].[BROKERTYPE]([IsFSBO], [FSBOName], [FSBOContact], [FSBOEmail], [FSBOWebsite], [FSBOLogo],[IsBroker], [BrokerageName], [BrokerageWebsite], [BrokerName], [BrokerImage], [BrokerContact], [BrokerLicence], [SalesPerLicense], [BDListingType], [BrokerageRelation], [BrokerCommission], [AppointmentNec], [IsDeveloper], [DeveloperName], [DeveloperContactName], [DeveloperContact], [DeveloperWebsite], [DeveloperImage], [isComplete])-- I'm getting a text file thats going to say something likeadvertisertype (FSBO or Broker or Developer or Realtor) varchar(50)I need to put the type of advertiser for each record in text file into the appropriate column that I listed above. Does this help clarify? :) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-23 : 17:26:35
|
| Providing a few rows of the file plus what the table should look like after the import (using those few rows) would help.Tara Kizeraka tduggan |
 |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 17:30:30
|
| I don't know what the table will look like after, b/c I havent done anything yet, and to be honest I dont have the text file yet either. I'm in the conceptual stages. I believe I need to use CASE expressions. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 17:43:27
|
| I don't need to normalize any data though b/c I'm not creating anything. I just need to insert records based on different criteria. I'm still researching case expressions. |
 |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 18:13:27
|
| Should look something like this but it's not working:SELECT * = CASE WHEN (SELECT [isFSBO],[FSBO) WHERE [IsFSBO = 1] THEN 'FSBO' END SELECT * = CASE WHEN (SELECT [isFSBO]) WHERE [IsFSBO = 1] THEN 'Realtor' SELECT * = CASE WHEN (SELECT [isFSBO]) WHERE [IsFSBO = 1] THEN 'Developer'FROM dbo.BrokerDeveloper |
 |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 18:27:28
|
| I've cleaned it up a bit but still getting an error:SELECT * = CASE WHEN (SELECT [IsFSBO]) WHERE IsFSBO = 1 THEN 'FSBO' CASE WHEN (SELECT [isBroker]) WHERE [IsBroker = 1] THEN 'Broker' ELSE 'Developer' END FROM dbo.BrokerDeveloper |
 |
|
|
|