常用的数据库代码
2010-03-26 13:42 贤达 阅读(1681) 评论(0) 编辑 收藏 举报1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <pre class= "brush:sql" ><pre class= "brush:sql" > --挂起业务存储过程 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 </pre> </pre> <pre class= "brush:sql" >利用系统存储过程建立数据库链接</pre> <pre class= "brush:sql" > EXEC sp_addlinkedserver 'lkTest' , '' , 'MSDASQL' , NULL , NULL , 'DRIVER={SQL Server};SERVER=地址;UID=sa;PWD=密码;' go </pre> |
1 2 3 4 5 6 7 8 9 | <pre class= "brush:sql" > --测式数据库语句运行的时间 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 运行时间 </pre> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)