Showing posts with label scripting. Show all posts
Showing posts with label scripting. Show all posts

Sunday, March 25, 2012

@@ERROR & CREATE TABLE

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.

Moving table with data to another database in sql Express 2005?

How to move some tables with data & procedures etc from 1 database to another in sql server 2005 express edition.

i did by scripting but i transfer tables and procedures and not data

data is the problem.

tnx

I'm already discussing this with you here

http://forums.asp.net/thread/1299924.aspx

sql