随笔分类 -  sql server

摘要:use my_temp CREATE VIEW V_temp --创建视图 AS SELECT * FROM A select *from V_temp 阅读全文
posted @ 2019-09-26 16:11 enych 阅读(154) 评论(0) 推荐(0)
摘要:select col from [dbo].[GetInPara]('101,102,103',',') USE [xxx] GO /****** Object: UserDefinedFunction [dbo].[GetInPara] Script Date: 2019/9/26 11:06:28 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFI 阅读全文
posted @ 2019-09-26 11:07 enych 阅读(1000) 评论(0) 推荐(0)
摘要:SELECT LEN('SQL Server LEN') length, LEN('SQL Server LEN ') length_with_trailing_blanks; SELECT (CASE WHEN LEN('')=0 THEN '001' ELSE '1线' END) --执行001 SELECT (CASE WHEN LEN('1线')=0 THEN '001' ELSE '1线 阅读全文
posted @ 2019-09-26 10:41 enych 阅读(740) 评论(0) 推荐(0)
摘要:-*-分页查询 SELECT * FROM ( SELECT temp.*, ROWNUM RN FROM (SELECT * FROM 表名) temp ) WHERE RN BETWEEN 1 AND 2 -*-* 连表查询 select count(*) as 总次数 from T_HANDL 阅读全文
posted @ 2019-01-03 10:16 enych 阅读(615) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2018-12-24 15:21 enych 阅读(6) 评论(0) 推荐(0)
摘要:经发现, 数据库中保存时间格式数据 可以正常 排序, 数据中保存时间格式字符串 排序出现问题 /// <summary> /// 修改时间 /// </summary> public DateTime ModifyTime { get; set; } public string ModifyTime 阅读全文
posted @ 2018-12-13 14:05 enych 阅读(2021) 评论(0) 推荐(0)
摘要:select * from [LPicture] UPDATE [dbo].[LPicture] SET [picGroup] = '3213' WHERE LPictureid in(1,2); select * from LPicture where LPictureid not in ('') select * from LPicture where LPictureid n... 阅读全文
posted @ 2018-12-13 09:43 enych 阅读(1488) 评论(0) 推荐(0)
摘要:以上代码测试均失败, 最后, 直接删除表主键 阅读全文
posted @ 2018-12-01 15:31 enych 阅读(3022) 评论(0) 推荐(0)
摘要:Select A,B,C from Tb1 –查询所有 Select A,replace(B,’1’,’壹’),C from Tb1 替换查询 Tb1 A B C AA1 1 CC AA2 2 CC AA3 3 CC 有什么方法 同时 把1替换为壹 把 2替换贰,把3替换叁 阅读全文
posted @ 2018-08-11 10:59 enych 阅读(5048) 评论(0) 推荐(0)
摘要:sql的 where in 删除 要更改为 // in( ) 阅读全文
posted @ 2018-08-10 12:02 enych 阅读(320) 评论(0) 推荐(0)
摘要:select * from GropBy where [date] BETWEEN '2010-10' and '2015-10' --从字符串转换日期和/或时间时,转换失败。 select * from GropBy where [date] between '2017-07-25 00:00:00' and '2017-07-25 24:00:00' --从字符串转换日期和/或时间时... 阅读全文
posted @ 2018-06-29 17:31 enych 阅读(454) 评论(0) 推荐(0)
摘要:select 名称, COUNT(名称) as 数量之和from 信息group by all 名称 阅读全文
posted @ 2018-06-29 17:25 enych 阅读(631) 评论(0) 推荐(0)
摘要:select * from sysobjects --查询所有信息 SELECT Name FROM Master..SysDatabases ORDER BY Name --查询所有数据库名字 SELECT name FROM sysobjects WHERE xtype='U' --查询数据库表(先引用数据库[use]) select * from sys.tables --查询数据库... 阅读全文
posted @ 2018-04-12 11:55 enych 阅读(187) 评论(0) 推荐(0)
摘要:select COUNT(*) from ( select ID,H1 AS Value from Table_1 union all select ID,H2 from Table_1 union all select ID,H3 from Table_1 union all select ID,H4 from Table_1 union all... 阅读全文
posted @ 2018-03-08 16:43 enych 阅读(1726) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-03-07 14:42 enych 阅读(450) 评论(0) 推荐(0)
摘要:select @PageSize * from tets SELECT 在WHERE 之前都不能参数化. TOP 只能做字符串运行. 阅读全文
posted @ 2018-03-07 09:08 enych 阅读(493) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-01-27 14:29 enych 阅读(129) 评论(0) 推荐(0)
摘要:ALTER TABLE tab1 add id int identity primary key (注意:必须加identity,否则添加会失败) //导入excel时候 先把主键去掉 变为可为空,之后导入数据, 之后在额外添加主键 alter table tab1 drop column aaa; 删除列 阅读全文
posted @ 2018-01-22 14:58 enych 阅读(181) 评论(0) 推荐(0)
摘要:select top 10 * from ComprehensiveShow where id not in(select top 40 id from ComprehensiveShow order by id) 意思是查询前40条数据,在查询不在前40条数据中的前10条数据 //select t 阅读全文
posted @ 2018-01-13 16:58 enych 阅读(202) 评论(0) 推荐(0)
摘要:use test select isnull(max(CCC),0)+1 from [tab] --返回表中指定列名中有多少条数据 select count(0) from (select * from tab) as dhs_table --统计表中的行数 insert into Areas() values () ;select @@IDENTITY --用select @@iden... 阅读全文
posted @ 2018-01-12 16:17 enych 阅读(135) 评论(0) 推荐(0)