摘要: 使用order by排序,有时候不是根据字符或数字顺序,而是根据实际要求排序。 例如有客户A,B,C,我希望排序结果是B,C,A,那么就要通过自定义的规则排序。 第一种方法,可以构造一张映射表,将客户映射到所需要的顺序。 第二种方法,如果要排序的客户不多,可以直接写出,那就使用如下方法: order 阅读全文
posted @ 2016-08-29 09:51 萧紫紫 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 在mysql中,筛选非空的时候经常会用到is not null和!=null,这两种方法单从字面上来看感觉是差不多的,其实如果去运行一下试试的话差别会很大!为什么会出现这种情况呢?null 表示什么也不是, 不能=、>、< … 所有的判断,结果都是false,所有只能用 is null进行判断。默认 阅读全文
posted @ 2016-08-29 09:50 萧紫紫 阅读(10873) 评论(0) 推荐(2) 编辑
摘要: declare @id1 int,@id2 int,@id3 int,@id4 int declare @sickcode varchar(20),@sfrq datetime ,@count int,@str varchar(200) select @sickcode = sickcode,@sfrq =sfrq from tablenamewhere objid=@objid select ... 阅读全文
posted @ 2016-08-29 09:47 萧紫紫 阅读(607) 评论(0) 推荐(0) 编辑
摘要: 数据库中字段类型对应C#中的数据类型: 数据库 C#程序 int int32 text string bigint int64 binary System.Byte[] bit Boolean char string datetime System.Dat... 阅读全文
posted @ 2016-08-29 09:42 萧紫紫 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 帮助文档中的信息 Without century (yy) With century (yyyy) Standard Input/Output** - 0 or 100 (*) Default mon dd yyyy hh:miAM (or PM) 1 101 USA mm/dd/yy 2 102 阅读全文
posted @ 2016-08-29 09:41 萧紫紫 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 显示 包括选择的这条,在加上 选择年度的此人 最近的 3条。(最多显示4条) 1.@count>4 记录数大于4条 2.@count4 begin select top 4 * from temp where name=@name and YEAR (rq)= YEAR(@rq) order by abs(datediff(day,sfrq,@sfrq)) asc end el... 阅读全文
posted @ 2016-08-29 09:38 萧紫紫 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 操作列 删列: alter table tablename drop column columnname; 加列: alter table Medical_institution add Hospital_Level int not null default(1) 改列长度/类型 alter table tableName alter column columnName varchar(400... 阅读全文
posted @ 2016-08-29 09:30 萧紫紫 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 临时表是不存在表SYSOBJECTS中的, if exists ( object_id('Tempdb..#temp') ) 也不行,因为无论是否存在表#temp都会返回一行的,所以这个条件永远成立 应该用 if ( object_id('Tempdb..#temp') is not null) DROP TABLE #temp GO 阅读全文
posted @ 2016-08-29 09:29 萧紫紫 阅读(136) 评论(0) 推荐(0) 编辑
摘要: create function test (@lb varchar(20)) returns @temp table (lieming varchar(20),xianshi varchar(20),tablename varchar(20)) as begin declare @lieming varchar(20),@xianshi varchar(20),@tablename va... 阅读全文
posted @ 2016-08-29 09:27 萧紫紫 阅读(185) 评论(0) 推荐(0) 编辑
摘要: Sql :cast(sum(colname) as varchar) 或者 convert(varchar,sum(colname)) convert(varchar(50),sum(colname)) 阅读全文
posted @ 2016-08-29 09:26 萧紫紫 阅读(511) 评论(0) 推荐(0) 编辑