| Author |
Topic |
|
kdjonesmtb
Starting Member
3 Posts |
Posted - 2012-06-01 : 11:11:39
|
| I wanted to do something like this but sql does not like the syntaxcase when datasource ='QNXT' theninto #QNXT_Source_dataI can just clone the code multiple times but it seems redundantThanks--QNXT table creation--drop table #QNXT_Source_dataSELECT nationalproviderid,providerid,datasource,providername,NameLast,NameFirst,NameMiddle,NameSuffix,FederalTaxId,Gender,BirthDate,Ethnicity,Languages,ProviderType,MailingAddress1,MailingCity,MailingState,MailingZipCode,MailingCounty,PhysicalAddress1,PhysicalCity,PhysicalState,PhysicalZipCode,Phone,PrimarySpecialty,CLIANumber,DEANumber,StateOfMassachusettsLicensecase when datasource ='QNXT' theninto #QNXT_Source_dataFROM DW.DBO.PROVIDERDEMOGRAPHICS PDWHERE NationalProviderId in(SELECT nationalproviderid--FROM ----(SELECT count(*) as countof,nationalproviderid FROM DW.DBO.PROVIDERDEMOGRAPHICS PD WHERE NationalProviderId <> '')Keith David Jones Senior Business Analyst |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-06-01 : 11:14:57
|
| Can you describe what you are trying to do in words? Is that a conditional insert? If so, you could use dynamic sql or you'll have to break it into two separate statements: SELECT and INSERT. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-01 : 11:58:04
|
quote: Originally posted by kdjonesmtb I wanted to do something like this but sql does not like the syntaxcase when datasource ='QNXT' theninto #QNXT_Source_dataI can just clone the code multiple times but it seems redundantThanks--QNXT table creation--drop table #QNXT_Source_dataSELECT nationalproviderid,providerid,datasource,providername,NameLast,NameFirst,NameMiddle,NameSuffix,FederalTaxId,Gender,BirthDate,Ethnicity,Languages,ProviderType,MailingAddress1,MailingCity,MailingState,MailingZipCode,MailingCounty,PhysicalAddress1,PhysicalCity,PhysicalState,PhysicalZipCode,Phone,PrimarySpecialty,CLIANumber,DEANumber,StateOfMassachusettsLicensecase when datasource ='QNXT' theninto #QNXT_Source_dataFROM DW.DBO.PROVIDERDEMOGRAPHICS PDWHERE NationalProviderId in(SELECT nationalproviderid--FROM ----(SELECT count(*) as countof,nationalproviderid FROM DW.DBO.PROVIDERDEMOGRAPHICS PD WHERE NationalProviderId <> '')Keith David Jones Senior Business Analyst
Case is not a conditional statement using which you can manipulate sequence flow of execution but its just an expression which returns value of field conditionallyI think what you may be looking would be IF..ELSE statement but again for that you need separate SELECT statements------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|