Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Having on calculated field
Message
 
 
À
15/07/2011 10:21:43
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01518229
Message ID:
01518236
Vues:
40
>>>But I get a syntax error:
>>>
>>>Msg 207, Level 16, State 1, Line 9
>>>Invalid column name 'statusfk'.
>>>
>>>How can I refer to the statusfk field?
>>
>>You have one extra )
>
>Where? I see two opening and two closing.
>
>FWIW, I got this to work:
>
>
select 1 
>	from ClaimItems inner join Claims on cit_clmfk = clm_pk
>	where dbo.claimitemstatus(clm_forwarded
>				,cit_received
>				,(select com_overduedays
>				from companies
>					inner join Clients on cli_comfk = com_pk
>					inner join Claims subclaims on clm_clifk = cli_pk
>				where subclaims.clm_pk = claims.clm_pk)) = 3
Change this to:
select 1 
	from ClaimItems inner join Claims on cit_clmfk = clm_pk
	where dbo.claimitemstatus(clm_forwarded
				,cit_received
				,(select SUM(com_overduedays)
				from companies
					inner join Clients on cli_comfk = com_pk
					inner join Claims subclaims on clm_clifk = cli_pk
				where subclaims.clm_pk = claims.clm_pk)) = 3
This will help avoiding subquery returned more than 1 record error in a future.

I still think using SCALAR function this way is not good for performance.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform