There is a table named users in my database.
It has two colume:
userName varchar(20)
age int
now I execute the follow transaction:
begin tran
insert users (userName,age) values ('mark',25)
insert users (userName,age) values ('jack',2577777777777767777)
commit tran
obviously,the second setence has an overflow error,
the question is:has the first record been inserted into the users table?
why?"κÊöÀÚ" <weisl@.netstars.com.cn> wrote in message
news:%23T$6pCrPGHA.140@.TK2MSFTNGP12.phx.gbl...
> There is a table named users in my database.
> It has two colume:
> userName varchar(20)
> age int
> now I execute the follow transaction:
> begin tran
> insert users (userName,age) values ('mark',25)
> insert users (userName,age) values ('jack',2577777777777767777)
> commit tran
> obviously,the second setence has an overflow error,
> the question is:has the first record been inserted into the users table?
> why?
>
Because you told it to. You need error checking (or try/catch in SQL 2005)
to prevent execution from moving from the line that generates the error to
the line that commits the transaction.
David
Showing posts with label colume. Show all posts
Showing posts with label colume. Show all posts
Subscribe to:
Comments (Atom)