摘要: 我的 SeqNo 从1到20,可是超过了SQLServer的默认排序这样的1101112...19234567如何才能让排序成为这样1234567891011.. . 解决办法:因为 SeqNo 是 VARCHAR 字符串类型,要按数字大小排序需要将它转换为 INT 类型 select * from 阅读全文
posted @ 2019-08-08 15:13 Bill-Lee 阅读(1764) 评论(0) 推荐(0) 编辑
摘要: 1、round()遵循四舍五入把原值转化为指定小数位数。如:round(1.45,0) = 1;round(1.55,0)=22、floor()向下舍入为指定小数位数.如:floor(1.45,0)= 1;floor(1.55,0) = 13、ceiling()向上舍入为指定小数位数.如:ceili 阅读全文
posted @ 2019-07-24 16:31 Bill-Lee 阅读(9136) 评论(0) 推荐(0) 编辑
摘要: 表sales 查询结果如下: 1、建表 CREATE TABLE [dbo].[sales]( [id] [int] IDENTITY(1,1) NOT NULL, [year] [int] NULL, [jidu] [int] NULL, [jine] [int] NULL, PRIMARY KE 阅读全文
posted @ 2019-07-24 16:25 Bill-Lee 阅读(11928) 评论(0) 推荐(0) 编辑
摘要: -- 当月第一天select dateadd(month, datediff(month, 0, getdate()), 0) -- 当月最后一天(思路:下月的第一天减去一天)select dateadd(month, datediff(month, 0, dateadd(month, 1, get 阅读全文
posted @ 2019-07-24 15:00 Bill-Lee 阅读(12169) 评论(0) 推荐(0) 编辑
摘要: --查询以下时间段内分别有几月--时间段:'2019-1-1'到'2019-7-24'select number as wknum from master..spt_valueswhere type='p' AND number>=datepart(mm,'2019-1-1') and number 阅读全文
posted @ 2019-07-24 14:58 Bill-Lee 阅读(2230) 评论(0) 推荐(0) 编辑
摘要: --1、新建函数(排除周未) CREATE FUNCTION [dbo].[getCnt](@begintime DATETIME,@endtime DATETIME)RETURNS @tab TABLE(cnt int)AS BEGIN DECLARE @cnt INT SET @cnt=0 -- 阅读全文
posted @ 2019-07-24 14:56 Bill-Lee 阅读(808) 评论(0) 推荐(0) 编辑
摘要: --游标更改数据--申明一个游标DECLARE MyCursor CURSOR FOR select SN,CT from TEMP1 --循环条件 --打开一个游标 OPEN MyCursor --循环一个游标DECLARE @SN VARCHAR(50) ,@CT VARCHAR(50) --循 阅读全文
posted @ 2019-07-24 14:19 Bill-Lee 阅读(1729) 评论(0) 推荐(0) 编辑
摘要: --执行如下语句select object_name(B.referenced_object_id),a.name as 约束名,object_name(b.parent_object_id) as 外键表,d.name as 外键列,object_name(b.referenced_object_ 阅读全文
posted @ 2019-07-24 14:15 Bill-Lee 阅读(4998) 评论(0) 推荐(0) 编辑
摘要: --执行如下语句select * from sysobjects where type ='tr' order by name 阅读全文
posted @ 2019-07-24 14:14 Bill-Lee 阅读(7097) 评论(0) 推荐(0) 编辑
摘要: --执行如下调语句 exec sp_configure 'show advanced options', '1'; goreconfigure;goexec sp_configure 'clr enabled', '1'goreconfigure;exec sp_configure 'show ad 阅读全文
posted @ 2019-07-24 14:12 Bill-Lee 阅读(304) 评论(0) 推荐(0) 编辑