• 发现一个Exec执行执行存储过程的问题


     Set @SqlstrGetCount = 'SELECT  @TotalRowsCount = COUNT(*) FROM EventLog where '
     
    DECLARE @ParameterDefinition Nvarchar(4000)
     
    SET @ParameterDefinition = ' 
           @TotalRowsCount  int ,
           @EventLogType tinyint,
           @Category nvarchar(20),
           @UserName nvarchar(20),
           @BeginTime dateTime,
           @EndTime dateTime
    '
     
    EXEC  sp_executesql @SqlstrGetCount@ParameterDefinition ,@TotalRowsCount ,@EventLogType,@Category,@UserName,@BeginTime,@EndTime

      发现 
    @TotalRowsCount 始终为0 ,百思不得其解,后来只好换为:

     
    Set @SqlstrGetCount = 'SELECT  COUNT(*) as TotalRowsCount  FROM EventLog where '
     
    DECLARE @ParameterDefinition Nvarchar(4000)
     
    SET @ParameterDefinition = ' 
         @EventLogType tinyint,
         @Category nvarchar(20),
         @UserName nvarchar(20),
         @BeginTime dateTime,
         @EndTime dateTime
    '
     
    EXEC  sp_executesql @SqlstrGetCount@ParameterDefinition ,@EventLogType,@Category,@UserName,@BeginTime,@EndTime

    在MS SQL中,写函数时,参数一定不要忘了给范围大小,上次遇到这个问题查了我好久啊!~不知道其它数据库会不会也这样!

  • 相关阅读:
    [BUUCTF]REVERSE——rsa
    windows下python3.7安装gmpy2、Crypto 库及rsa
    [BUUCTF]PWN——wustctf2020_getshell1/2
    [BUUCTF]PWN——bbys_tu_2016
    [BUUCTF]PWN——xdctf2015_pwn200
    [BUUCTF]REVERSE——[GXYCTF2019]luck_guy
    [BUUCTF]REVERSE——简单注册器
    [BUUCTF]PWN——pwnable_orw
    [BUUCTF]REVERSE——findit
    [BUUCTF]PWN——jarvisoj_level1
  • 原文地址:https://www.cnblogs.com/xiaowy/p/476753.html
Copyright © 2020-2023  润新知