Ò»´Î²åÈë¶àÌõÐÅÏ¢(sql)
×¢ÊÍ:Ö»Êʺϵ¥±íµ¥ÁÐÊý¾Ý,
create database test
go
use test
go
create table users
(
:id int identity(1,1) primary key not null,
:name nvarchar(20)
)
go
create proc sp_Inserts
@Names nvarchar(4000)
as
declare @Name nvarchar(20),@ErrorSum int
:set @ErrorSum = 0
:begin tran
:while(len(@Names)>0)
:begin
::if(charindex(',',@Names)<>len(@Names))
::begin
:::set @Name = substring(@Names,0,charindex(',',@Names))
:::insert into users(name) values(@Name)
:::set @ErrorSum = @ErrorSum + @@error
:::set @Names = substring(@Names,(charindex(',',@Names)+1),(len(@Names)-(charindex(',',@Names))))
::end
::else
::begin
:::set @Name = substring(@Names,0,charindex(',',@Names))
:::insert into users(name) values(@Name)
:::set @ErrorSum = @ErrorSum + @@error
:::set @Names = ''
::end
:end:
:if(@ErrorSum<>0)
::rollback tran
:else
::commit tran
go
sp_Inserts 'Tom,Jack,Bob,'
Ïà¹ØÎĵµ£º
...
)
Óõ½µÄ¹¦ÄÜÓÐ:
1.Èç¹ûÎÒ¸ü¸ÄÁËѧÉúµÄѧºÅ,ÎÒÏ£ÍûËûµÄ½èÊé¼Ç¼ÈÔÈ»ÓëÕâ¸öѧÉúÏà¹Ø(Ò²¾ÍÊÇͬʱ¸ü¸Ä½èÊé¼Ç¼±íµÄѧºÅ);
2.Èç¹û¸ÃѧÉúÒѾ ......
drop table father;
create table father(
id int identity(1,1) primary key,
name varchar(20) not null,
age int not null
)
drop table mother;
create table mother(
id int identity(1,1),
name varchar(20) not null,
age int not null,
husban ......
ÅжÏÊý¾Ý¿âÀàÐÍ
(select count(*) fromsysobjects)>0 //sqlÊý¾Ý¿â
(select count(*) from msysobjects)>0 //accessÊý¾Ý¿â
µÃµ½SqlÓû§Ãû
user>0
Conversion failed when converting the nvarchar value 'dbo' to data type int.
Öع¹SQLÓï¾ä
ÕûÊýÐÍ
(A) ID=49 ID=49 And [ ²éѯÌõ¼þ] £¬¼´Ê ......
ÔÚ°²×°SQL Server 2005¿ª·¢°æʱ³öÏÖÎÊÌâ¡£°²×°»·¾³Îªwindows xp sp3£¬°²×°Óû§Ê¹Ó󬼶¹ÜÀíÔ±£¨Administrator£©¡£³öÏֵĴíÎóÊÇ
ÔÚ°²×°“Integration Services”²½Öèʱ³öÏÖ°²×°´íÎó£¬Ìáʾ“´íÎó: -2146233087”¡£
´íÎó¼Ç¼
±êÌâ:
Microsoft SQL Server 2005 °²×°³ÌÐò
ÎÞ·¨ÔÚ COM+ Ŀ¼Öа²×°ºÍÅäÖ ......
1 ±ÜÃâÎ޼ƻ®µÄÈ«±íɨÃè
ÈçÏÂÇé¿ö½øÐÐÈ«±íɨÃ裺
- ¸Ã±íÎÞË÷Òý
- ¶Ô·µ»ØµÄÐÐÎÞÈ˺ÍÏÞÖÆÌõ¼þ£¨ÎÞWhere×Ӿ䣩
- ¶ÔÓÚË÷ÒýÖ÷ÁУ¨Ë÷ÒýµÄµÚÒ» ......