SQLSERVER
肥嘟嘟D左卫门
这个作者很懒,什么都没留下…
展开
-
SQLSERVER 简单的游标使用
declare @id intdeclare @name nvarchar(100)--声明游标c_departmentdeclare c_department cursor for select id,name from department--1、打开游标open c_department--2、提取数据fetch next from c_department into @...原创 2018-11-15 15:28:58 · 202 阅读 · 0 评论 -
SQLSERVER 带分隔的字符串与列表相互转换
先自定义一个简单的表(TB01)数据:select TB01.CC from (select '香港' CC union all select '上海' CC union all select '北京' CC) TB01 1、列表某列数据转逗号分隔的字符串(这里的分隔符任意,以英文逗号举例)DECLARE @_text VARCHAR(MAX)SET @_text = STUF...原创 2018-11-15 10:45:50 · 3375 阅读 · 0 评论 -
SQLServer、Oracle、MySql批量更新
SQLServerupdate S_USER set account=p.account from S_PERSON p where p.id=S_USER.person_id;Oracleupdate table_name t1 set (a,b,c)=( select a,b,c from table_name_2 t2 where t1.a=t2.a)2 where exi...原创 2018-12-04 10:19:05 · 436 阅读 · 0 评论 -
SQL SERVER 添加序号列
selectROW_NUMBER() OVER(ORDER BY Convey_Fee desc) as z,rank() OVER(ORDER BY Convey_Fee desc) as z,DENSE_RANK() OVER(ORDER BY Convey_Fee desc) as z,NTILE(4) OVER(ORDER BY Convey_Fee desc) as z,(...转载 2019-07-26 14:58:54 · 4505 阅读 · 0 评论