Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sp_executesql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-09 : 23:59:44
Paul writes "The Syntax for sp_executesql:

'##############################################################
sp_executesql [@stmt =] stmt
[
{, [@params =] N'@parameter_name data_type [,...n]' }
{, [@param1 =] 'value1' [,...n] }
]
'##############################################################

'--------------------------------------------------------
Whats wrong with the sproc below?? (SQL Server 7)

CREATE PROCEDURE [p_solo]

@depId as int,
@fabId as int

AS

declare @SQLstring Nvarchar(500)
declare @para_1 Nvarchar(50)
declare @para_2 Nvarchar(50)

SET @SQLstring = N'SELECT TOP 2 * FROM solo WHERE depId=@dp AND fabId=@fb'

set @para_1 = N'@dp as int'
set @para_2 = N'@fb as int'

EXECUTE sp_executesql @SQLstring, @para_1, @para_2, dp=@depId, @fb=@fabId"
   

- Advertisement -