The Perfect Day

分享技术,编写未来

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

随笔分类 -  [D] MSSQL

摘要:BULK INSERT 数据库名.dbo.[表名] --表名 FROM 'd:\create_report.txt'--文本文件名 WITH ( FIELDTERMINATOR = '|',--字段结束符 ROWTERMINATOR = '|\n'--行结束符 ) 阅读全文
posted @ 2008-05-26 15:30 StephenJu 阅读(257) 评论(0) 推荐(0)

摘要:将Excel导入SQL Server2000 select * into tableName from opendatasource('Microsoft.Jet.OLEDB.4.0','Data Source=e:\simple.xls;Extended Properties=Excel 8.0')[sheet1$] select * into tableName from openrowse... 阅读全文
posted @ 2008-05-26 12:44 StephenJu 阅读(242) 评论(0) 推荐(0)

摘要:create proc pr_test @IN_STORE_CODE varchar(11), @in_date_start varchar(8), @in_date_end varchar(8), @state_flag char(1), @WH_CODE varchar(3), @RECIPT_NO char(11), @SUP_NAME varchar(60), @MATERIAL_CO... 阅读全文
posted @ 2008-05-26 12:36 StephenJu 阅读(421) 评论(0) 推荐(0)

摘要:--查看表的属性 select * from sysObjects where [Name] = 'section' --用法 if exists ( select * from sysObjects where [Name] = 'section' and xtype='U' ) Drop Table table1 go Create table1 ( ) --获取所有用... 阅读全文
posted @ 2008-05-26 12:32 StephenJu 阅读(276) 评论(0) 推荐(0)

摘要:SELECT TOP n-m+1 * FROM TABLE a WHERE Not Exists (Select * From (Select Top m-1 * From TABLE ) b Where b.id=a.id ) 阅读全文
posted @ 2008-04-22 20:28 StephenJu 阅读(199) 评论(0) 推荐(0)

摘要:利用游标实现 CREATE table userinfo( name char(10), sex char(4), phone char(10))insert userinfo select 'aaa','男','12345' union all select 'bbb','男','12345' union all selec... 阅读全文
posted @ 2006-12-22 22:09 StephenJu 阅读(328) 评论(0) 推荐(0)

摘要:-创建数据库if exists(select * from sysdatabases where name=N'master..test')drop database testcreate database test--创建存储过程(法1)if exists(select * from sysobjects where name=N'proc_name' and type='p')drop pro... 阅读全文
posted @ 2006-11-21 15:29 StephenJu 阅读(572) 评论(0) 推荐(0)

摘要:scope_indentity() 返回插入到同一作用域中(存储过程,.......)的indentity列内的最后一个indentity值例: declare @dt table( _id int identity(1,1), _name char(10))insert into @dt (_name) values('zhang')insert into @dt (_name) value... 阅读全文
posted @ 2006-11-20 22:16 StephenJu 阅读(508) 评论(0) 推荐(0)

摘要:注:This method gets the record count much faster than select count(*) from table_name1、一般情况下,可以通过聚合函数Count实现查询出记录的总数 select count(*) as 记录总数 from table_name2、也可以通过查询系统表sysindexes实现 select row... 阅读全文
posted @ 2006-11-20 22:03 StephenJu 阅读(404) 评论(0) 推荐(0)

摘要:ROUND函数是四舍五入函数,返回数字表达式并四舍五入为指定的长度或精度。 语法:ROUND ( numeric_expression , length [ , function ] ) 参数:numeric_expression 精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。 length 是 numeric_expression 将要四舍五入的精度。length 必须是 t... 阅读全文
posted @ 2006-11-10 11:56 StephenJu 阅读(4412) 评论(0) 推荐(0)

摘要:若b列的值都为1则返回Y,否则返回X declare @t table(a int,b int)insert @tselect 1,1 union all select 2,1 union all select 3,1 union all select 4,0 select b=case when exists(select b from @t where b1) then 'X' else 'Y... 阅读全文
posted @ 2006-11-09 11:45 StephenJu 阅读(542) 评论(0) 推荐(0)

摘要:常用的日期信息获取函数 功能说明 语法 参数及返回值数据类型说明 ... 阅读全文
posted @ 2006-09-22 10:39 StephenJu 阅读(507) 评论(0) 推荐(0)

摘要:日期增减函数可以对日期指定部分的值进行增减,并返回处理后的日期值。具体语法:DATEADD(deapart,number,date) depart:是规定应该向日期的哪一部分返回新值的参数 DATEADD、DATEDIFF支持的日期部分、缩写及含义 日... 阅读全文
posted @ 2006-09-20 11:43 StephenJu 阅读(894) 评论(0) 推荐(0)