From: Uri Dimant on
CREATE PROCEDURE usp_main
@param1 nvarchar(128),
@param2 varchar(10)
AS
EXEC general_select @tblname =@param1,@key =@param2

--Usage
EXEC usp_main @param1 ='TBL',@param2 ='BLABLA

'




"GW" <GW(a)discussions.microsoft.com> wrote in message
news:EBCB1789-67FE-4937-AAF1-22AF8A20523E(a)microsoft.com...
> how to call the following sp from another SP?
>
> CREATE PROCEDURE general_select @tblname nvarchar(128),
> @key varchar(10),
> @debug bit = 0 AS
> DECLARE @sql nvarchar(4000)
> SET @sql = 'SELECT col1, col2, col3
> FROM dbo.' + quotename(@tblname) + '
> WHERE keycol = @key'
> IF @debug = 1 PRINT @sql
> EXEC sp_executesql @sql, N'@key varchar(10)', @key = @key
>
> Help is much appreciated. thank you.


 | 
Pages: 1
Prev: scripting an object
Next: Trigger question