随笔分类 -  sql

摘要:方法一:创建合并列函数 方法二:xml path()方法在05之后可用 阅读全文
posted @ 2017-11-21 13:41 ly77461 阅读(3270) 评论(0) 推荐(0)
摘要:纵表格式如图所示: 查询sql语句如下: 变成横表如图所示: 纵表变横表sql语句如下: 阅读全文
posted @ 2017-11-21 12:01 ly77461 阅读(887) 评论(0) 推荐(0)
摘要:select getdate() select dateadd(year,-1,getdate()) select datediff(day,getdate(),dateadd(day,2,getdate()) ) Select datepart(month, dateadd(month,1,getdate())) Select datepart(hour, dateadd(mon... 阅读全文
posted @ 2017-11-21 11:41 ly77461 阅读(362) 评论(0) 推荐(0)
摘要:------------------------------------------创建一个方法----------------------------------------------------------------------@LatBegin 纬度A(33.8703596)-- --@LngBegin 经度A(-117.9242966)-- --@LatEnd 纬度B(34.0392... 阅读全文
posted @ 2017-05-24 10:34 ly77461 阅读(821) 评论(0) 推荐(0)
摘要:修改表中已有的字段属性 ALTER TABLE 表名 ALTER COLUMN 字段名 varchar(500) --sqlserver建表表时设置字段的默认值 create table 表(id int,name varchar(10) default '张三',age int) --添加字段时设置字段的默认值 alter ... 阅读全文
posted @ 2016-09-01 12:04 ly77461 阅读(44286) 评论(0) 推荐(1)
摘要:declare @a varchar(100),@b varchar(100) declare user_cursor cursor for select a,b from tableA tab open user_cursor fetch next from user_cursor into @a,@b while @@fetch_status=0 begin update tableA s... 阅读全文
posted @ 2016-08-04 13:55 ly77461 阅读(2067) 评论(0) 推荐(0)
摘要:导入之后必须关闭连接,否则会出现错误 阅读全文
posted @ 2016-08-04 13:48 ly77461 阅读(401) 评论(0) 推荐(0)