Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Concantenating Problem In Query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Concantenating Problem In Query
Divers
Thread ID:
01460836
Message ID:
01460836
Vues:
105
I'm trying to determine the next customer code using a 3 digit customer code. If you pass in "ABC", and there are already 3 rows for
customer ABC, then you should get bacl 'ABC-004'. Here's what I have:
CREATE PROCEDURE ap_GetNextProjectNoForClient
	@CustomerCode	VARCHAR(03),
	@NewCustCode	VARCHAR(07) OUTPUT
	
AS
BEGIN
	
	DECLARE @Count INT

	SELECT @Count = COUNT(CustomerCode)
		FROM COSProjects
		WHERE CustomerCode =  @CustomerCode

	SET @NewCustCode = @CustomerCode + '-' + dbo.PADL(@Count, 3, '0')
I'm calling it like this:
DECLARE @Code VARCHAR(3)
EXEC ap_GetNextProjectNoForClient 'MCD', @Code OUTPUT
SELECT @Code
All I'm getting back is the @CustomerCode value.

If I put this at the end, it works:
SELECT @CustomerCode + '-' + dbo.PADL(@Count, 3, '0')
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform