版权声明:本文为CSDN博主「暮雪寒寒」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明.原文链接:https://blog.csdn.net/qq_27628011/article/details/89319710 MERGE tABatch AS t -- 需要操作的主体表 USING( ) AS waitTotal FROM ( SELECT batchNo FROM OPENJSON(@checkJson) ) '$.batchNo') ) t GRO
在写sql的查询时 如下: select * from Users where username='WangE' select * from Users where username='wange' 上面两条查询语句的结果是一样的,这说明username的条件并没有区分大小写. 若要使用上面的的语句能够执行按区分大小写查询 需要在查询的结尾加上 collate Chinese_PRC_CS_AI_WS 完整语句是: select * from Users where username='Wang
--查询当天: select * from info where DateDiff(dd,datetime,getdate())=0 --查询24小时内的: select * from info where DateDiff(hh,datetime,getDate())<=24 --本月记录 SELECT * FROM 表 WHERE datediff(month,[dateadd],getdate())=0 --本周记录 SELECT * FROM 表 WHERE
create table #ttt(id int,name nvarchar(10));merge into #ttt t using (select 1 as id ,'eee' as name ) b on (t.id = b.id) when matched then update set t.name = b.name when not matched then insert(id,name) values(b.id,b.name); select * from #ttt; merge
-- ╔════════╗ -- =============================== ║ if语句使用示例 ║ -- ╚════════╝ declare @a int set @a=12 if @a>100 begin print @a end else begin print 'no' end -- ╔══════════╗ -- =============================== ║ while语句使用示例 ║ -- ╚══════════╝declare @i i
查询出所有未写说明的字段: SELECT IC.table_name TableName, ColName=C.name, PFD.[value] FROM sys.columns C INNER JOIN sys.objects O ON C.[object_id]=O.[object_id] AND O.type='U' AND O.is_ms_shipped=0 inner join information_schema.columns IC on ic.COLUMN_NAME = c.n
merge集插入,更新,删除于一体,如果要对一个表同时进行插入,更新,删除2个或3三个操作.效率要高于单个操作. merge into tableb b --被操作表using (select id,servicepromotor,servicecmclient from tablea where servicepromotor>0) a--参照表 支持子查询on a.id=b.client --关联关系when matched --a,b表均匹配到做updatethen update set
USE [CDM] GO /****** Object: Trigger [dbo].[UpdateAkisFlight] Script Date: 2018/6/14 16:43:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[UpdateAkisFlight] ON [dbo].[FlightWarnTime] FOR INSERT,DELETE AS BEGIN from de
create function fun_getPY(@str nvarchar(4000)) returns nvarchar(4000) as begin declare @word nchar(1),@PY nvarchar(4000) set @PY=''while len(@str)>0 begin set @word=left(@str,1) --如果非汉字字符,返回原字符 set @PY=@PY+(case when unicode(@word) between 19968 and