like查询效率低下,网上搜了一下替代like查询的方法,都是说用charindex方法,自己对比了一下查询速度test1表中有一千两百多万条数据,我只给ID加了索引先看一下 '%我%'这种模糊查询:declare @q datetime set @q = getdate() select ID,U_Name,U_Sex,U_Age,U_Address from test1 where U_Nam
--计算并返回两个日期间的工作小时数(工作日*8)按周一到周五计算 --必须先SET DATEFIRST 1 CREATE FUNCTION dbo.CalcWorkHours(@bdate DATETIME, @edate DATETIME) RETURNS INTEGER AS BEGIN DECLARE @hours INTEGER IF @@DATEFIRST <> 1
select name,type_desc from sys.all_sql_modules s inner join sys.all_objects o on s.object_id=o.object_id where definition like '%关键字%' order by type_desc,name
根据表名和条件,生成Insert语句
SqlServer 工作日计算
Select 'itemModel.'+ name+'=item.'+name+';' from syscolumns Where ID=OBJECT_ID('表名')
数据库优化
MD5加密
慢Sql查询
--被锁住的表select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableNamefrom sys.dm_tran_locks where resource_type='OBJECT'--解锁 declare @spid int Set @spid = 104 --锁表
Sqlserver 脚本备份数据库
日志收缩
Sql Server 增加字段、修改字段、修改类型、修改默认值
循环遍历表
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号