SqlServer中自定义类似Split截取字段函数
if exists (select * from dbo.sysobjects where name='SplitStr' )
drop FUNCTION SplitStr
go
CREATE FUNCTION SplitStr (@splitString varchar(8000), @separate varchar(10))
RETURNS @returnTable table(col_Value varchar(20))
AS
BEGIN
declare @thisSplitStr varchar(20)
declare @thisSepIndex int
declare @lastSepIndex int
set @lastSepIndex = 0
if Right(@splitString ,len(@separate)) <> @separate set @splitString = @splitString + @separate
set @thisSepIndex = CharIndex(@separate,@splitString ,@lastSepIndex)
while @lastSepIndex <= @thisSepIndex
begin
set @thisSplitStr = SubString(@splitString ,@lastSepIndex,@thisSepIndex-@lastSepIndex)
set @lastSepIndex = @thisSepIndex + 1
set @thisSepIndex = CharIndex(@separate,@splitString ,@lastSepIndex)
insert into @returnTable values(@thisSplitStr)
end&n
相关文档:
测试的时候比较重要,我们可以知道当前交易影响了哪些表
--用于记录用户在当前表上什么时候、做的什么操作:update、insert、delete
create table TriggerRecord
(
operdt datetime, --触发时间
opertp varchar(10), --操作类型:update、insert、delete
opertb varchar(50) --表名 ......
花了大半天的时间终于解决了问题,下面分享一下我的过程:
我的系统安装的是jdk6,netbeans和Mycrosoft SqlServer 2005,java连接数据库一般要分六部走
1.注册驱动
2.用驱动管理类创建连接
3.创建语句statement封装sql脚本语句
4.执行
5.处理返回的结果
6.关闭相关连接
在这里连接的是SqlServer2005,属于第三方驱动 ......
SQLServer 批量插入数据的两种方法
2009-07-27 19:31
在SQL Server 中插入一条数据使用Insert语句,但是如果想要批量插入一堆数据的话,循环使用Insert不仅效率低,而且会导致SQL一系统性能问题。下面介绍SQL Server支持的两种批量数据插入方法:Bulk和表值参数(Table-Valued Parameters)。
&nb ......
Create Procedure up_InsertData2
@ID INT
AS
BEGIN
Declare @Name NVARCHAR(30)
Declare @c1 NVARCHAR(30)
Declare @c2 NVARCHAR(30)
Declare @c3 NVARCHAR(30)
Declare @c4 NVARCHAR(30)
Declare tmpCur Cursor For Select a,b,c,d from table1
Open tmpCur;
Fetch Next from tmpCur Into @c1,@c2,@c3 ......