For beginners, this is one of the toughest jobs, Here is an example, hope this will help u guys :)
Use Northwind
CREATE PROC TEST(
@DATABASENAME VARCHAR(30),
@COUNTOUT INT OUTPUT
)
AS
BEGIN
DECLARE @v_SQL nVARCHAR(4000)
DECLARE @COUNT INT
SET @V_SQL='SELECT @COUNT=COUNT(*) FROM '+@DATABASENAME+'..Authors'
EXEC SP_EXECUTESQL @V_SQL,N'@COUNT INT OUTPUT',@COUNT OUTPUT
SET @COUNTOUT=@COUNT
RETURN @countout
END
0 komentar:
Posting Komentar