sqlserver 2005 split function
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
create function [dbo].[split](@str nvarchar(1000),@word varchar(5),@no
int) returns nvarchar(500)
as begin
declare @len int
declare @index int
set @index=charindex(@word,@str)
set @index=len(@word)+@index-1
set @len=len(@str)
if @index >0 and @no=2
return substring(@str,@index+1,@len)
else if @index>0 and @no=1
return substring(@str,0,@index-len(@word)+1)
return @str
end
相关文档:
疑问:
1, sqlserver里面执行 xp_cmdshell
exec @error=xp_cmdshell 'cmdstr......'
返回值是什么值?dos命令的错误?什么样的错误可以扑捉到?
比如:
DECLARE @error int
EXEC @error=master.dbo.xp_cmdshell 'bcp CM_DWHSend.dbo.WK_CM_DWHSend_Master in "D:\Sales\DWH_Onl\2010042_SENDMEMM.csv" -n -t, - ......
进来因为开发原因,经常需要使用日期方面的比较和操作,整理了一下这方面的资料,供大家共享:
SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm
例如:
select getdate()
2004-09-12 11:06:08.177
整理了一下SQL Server里面可能经常会用到的日期格式转换方法:
举例如下:
select CONVE ......
select identity(int,1,1) as col_id , * into temp from uep.dbo.A_experiment
select * from temp where col_id between 50 and 60
drop table temp ......
游标操作的六步骤:
◆在每次在创建游标的时候都问问自己,用什么别的方法可以避免使用游标,那么你就步如设计的正规了.
1.声明
2.打开
3.应用/操作
4.关闭.
5.释放
&nbs ......
现象:
现在做一个程序,对数据库的几个装有大量数据的表进行操作,对其中的一个表进行
循环操作,以处理其他的几个表。其中用到了几个query,update,当程序跑的过程中,
SQLSERVER的内存不断的增长,跑完后关闭程序退出后也不降下来。
解决:
这是SQL的内存管理机制决定的,SQL管理内存的原则是这样的,只要你的内存够 ......