Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stored Procedure returning no results
Message
De
29/05/2012 17:34:15
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01544680
Message ID:
01544704
Vues:
16
>>>>>What is the type of the field? Is it CHAR or varchar? As Boris showed, it doesn't work with char field.
>>>>
>>>>It is nvarchar
>>>
>>>Ok, what is your command which you printed and have you tried executing it?
>>
>>this is what gets printed:
>>
>>
SELECT [dbo].[Receipts].[PolicyHeaderFK],
>>		[ReceiptAmount],
>>		[ReceiptDate],
>>		[ReceiptNumber],
>>		[ReceiptPK],
>>	    [ClientFK],
>>		[PlanFK],
>>		[PolicyNumber],
>>		[PolicyPK],
>>		[Code],
>>		[Description],
>>		[ClientNumber],
>>		[CompanyName],
>>		[FirstName],
>>		[MiddleName],
>>		[LastName]
>>	FROM [dbo].[Receipts]
>>		INNER JOIN [dbo].[Policyheaders] ON [dbo].[Receipts].[PolicyHeaderFK] = [PolicyHeaderPK]
>>		INNER JOIN [dbo].[Policies]	ON [PolicyHeaderPK] = [dbo].[Policies].[PolicyHeaderFK]
>>		INNER JOIN (SELECT [PolicyHeaderFK], MAX(EffectiveDate) as EffectiveDate 
>>						FROM [dbo].[Policies]
>>						GROUP BY [PolicyHeaderFK]) subquery ON [Policies].[PolicyHeaderFk] = subquery.policyHeaderFK AND Policies.EffectiveDate = subquery.EffectiveDate
>>		inner join [dbo].[Plans] on [PlanFK] = [PlanPK]
>>		inner join [dbo].[Clients] on [ClientFK] = [ClientPK] 
>>WHERE 1 = 1
>>   AND ([PolicyNumber] LIKE @PolicyNumber)
>>   AND ([LastName] LIKE @ClientName OR [CompanyName] LIKE @ClientName)
>>   AND [ReceiptNumber] LIKE @ReceiptNumber
>>
>>I added this to the top:
>>
>>
		declare @ReceiptNumber nvarchar(20)
>>		set @ReceiptNumber = NULL
>>		declare @ClientName nvarchar(20)
>>		set @ClientName = NULL
>>		declare @PolicyNumber nvarchar(20)
>>		set @PolicyNumber = 'WLIF20120047'
>>
>>and when I run it I get no records
>
>No wonder. Leave only PolicyNumber condition and re-test. The NULL parameters tests should not be there.

My head is not getting around this. It's been a long day so I'm shutting off for now and will check back tomorrow and see if this makes more sense.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform