SQL ????? ??? ???????? ????????? ?????? ???????? ????????? ???? ?? ?? ?? sp_executesql ?? ????? ???? ?? ??? ????

???? ?????? ???? ??????
???? ID: 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)" ????? ?? ????? SQL Server ???????? ?????? ??? "?? ????? ???? sp_executesql" ?? "sp_executesql (T-SQL) SQL Server 7.0 ???????? ?????? ???" ?? "sp_executesql" SQL Server 2000 ???????? ?????? ??? "sp_executesql ??? SQL Server ???????? Online.For ???????? ??????? ?? ????? ???? ???"?

???

???? ID: 262499 - ????? ???????: 22 ??????? 2014 - ??????: 3.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 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??: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