
sql
文章平均质量分 67
jsm8523
这个作者很懒,什么都没留下…
展开
-
sql中调用带输出参数的函数
Create Procedure Example(@a int,@b int output)as set @b=23调用declare @b intexec Example 1,@b output原创 2013-07-09 14:15:11 · 1874 阅读 · 0 评论 -
sql 行列转换
-- 行转列CREATE TABLE [ss_text]( [UserName] NVARCHAR(20), --学生姓名 [Subject] NVARCHAR(30), --科目 [Score] FLOAT, --成绩)INSERT I原创 2017-11-23 15:03:14 · 208 阅读 · 0 评论 -
数据库工具 Navicat_Premium
Navicat Premium一款功能强大的数据库管理工具,其它好处我都省略,因为只有一点就将我征服了—— 可以将 begin 与 end 收缩起来。原创 2016-09-13 14:28:30 · 484 阅读 · 0 评论 -
sql 中把datetime转换成string 函数
0Feb 22 2006 4:26PM CONVERT(CHAR(19), CURRENT_TIMESTAMP, 0)1 02/22/06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 1)2 06.02.22 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 2)3 22/02/0转载 2016-04-22 15:12:08 · 3322 阅读 · 0 评论 -
事务及-保存点的应用
1、创建事务的结构SqlConnection sqlConnection = new SqlConnection(); ...初始化连接 // 开启事务 SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); // 将事务应用于Co原创 2013-07-31 16:07:31 · 569 阅读 · 0 评论 -
如何判断一个时间段是否和另一个时间段冲突?
案例:预订会议室时判断提交预订的时间段是否与已经预订的时间段冲突CREATE TABLEroombookinfo( id intNOT NULL, title nvarchar(10)NOT NULL, beginTime datetime NOT NULL, endTime datetime NOT NULL) select原创 2015-12-10 18:15:14 · 4968 阅读 · 1 评论 -
计算sql语句的执行时间
declare @starttime datetimeset @starttime=getdate()--要执行的SQL语句select datediff(MS,@starttime,getdate())原创 2015-08-17 18:22:51 · 1299 阅读 · 0 评论 -
游标与事务结合使用,在游标内启用事务;判断数据类型不符合时执行下一条
--创建测试用户的表与数据CREATE TABLE [dbo].[t1]( [id] [int] IDENTITY(1,1)NOT NULL, [userId] [varchar](20)COLLATEChinese_PRC_CI_AS NULL, [money] [varchar](50)COLLATEChinese_PRC_CI_AS原创 2015-08-15 20:07:59 · 1001 阅读 · 0 评论 -
自己整个理的一些常用sql 语句
--查询当前数据库下的所有用户表select * from sysobjects where xtype= 'U'truncate table asdf --初始化表sp_help sjorder --显示 sjorder 表所有信息sp_helptext 'tgr_Name' --查看 tgr_Name 触发器的语句--查询表的约束sel原创 2014-04-03 15:26:14 · 441 阅读 · 0 评论 -
sql server 查询某个表的所有触发器名称
查出所有用到某个表的SQLselect * from sysobjects where xtype='TR' select * from sysobjects where xtype='TR' and parent_obj=object_id('表名')xtype char(2) 对象类型。可以是下列对象类型中转载 2014-03-10 13:53:14 · 1022 阅读 · 0 评论 -
如何快速生成100万不重复的8位编号
--如何快速生成100万不重复的8位编号 收藏 --最近在论坛看到有人问,如何快速生成100万不重复的8位编号,对于这个问题,有几点是需要注意的:--1. 如何生成8位随机数,生成的数越随机,重复的可能性当然越小--2. 控制不重复--3. 考虑性能--针对这个问题,我写了如下的示例来解决,希望能为有这类需求的人提供指导-- --生成100万条8位不重翻译 2014-02-21 11:14:53 · 1741 阅读 · 0 评论 -
动态语句语法:exec/sp_executesql语法
/******************************************************************************************************************************************************动态语句语法:exec/sp_executesql语法整理人:中国风(Roy)转载 2014-01-24 10:23:02 · 663 阅读 · 0 评论 -
SQLSERVER基本语法
一、定义变量--简单赋值declare @a int set @a=5 print @a --使用select语句赋值declare @user1 nvarchar(50) select @user1='张三'print @user1 declare @user2 nvarchar(50) select @user2原创 2013-06-15 15:19:07 · 607 阅读 · 0 评论 -
Sql 中 with 的使用例子
Create table with_case_Test(DID varchar(50) not null primary key,DName varchar(50) not null,PID varchar(50) null)insert into with_case_Test(DID,DName,PID) select 'A','A仓库',null uni原创 2013-07-23 18:01:49 · 526 阅读 · 0 评论 -
SQL查询当天、本周、本月记录详解
--查询当天: select * from info where DateDiff(dd,datetime,getdate())=0 --查询24小时内的: select * from info where DateDiff(hh,datetime,getDate())<=24 --info为表名,datetime为数据库中的字段值 ...转载 2019-02-23 10:45:47 · 2851 阅读 · 0 评论