zoukankan      html  css  js  c++  java
  • 常用的数据库代码

    --挂起业务存储过程
    create procedure [dbo].[p_suspend_business] 
       @Bfixednum  varchar(40)
    as
    begin transaction
    
      declare @SNumber int
      declare @messageNumber int
      select @SNumber=SNumber from sendnumber where Bfixednum=@Bfixednum
      select @messageNumber = count(@Bfixednum) from [message] where Bfixednum = @Bfixednum and mDate between (select  dateadd(dd,-day(getdate())+1,getdate()))  and   (select  dateadd(dd,-day(getdate()),dateadd(m,1,getdate())))
    
    
      --参数检查
      if (@SNumber is null or @messageNumber = '')
        begin
          raiserror('错误!缺少参数 ,请检查!',16,1)
          rollback
          return
        end
      
      if (@messageNumber >= @SNumber)
        begin
         update dbo.Business set BState=0 where  Bfixednum=@Bfixednum
       commit transaction    
        end
    
    GO
    
    
    
    
    利用系统存储过程建立数据库链接
    EXEC sp_addlinkedserver 
       'lkTest', 
       '', 
       'MSDASQL',
       NULL,
       NULL,
       'DRIVER={SQL Server};SERVER=地址;UID=sa;PWD=密码;'
     go
    
    --测式数据库语句运行的时间
    declare @starttime as datetime;
    declare @endtime as datetime;
    set @starttime = getdate(); 
    --运行的语句  
    select * from dbo.total where  companyinfo like '%中南一路%'
    set @endtime = getdate();select @starttime as 开始时间,@endtime as 结束时间,datediff(MS,@starttime,@endtime)as 运行时间
    
    
  • 相关阅读:
    对象属性键值[key]属性问题
    理解 JavaScript 中的 for…of 循环
    vue初学篇----过滤器(filters)
    CSS变量
    SCSS !default默认变量
    vue 集成 NEditor 富文本
    如何在Github上面精准搜索开源项目?
    OSS介绍
    键盘各键对应的编码值(key code)
    网易云音乐歌单生成外链播放器
  • 原文地址:https://www.cnblogs.com/and/p/1696930.html
Copyright © 2011-2022 走看看