摘要: select *,REPLACE (列名,'需要变的字符','要变成的字符') from 表名 阅读全文
posted @ 2019-02-19 14:28 新手上路,多多关照 阅读(257) 评论(0) 推荐(0) 编辑
摘要: sp_helpdb test --查看数据库路径 backup database test to disk='D:\学习\test2019218.bak'--备份 restore filelistonly from disk='D:\学习\test2019218.bak'--查看还原的备份文件里的M 阅读全文
posted @ 2019-02-18 15:26 新手上路,多多关照 阅读(171) 评论(0) 推荐(0) 编辑
摘要: SQL分布式查询,简而言之就是跨域或跨服务器的查询 例:查询IP地址为190.111.1.177的zhfc数据库的abc表 --查询操作对方表的语句 select * into newcreattb from 123.zhfc.dbo.abc --把远程的表复制到本地 阅读全文
posted @ 2018-12-22 17:11 新手上路,多多关照 阅读(884) 评论(0) 推荐(0) 编辑
摘要: --函数 alter function xb ( @xingbie varchar(2) ) returns table as return ( select a.sex,SUM (b.score)as 总分,AVG(b.score)as 平均分 from stu3 as a full join stu4 as b on a .snum=b.cn... 阅读全文
posted @ 2018-11-30 17:12 新手上路,多多关照 阅读(854) 评论(0) 推荐(0) 编辑
摘要: alter function liejia ( @a int, @z int) returns int as begin declare @sum int while(@a<=@z) begin set @sum=isnull(@sum,0)+@a set @a=ISNULL(@a,0)+1 end return @sum e... 阅读全文
posted @ 2018-11-30 17:03 新手上路,多多关照 阅读(527) 评论(0) 推荐(0) 编辑
摘要: --函数 alter function zh() returns table as return( select 科目,max(张三) as 张三,max(李四)as 李四 from( select '语文'as 科目,张三,李四 from stu2 pivot(max(语文)for 姓名 in (科目,张三,李四))as a... 阅读全文
posted @ 2018-11-30 17:00 新手上路,多多关照 阅读(411) 评论(0) 推荐(0) 编辑