Hi
I've been looking at scripting some create tables, but want to know if the table created successfully. I've been doing the following:
DECLARE @.ERRCODE INT
CREATE TABLE x
SET @.ERRCODE = @.@.ERROR
This works ok, if there is no erroor. However if I run this again, then obviously I get the error "This object already exists" and the script stops executing.
Is there a way that I can capture the error using @.@.ERROR and still let the script run ?
Thanks in advance
MicksterWell, you shouldn't. "On Error Resume Next" is not present in T-SQL. What you should do is perform a validation for presence of object before attempting to create it.if objectproperty(object_id('dbo.x'), 'isusertable')=1 drop table dbo.x
create table dbo.x (f1 int, ...)|||Thanks, but I already understand that I should check for the existance of the object - as stated in my last mail. I want to check the table is being created correctly incase of other events, like permissions, file full, etc.
No comments:
Post a Comment