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
相关文档:
Access、SQLServer、Oracle常见SQL语句应用区别
关劲松 PMP
如果要兼容Access、SQL Server、Oracle三个数据库版本;我们在编写SQL语句的过程中,尽量使用一些通用的语句,但还是有些方面有些区别避免不了,现简单总结一下。
以下A代表Access,S代表SQL Server,O代表Oracle
1、取当前系统时间
A:Select Now()
S:Selec ......
用oracle习惯了,导出用exp语句,直接生成dmp文件,导入用imp语句,表结构和数据同时搞定。最近需要用到sqlserver,总是不能够同时导出表结构和数据,google上百度了很久也没解决方法。
右键--所有任务--导出数据--选择数据源,数据源为用于SQLServer的Microsoft OLE DB提供程序,选择验证方式 ......
选择指定条数语句:
db2:select * from tabname fetch frist n rows only
informix:select first n *
from tabname
oralce:select * from tabname where rownum <= n
sql server :select top n * from tabname ......
1.建表(Create table)时使用 IDENTITY (SEED,INCREMENT)
其中SEED是起始值,INCREMENT是增量。
例:
CREATE TABLE mytable1
(
[user_id] BIGINT NOT NULL
IDENTITY(1, 1) ,
......