SqlServer
文章平均质量分 62
Dlinlin
这个作者很懒,什么都没留下…
展开
-
简单使用游标插入数据
--创建数据库create proc InsertStudentas--定义所需要的变量declare @SchoolID intdeclare @ClassID intdeclare @StudentID intdeclare @IDNumber int --条件判断时需要begin--创建游标declare FeeInsertStudent curso原创 2013-09-06 14:58:17 · 7972 阅读 · 0 评论 -
简单实用游标更改数据
alter proc updateStudent@id int,@id2 intasdeclare @SchoolID intdeclare @ClassID intdeclare @StudentID intdeclare @IDNumber intdeclare @IDAAA intbegindeclare FeeInsertStudent cursor原创 2013-09-06 15:01:44 · 1028 阅读 · 0 评论 -
SqlServer存储过程
常用系统存储过程有:exec sp_databases; --查看数据库exec sp_tables; --查看表exec sp_columns student;--查看列exec sp_helpIndex student;--查看索引exec sp_helpConstraint student;--约束exec sp_stored_procedures;exec原创 2013-09-03 11:20:20 · 986 阅读 · 0 评论 -
SQL Server中经常会用到的与时间相关的函数
SQLserver中用convert函数转换日期格式 SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm 例如: select getdate() 2004-09-12 11:06:08.177 整理了一下SQL Server里面可能经常会用到的日期格式转换方法: 举例如下: select CONVERT(v转载 2013-10-28 17:16:00 · 1292 阅读 · 0 评论 -
实现上一篇,下一篇的效果
实现如图效果 sql语句: select top 1 * from Table where id select top 1 * from Table where id>id 表示上一篇原创 2013-10-30 18:33:18 · 4487 阅读 · 0 评论 -
SqlServer去除表中的重复列,商品表和评论表,一个相拼对应多个评论,只去一个商品的一个评论
Da_CommodityList是商品表,Da_CommodityComment 评论表 pid为商品idSELECT row_number() OVER ( ORDER BY time DESC ) AS r_n , comm.time , comm.pid , comm.users , comm.conten原创 2013-12-09 17:25:35 · 1292 阅读 · 0 评论 -
利用存储过程把两个表的数据插入到一个新表中(存储过程中写两个游标)
CREATE PROCEDURE [dbo].[GetAllStuClickTime] @stime nvarchar(20),--开始时间@etime nvarchar(20)--结束时间--时间为第一个循环体 以这个时间段为范围AS BEGIN declare @days intdeclare @datediff intdeclare @dat原创 2013-12-11 16:32:29 · 13061 阅读 · 0 评论 -
语句被终止。完成执行语句前已用完最大递归 100
sql语句递归查询会员的推荐或安置关系时报错:语句被终止。完成执行语句前已用完最大递归……服务器范围的默认值为 100。如果指定 0,则没有限制。每一个语句只能指定一个 MAXRECURSION 值使用类似的语句:例如:;WITH cte AS( SELECT [AncestorID]=ParentID ,[DescendantID]=CustomerID ,[原创 2017-03-02 15:39:22 · 9052 阅读 · 0 评论