摘要: var mydate = new Date(); mydate.getYear(); //获取当前年份(2位) mydate.getFullYear(); //获取完整的年份(4位,1970-????) mydate.getMonth(); //获取当前月份(0-11,0代表1月) mydate.getDate(); //获取当前日(1-31) mydate.getDay(); //获取当前星期... 阅读全文
posted @ 2016-08-29 10:09 萧紫紫 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2016-08-29 10:02 萧紫紫 阅读(173) 评论(0) 推荐(0) 编辑
摘要: alter proc ljgl_cp_yzzx @usetag int ,@ids varchar(1000) as begin begin tran tr1 select * into #temp from fn_split(@ids,',') update cp_advice set usetag=@usetag where [objid] in (select * from... 阅读全文
posted @ 2016-08-29 09:57 萧紫紫 阅读(356) 评论(0) 推荐(0) 编辑
摘要: select * from ( select isnull(c.type,'其他') type,d from ( select ID,Record_code,code,day(thedate) d from search_record ... 阅读全文
posted @ 2016-08-29 09:55 萧紫紫 阅读(130) 评论(0) 推荐(0) 编辑
摘要: -主键用随机数难以保证唯一,在生成主键上要多做校验工作 --处理示例 --创建一个视图,生成编号 create view v_getNo as select No=convert(char(6),getdate(),12) +replace(convert(varchar(12),getdate(),14),':','') +right(newid(),6) go --创建一个函数,目的是... 阅读全文
posted @ 2016-08-29 09:52 萧紫紫 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 使用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 萧紫紫 阅读(10866) 评论(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 萧紫紫 阅读(606) 评论(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 萧紫紫 阅读(510) 评论(0) 推荐(0) 编辑
摘要: Update是T-sql中再简单不过的语句了,update table set column=expression [where condition],我们都会用到。但update的用法不仅于此,真正在开发的时候,灵活恰当地使用update可以达到事半功倍的效果。 假定有表Table1(a,b,c) 阅读全文
posted @ 2016-08-29 09:24 萧紫紫 阅读(6912) 评论(0) 推荐(0) 编辑
摘要: Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少。但我们在开发、测试过程中,经常会遇到需要表复制的情况,如将一个table1的数据的部分字段复制到table2中,或者将整个table1复制到table2中,这时候我们就要使用SELECT INTO ... 阅读全文
posted @ 2016-08-29 09:23 萧紫紫 阅读(7607) 评论(0) 推荐(0) 编辑
摘要: 程序 exec heduling_date_select ' Name like @%a%@ or phone like @%a%@ or Cus_code like @%a%@ or objjc like @%a%@ or Doctor like @%a%@' 存储过程 set @where = replace(@where,'@',char(39)) 或者 用两... 阅读全文
posted @ 2016-08-29 09:21 萧紫紫 阅读(665) 评论(0) 推荐(0) 编辑
摘要: select top 5 * FROM [Menu] order by NEWID() select top 5 * FROM [Menu] order by 6 阅读全文
posted @ 2016-08-29 09:16 萧紫紫 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Create proc setup_list_add @creatime Datetime--创建时间 ,@objjc Varchar(20)--排期项目 ,@Doctor Varchar(20)--接诊医生 ,@beginDate Datetime--排班开始 ,@endtDate Datetime--排班结束 ,@objuser Varchar(20)--排班人 as begin begi... 阅读全文
posted @ 2016-08-29 09:15 萧紫紫 阅读(596) 评论(0) 推荐(0) 编辑