摘要: --删除数据库表数据 慎用 create PROCEDURE sp_DeleteAllData AS declare @tblName nvarchar(50) declare @sNOCHECKCONSTRAINT nvarchar(500) declare @sDISABLETRIGGER nvarchar(500) declare @sDeleteTable nvar... 阅读全文
posted @ 2019-09-06 16:42 丶愤怒的蘑菇 阅读(1859) 评论(0) 推荐(0) 编辑
摘要: --删除重复数据,无标识列情况 if object_id(N'test',N'U') is not null drop table test go create table test( id INT, n NVARCHAR(20) ) go INSERT INTO test VALUES (1,'a 阅读全文
posted @ 2019-09-06 16:23 丶愤怒的蘑菇 阅读(878) 评论(0) 推荐(0) 编辑
摘要: 方法1:缺点,不去重,不去空;见表1 表1: 方法2:通过游标来处理,去重,去空。见表2 表2: 阅读全文
posted @ 2019-09-06 15:11 丶愤怒的蘑菇 阅读(799) 评论(1) 推荐(0) 编辑
摘要: #原表 #直接拼接 #去重,但未去空 #去重且去空 阅读全文
posted @ 2019-09-06 14:29 丶愤怒的蘑菇 阅读(1881) 评论(0) 推荐(0) 编辑
摘要: --根据索引idx值获取格式串中第idx个值 如数据'11,12,13,14,15,16' 方法:格式串+分隔符;@str='11,12,13,14,15,16'+',' select dbo.GetStrByindex('11,12,13,14,15,16,', ',', 3); -- 13 cr 阅读全文
posted @ 2019-09-06 13:46 丶愤怒的蘑菇 阅读(445) 评论(0) 推荐(0) 编辑
摘要: if (exists (select * from sys.objects where name = 'up_test')) drop proc up_testgoCreate PROC [dbo].[up_test]as declare @SQL nvarchar(max), @SQL1 nvar 阅读全文
posted @ 2019-09-06 11:56 丶愤怒的蘑菇 阅读(614) 评论(0) 推荐(0) 编辑
摘要: --MSSql 保留两位小数的用法1: round(@sum,2),2: Convert(decimal(18,2),@sum) select round(9,2) --9 是想要的效果select round(9.1248,2) --9.1200 不是想要的效果 select Convert(de 阅读全文
posted @ 2019-09-06 10:23 丶愤怒的蘑菇 阅读(2813) 评论(0) 推荐(0) 编辑