摘要: 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 阅读(9159) 评论(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 阅读(11937) 评论(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 阅读(12210) 评论(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 阅读(813) 评论(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 阅读(5003) 评论(0) 推荐(0) 编辑
摘要: --执行如下语句select * from sysobjects where type ='tr' order by name 阅读全文
posted @ 2019-07-24 14:14 Bill-Lee 阅读(7098) 评论(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) 编辑
摘要: --查询表名与表备注select ROW_NUMBER() OVER (ORDER BY a.object_id) AS No, a.name AS TabelName, g.[value] AS TableNotesfrom sys.tables a left join sys.extended_ 阅读全文
posted @ 2019-07-24 13:26 Bill-Lee 阅读(2685) 评论(0) 推荐(0) 编辑
摘要: SELECTDATEDIFF( Second, '2009-8-25 12:15:12', '2009-9-1 7:18:20') --返回相差秒数SELECTDATEDIFF( Minute, '2009-9-1 6:15:12', '2009-9-1 7:18:20') --返回相差分钟数SEL 阅读全文
posted @ 2019-07-24 11:39 Bill-Lee 阅读(24256) 评论(0) 推荐(1) 编辑
摘要: 语句及查询结果: Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AMSelect CONVERT(varchar(100), GETDATE(), 1): 05/16/06Select CONVERT(varchar(100) 阅读全文
posted @ 2019-07-24 11:32 Bill-Lee 阅读(6755) 评论(0) 推荐(0) 编辑