Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic SQL question
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00675839
Message ID:
00676248
Vues:
23
>Any idea as to what I'm doing wrong here?

You don't need to use Dynamic SQL to parameterize a predicate in the WHERE clause.
CREATE PROCEDURE  up_CountRecordsforBranch
                  @BranchID             varchar(3),
    	          @TotalCount           int output
AS

SET NOCOUNT ON

DECLARE  @CurrentCount  int

Set  @CurrentCount = 0

set @CurrentCount = (select count(*) from GLDetails where CUBranchVC = @branchID)
set @Totalount = @TotalCount + @CurrentCount

set @CurrentCount = (select count(*) from TransactionDetails where CUBranchVC = @BranchID)
set @TotalCount = @TotalCount + @CurrentCount
	
GO
-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform