Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Wednesday, March 21, 2012

Error 14262

Merge replication - SQL 2000. I ran some scripts to add a column to a table
and to add a new table and view to articles. All went fine. Then I tried
to manually start the snapshot agent and it gave me this error "The
specified @.job_id('guid number...') does not exist."
What do I need to do? I looked at Paul's site and found the explanation but
I'm not sure if this applies and was not clear what to do. Please help,
thanks.
David
Hi David - the explanation on my site refers to a scripting error and
doesn't seem relevant to your case to be honest. Can you refresh the jobs
folder as I think that you might be attempting to start a job that has been
removed/replaced. Also check under replication monitor that the agent has a
job (right-click and select "Agent properties..." and see what the name is
there.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
|||Paul,
I got this message from the Snapshot Agents folder, right-click of the
publication (which has a red X on it) and selecting "Start Agent". The
status column shows "Failed" due to "Timeout expired. ..." Apparently the
last attempt to create this had a problem. This server is not on our site,
so I'm not sure what happened. Also, this publication under the Publishers
folder also has a red X on it. Do I have to re-create the Publication
entirely?
Also, when I was there yesterday I created a new table and added it to the
articles via sp_addmergearticle. I also ran sp_repladdcolumn to add a
column to an existing publication. I have 2 publications, one for tables
and the other for views and stored procs. The one with the problems is the
tables publication and these problems (red X) existed before I ran these
additions.
David
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:egCdwmKMHHA.4000@.TK2MSFTNGP06.phx.gbl...
> Hi David - the explanation on my site refers to a scripting error and
> doesn't seem relevant to your case to be honest. Can you refresh the jobs
> folder as I think that you might be attempting to start a job that has
> been removed/replaced. Also check under replication monitor that the agent
> has a job (right-click and select "Agent properties..." and see what the
> name is there.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .
>

Wednesday, February 15, 2012

Erro trapping question

I have a batch file that runs SQL Server scripts using commands like:

OSQL -Umyname -Pmypassword -iScript_01.sql -w200 -e -n
>>Consolidation.log

Script_01.sql will contain statements like:
Update SASI.AACT set schoolnum='071' where schoolnum in ('000',' ')
update SASI.AATD set schoolnum='071' where schoolnum in ('000',' ')
update SASI.AATP set schoolnum='071' where schoolnum in ('000',' ')
update SASI.ACHS set schoolnum='071' where schoolnum in ('000',' ')
update SASI.ACLS set schoolnum='071' where schoolnum in ('000',' ')

If one of those tables should not exist, how could I have it continue,
but hopefully the log would have a reference to the error?

I am experimenting, but I am unsuccessfull with something like:
BEGIN TRAN
select count(*) from sasi.aact --this could be an update
statement
if @.@.ERROR =208 GOTO err_handle
select count(*) from sasi.astu
if @.@.ERROR <> 0 GOTO err_handle
select count(*) from sasi.astu
if @.@.ERROR <> 0 GOTO err_handle
select count(*) from sasi.astu
if @.@.ERROR <> 0 GOTO err_handle
err_handle:
return
commit Tran<OakRogbak_erPine@.yahoo.com> wrote in message
news:13fdc9b4.0410140645.305d53d3@.posting.google.c om...
>I have a batch file that runs SQL Server scripts using commands like:
> OSQL -Umyname -Pmypassword -iScript_01.sql -w200 -e -n
>>>Consolidation.log
> Script_01.sql will contain statements like:
> Update SASI.AACT set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.AATD set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.AATP set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.ACHS set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.ACLS set schoolnum='071' where schoolnum in ('000',' ')
> If one of those tables should not exist, how could I have it continue,
> but hopefully the log would have a reference to the error?
> I am experimenting, but I am unsuccessfull with something like:
> BEGIN TRAN
> select count(*) from sasi.aact --this could be an update
> statement
> if @.@.ERROR =208 GOTO err_handle
> select count(*) from sasi.astu
> if @.@.ERROR <> 0 GOTO err_handle
> select count(*) from sasi.astu
> if @.@.ERROR <> 0 GOTO err_handle
> select count(*) from sasi.astu
> if @.@.ERROR <> 0 GOTO err_handle
> err_handle:
> return
> commit Tran

Error handling is rather awkward in MSSQL:

http://www.sommarskog.se/error-handling-I.html
http://www.sommarskog.se/error-handling-II.html

In your case, the easiest thing is probably to avoid the error by checking
if the table exists before trying to query it:

if object_id('sasi.aact') is not null and
objectproperty(object_id('sasi.aact'), 'IsTable') = 1
begin
... -- do something here
end
else
begin
... -- log to an error table
end

Simon