????? ????? ?????? ??????? ??? ??????? sp_executesql ?? ??????? ?????? ?? SQL Server

?????? ????????? ?????? ?????????
???? ???????: 262499 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

??????

??? ??????? ????? ?????? ?????? sp_executesql ????? ????? T SQL ???? ????? ???????? ??? ????? ?? ????? ????? T SQL ??????? ???? ????. ???? ???????? ??????? ??????? ?????? T SQL ?? ?????. ??? ???? ?????? ??????? ????? ??? ???? ????? ?? ??????? ???? ?? ??????? ?? ?????? T SQL (??? ????? ?? ??? ?? ??? ??????? ??? ?? ??? SQL Server ??? ??????).

????? ?? ???????????? ???? ????? ????? ?? sp_executesql ?????? ???????:
  • ??? sp_executesql ?????? ??????? ????? ?????? ???? ????? ??? ??????? ?????? ????? ???????? ????????? ??????? ??????? ??????????? ???????.
  • Sp_executesql ????? ????? ???? ???? ??? ?????? ???????? ?????? ???????? ???? ??????? ?????? ??????? ? sp_executesql ???????? ??????? ???? ?? ??????? ?? ??????? ??????.

??????? ????

???? ??????? ??????? ??????? ?????? ??????? ?? sp_executesql.

???? 1
DECLARE @SQLString NVARCHAR(500)
DECLARE @ParmDefinition NVARCHAR(500)
DECLARE @IntVariable INT
DECLARE @Lastlname varchar(30)
SET @SQLString = N'SELECT @LastlnameOUT = max(lname)
                   FROM pubs.dbo.employee WHERE job_lvl = @level'
SET @ParmDefinition = N'@level tinyint,
                        @LastlnameOUT varchar(30) OUTPUT'
SET @IntVariable = 35
EXECUTE sp_executesql
@SQLString,
@ParmDefinition,
@level = @IntVariable,
@LastlnameOUT=@Lastlname OUTPUT
SELECT @Lastlname
				
???? 2
CREATE PROCEDURE Myproc
    @parm varchar(10),
    @parm1OUT varchar(30) OUTPUT,
    @parm2OUT varchar(30) OUTPUT
    AS
      SELECT @parm1OUT='parm 1' + @parm
     SELECT @parm2OUT='parm 2' + @parm
GO
DECLARE @SQLString NVARCHAR(500)
DECLARE @ParmDefinition NVARCHAR(500)
DECLARE @parmIN VARCHAR(10)
DECLARE @parmRET1 VARCHAR(30)
DECLARE @parmRET2 VARCHAR(30)
SET @parmIN=' returned'
SET @SQLString=N'EXEC Myproc @parm,
                             @parm1OUT OUTPUT, @parm2OUT OUTPUT'
SET @ParmDefinition=N'@parm varchar(10),
                      @parm1OUT varchar(30) OUTPUT,
                      @parm2OUT varchar(30) OUTPUT'

EXECUTE sp_executesql
    @SQLString,
    @ParmDefinition,
    @parm=@parmIN,
    @parm1OUT=@parmRET1 OUTPUT,@parm2OUT=@parmRET2 OUTPUT

SELECT @parmRET1 AS "parameter 1", @parmRET2 AS "parameter 2"
go
drop procedure Myproc
				
????? ?? ?????????? ???? "sp_executesql (T-SQL)" ? "???????? sp_executesql" ?? SQL Server ????? Online.For ??? ??????? ??????? ???? "??????? sp_executesql" ?? "??? SQL Server ??? ??????" ? "sp_executesql (T-SQL) ?? ??? SQL Server 7.0" ?? "sp_executesql" ?? ??? SQL Server 2000.

???????

???? ???????: 262499 - ????? ??? ??????: 30/???/1436 - ??????: 5.0
????? ???
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Express Edition
  • Microsoft SQL Server 2005 Workgroup Edition
????? ??????: 
kbsqlsetup kbinfo kbmt KB262499 KbMtar
????? ????
???: ??? ????? ??? ??????? ???????? ????? ?????????? ??????? ?????? ??? ??????? ?? ??? ??????? ?? ??????? ??? ??? ?? ???? ????????? ???? ??????? ???????(CTF) ?? ?? ???? ????? ????. ???? ?? ???? ?????????? ??? ???????? ???????? ???? ??? ?? ???????? ??????? ?? ??? ??????? ???????? ?? ??? ??????? ??????? ??? ?????? ?? ?????? ??? ???? ???????? ???????? ?? ????? ??????? ????? ????? ??????. ??? ?? ???????? ???????? ?? ????? ??? ????? ?? ???????? ?? ???? ????? ?? ?????. ?????? ??? ???? ?????????? ???? ?????? ?? ??? ????? ?? ??? ??? ?? ??????? ?? ??? ????? ?? ???? ????? ????? ?? ????? ??????? ???? ?? ???????? ?? ??? ???????.
???? ??? ????? ??????? ?????? ??????????262499

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com