Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic SQL question
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00675839
Message ID:
00676248
Views:
22
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform