Showing posts with label procedure. Show all posts
Showing posts with label procedure. Show all posts

Friday, March 30, 2012

RAISERROR does not cause SQL task to fail - why?

Greetings,

I have a stored procedure with a TRY / CATCH block. In the catch block I capture information about the error. I then use RAISERROR to "rethrow" the exception so that it will be available to SSIS.

I execute the stored procedure through a SQL task. I observe that SSIS reports the SQL task succeeds (the task box turns green) when RAISERROR is invoked. If I comment the catch block with RAISERROR then SSIS reports the task failed. (I created a simple procedure that does a divide by zero to force an error.) The expected error message is displayed when the sproc is run from the SQL Server Management Studio command line so I believe that the stored procedure is doing what I intended.

I would like to handle an error within my stored procedure without destroying SSIS's ability to detect a task failure. Is this possible? Is there an alternative to using RAISERROR?

Thanks,

BCB

But is it a message or an output? That is, which tab in SSMS does the results of the procedure end up on? "Results" or "Messages"?|||Can you please post code for both versions of the stored procedure?|||

Thanks for the replies.

Phil, to answer your question, the error message is displayed on the Messages tab in Management Studio.

I'm including two versions of the sproc as well as the invocation code I used to run it within Management Studio. I'm successfuly capturing the error info in the CATCH block and passing it back to SSIS. The point of having the RAISERROR at the end of the CATCH is to make SSIS fail the task.

This is the sproc with no CATCH:

Code Snippet

-- This is the stripped procedure with no CATCH block. The OUTPUT parms do nothing.
-- This sproc will cause an SQL task to fail.
ALTER PROCEDURE [dbo].[sp_ThrowException]
@.ERROR_NUMBER INT OUTPUT,
@.ERROR_MESSAGE NVARCHAR(4000) OUTPUT,
@.ERROR_SEVERITY INT OUTPUT,
@.ERROR_STATE INT OUTPUT,
@.ERROR_PROCEDURE NVARCHAR(126) OUTPUT,
@.ERROR_LINE INT OUTPUT,
@.FormattedMessage NVARCHAR(4000) OUTPUT
AS

BEGIN

SET NOCOUNT ON

-- this forces a "divide by zero" exception
SELECT 1 / 0 AS 'TRY' FROM view_OilRigs_REPORT R

END

This is the sproc as I really want it. It has the RAISERROR in the CATCH block.

Code Snippet

-- This is the desired procedure with the CATCH block. The error information is being returned
-- to the SQL task through the OUTPUT parms.
-- This sproc will allow an SQL task to succeed.

ALTER PROCEDURE [dbo].[sp_ThrowException]
@.ERROR_NUMBER INT OUTPUT,
@.ERROR_MESSAGE NVARCHAR(4000) OUTPUT,
@.ERROR_SEVERITY INT OUTPUT,
@.ERROR_STATE INT OUTPUT,
@.ERROR_PROCEDURE NVARCHAR(126) OUTPUT,
@.ERROR_LINE INT OUTPUT,
@.FormattedMessage NVARCHAR(4000) OUTPUT
AS

BEGIN TRY

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON

-- this forces a "divide by zero" exception
SELECT 1 / 0 AS 'TRY' FROM view_OilRigs_REPORT R

END TRY

BEGIN CATCH

SELECT
@.ERROR_NUMBER = ERROR_NUMBER(),
@.ERROR_MESSAGE = ERROR_MESSAGE(),
@.ERROR_SEVERITY = ERROR_SEVERITY(),
@.ERROR_STATE = ERROR_STATE(),
@.ERROR_PROCEDURE = ERROR_PROCEDURE(),
@.ERROR_LINE = ERROR_LINE(),
-- this renders the error message in command line format
@.FormattedMessage = 'Msg ' + CAST(ERROR_NUMBER() AS NVARCHAR(20)) + ', ' +
'Level ' + CAST(ERROR_SEVERITY() AS NVARCHAR(20)) + ', ' +
'State ' + CAST(ERROR_STATE() AS NVARCHAR(20)) + ', ' +
'Procedure ' + ERROR_PROCEDURE() + ', ' +
'Line ' + CAST(ERROR_LINE() AS NVARCHAR(20)) + ', ' +
'Message: ' + ERROR_MESSAGE()

-- Use RAISERROR inside the CATCH block to return error
-- information about the original error that caused
-- execution to jump to the CATCH block.
RAISERROR
(
@.ERROR_MESSAGE, -- Message text
@.ERROR_SEVERITY, -- Severity
@.ERROR_STATE -- State
)

END CATCH

I use this code to run the sproc in Management Studio.

Code Snippet

-- I use this to run the sproc within Management Studio.

SET NOCOUNT ON;

DECLARE @.local_ERROR_NUMBER INT
DECLARE @.local_ERROR_MESSAGE NVARCHAR(4000)
DECLARE @.local_ERROR_SEVERITY INT
DECLARE @.local_ERROR_STATE INT
DECLARE @.local_ERROR_PROCEDURE NVARCHAR(126)
DECLARE @.local_ERROR_LINE INT
DECLARE @.local_FormattedMessage NVARCHAR(4000)

EXEC [dbo].[sp_ThrowException]
@.ERROR_NUMBER = @.local_ERROR_NUMBER OUTPUT,
@.ERROR_MESSAGE = @.local_ERROR_MESSAGE OUTPUT,
@.ERROR_SEVERITY = @.local_ERROR_SEVERITY OUTPUT,
@.ERROR_STATE = @.local_ERROR_STATE OUTPUT,
@.ERROR_PROCEDURE = @.local_ERROR_PROCEDURE OUTPUT,
@.ERROR_LINE = @.local_ERROR_LINE OUTPUT,
@.FormattedMessage = @.local_FormattedMessage OUTPUT
SELECT
@.local_ERROR_NUMBER AS ERROR_NUMBER,
@.local_ERROR_MESSAGE AS ERROR_MESSAGE,
@.local_ERROR_SEVERITY AS ERROR_SEVERITY,
@.local_ERROR_STATE AS ERROR_STATE,
@.local_ERROR_PROCEDURE AS ERROR_PROCEDURE,
@.local_ERROR_LINE AS ERROR_LINE,
@.local_FormattedMessage AS FormattedMessage

Thanks for looking at this.

BCB

|||As long as it's posted to the messages tab, to my knowledge, you cannot capture that inside SSIS.|||

BlackCatBone wrote:

Thanks for the replies.

Phil, to answer your question, the error message is displayed on the Messages tab in Management Studio.

I'm including two versions of the sproc as well as the invocation code I used to run it within Management Studio. I'm successfuly capturing the error info in the CATCH block and passing it back to SSIS. The point of having the RAISERROR at the end of the CATCH is to make SSIS fail the task.

I don't think you can have it both ways. If the task fails, you're not going to be able to use it to capture the output parameters.

I'm personally surprised that SSIS does not fail the task when you use RAISERROR in your procedure code. I would have assumed that explicitly raising an error would cause the task to fail, but it does not. It's far too late for me to dig into this. Perhaps someone else can shed some light on the "why" of this behavior.

With that said, this is the approach that I would recommend if I needed to capture the error information from the stored procedure and have the package respond to the error as well:

Remove the RAISERROR from the procedure. Leave the TRY CATCH block in the procedure. Have the Execute SQL task call the procedure and capture the output parameters. Have precedence constraints below the Execute SQL task that follow a "success" path or an "error" path based on the values of the output parameters - likely the error number.

raiserror / terminate a users connection

Hi,
For slightly convoluted reasons I'd like to be able to terminate a users
connection from within a stored procedure, in a similar way as if I'd raised
an error with a severity of 20 or above. Is this possible?
The circumstances are that I have a number of security tests that I run at
various places, and there is one possible outcome which can only mean that a
user has been active for over 20 hours (practically impossible) or that the
system has been broken into in some way - I'd like to just completely kill
the connection immediately if this condition is detected, and wrap it in a
single stored procedure (i.e. take the key in question, test it, and then
raise an error and throw the user out if it fails).
Can it be done?
Thanks
NickYou can use KILL, but it won't be a neat error message for that connection..
.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Nick Stansbury" <nick.stansbury@.sage-removepartners.com> wrote in message
news:cutjph$rm0$1@.pop-news.nl.colt.net...
> Hi,
> For slightly convoluted reasons I'd like to be able to terminate a user
s
> connection from within a stored procedure, in a similar way as if I'd rais
ed
> an error with a severity of 20 or above. Is this possible?
> The circumstances are that I have a number of security tests that I run at
> various places, and there is one possible outcome which can only mean that
a
> user has been active for over 20 hours (practically impossible) or that th
e
> system has been broken into in some way - I'd like to just completely kill
> the connection immediately if this condition is detected, and wrap it in a
> single stored procedure (i.e. take the key in question, test it, and then
> raise an error and throw the user out if it fails).
> Can it be done?
> Thanks
> Nick
>|||But won't "Kill" only work for other connections other than the current
connection? What I need to do is Kill the current connection
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23MC5e55EFHA.2564@.tk2msftngp13.phx.gbl...
> You can use KILL, but it won't be a neat error message for that
connection...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Nick Stansbury" <nick.stansbury@.sage-removepartners.com> wrote in message
> news:cutjph$rm0$1@.pop-news.nl.colt.net...
users
raised
at
that a
the
kill
a
then
>|||Sorry, I thought you want to execute this from the outside the connection, h
ence the reference to
KILL
I'm afraid that I can't see an easy way to accomplish this unless the user i
s symin. If so, you
can use RAISERROR with severity 20 or higher.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Nick Stansbury" <nick.stansbury@.sage-removepartners.com> wrote in message
news:cuv15k$al6$1@.pop-news.nl.colt.net...
> But won't "Kill" only work for other connections other than the current
> connection? What I need to do is Kill the current connection
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n
> message news:%23MC5e55EFHA.2564@.tk2msftngp13.phx.gbl...
> connection...
> users
> raised
> at
> that a
> the
> kill
> a
> then
>

RAISERROR

Hello,

I am raising an error on my SQL 2005 procedure as follows:

RAISERROR(@.ErrorMessage, @.ErrorSeverity, 1)

How can I access it in my ASP.NET code?

Thanks,

Miguel

See the following post

http://forums.asp.net/p/639921/639921.aspx#639921

raise error with 2 procedures

I have 2 procedures.
1 procedure calls second procedure and in second procedure I use raise error
statement:
RAISEEROR(60005,1,1)
But first procedure doesn't get an error, @.@.error=0, so transaction in first
procedure is not rolled back.
Any idea?
I can use parameter like this:
exec @.eror=firstProcedureName
if @.eror=1 then
begin
ROLLBACK TRAN
RETURN
end
and in 2 procedure I return 1, if error is done.
But I wonder is there any automation?
Simonsimon
RAISERROR is intend for information messages not for ERRORS. Also look up
for NESTED operations in the BOL
"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:e2Y7jRHKFHA.1396@.TK2MSFTNGP10.phx.gbl...
> I have 2 procedures.
> 1 procedure calls second procedure and in second procedure I use raise
error
> statement:
> RAISEEROR(60005,1,1)
> But first procedure doesn't get an error, @.@.error=0, so transaction in
first
> procedure is not rolled back.
> Any idea?
> I can use parameter like this:
> exec @.eror=firstProcedureName
> if @.eror=1 then
> begin
> ROLLBACK TRAN
> RETURN
> end
> and in 2 procedure I return 1, if error is done.
> But I wonder is there any automation?
> Simon
>|||What? From BOL, "Returns a user-defined error message and sets a system
flag to record that an error has occurred. "
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23YevxzHKFHA.4056@.TK2MSFTNGP14.phx.gbl...
> simon
> RAISERROR is intend for information messages not for ERRORS. Also look up
> for NESTED operations in the BOL
> "simon" <simon.zupan@.stud-moderna.si> wrote in message
> news:e2Y7jRHKFHA.1396@.TK2MSFTNGP10.phx.gbl...
> error
> first
>|||Your severity is not "high" enough to automatically cause the error logic.
Either use a higher severity or use the seterror option.
raiserror (60005,1,1)
select @.@.error
raiserror (60005,11,1)
select @.@.error
raiserror (60005,1,1) with seterror
select @.@.error
"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:e2Y7jRHKFHA.1396@.TK2MSFTNGP10.phx.gbl...
> I have 2 procedures.
> 1 procedure calls second procedure and in second procedure I use raise
error
> statement:
> RAISEEROR(60005,1,1)
> But first procedure doesn't get an error, @.@.error=0, so transaction in
first
> procedure is not rolled back.
> Any idea?
> I can use parameter like this:
> exec @.eror=firstProcedureName
> if @.eror=1 then
> begin
> ROLLBACK TRAN
> RETURN
> end
> and in 2 procedure I return 1, if error is done.
> But I wonder is there any automation?
> Simon
>|||Scott
I mean 'Info' to inform the end-users about the error and not returning
actual error message.
"Scott Morris" <bogus@.bogus.com> wrote in message
news:u88agtJKFHA.2628@.tk2msftngp13.phx.gbl...
> What? From BOL, "Returns a user-defined error message and sets a system
> flag to record that an error has occurred. "
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23YevxzHKFHA.4056@.TK2MSFTNGP14.phx.gbl...
up
>|||It CAN be used to generate an informational message, but it is not limited
to such usage. When the proper invocation is used, the client application
sees the error in the same manner as any other dbms error (e.g., a
constraint violation).
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23T8dF%23JKFHA.2728@.TK2MSFTNGP10.phx.gbl...
> Scott
> I mean 'Info' to inform the end-users about the error and not returning
> actual error message.
>
> "Scott Morris" <bogus@.bogus.com> wrote in message
> news:u88agtJKFHA.2628@.tk2msftngp13.phx.gbl...
look
> up
raise
in
>sql

Friday, March 23, 2012

R

Hello,

I want to make a stored procedure to search row :

How can I do to search only on begin of field ?

Thanks

Don′t know if I understand you right, but that should be something like that:

CREATE Table SomeTable
(
SomeColumn VARCHAR(200)
)

GO

CREATE PROCEDURE SomeProcedure
(
@.SomeSearchValue VARCHAR(200)
)
AS
SELECT SomeColumn FROM SomeTable
WHERE SomeColumn LIKE @.SomeSearchValue + '%'

GO

INSERT INTO SomeTable VALUES ('SomeValue')

EXEC SomeProcedure 'Value'

--(0 row(s) affected)

EXEC SomeProcedure 'Some'

--SomeValue

--(1 row(s) affected)

--Clean the House

DROP PROCEDURE SomeProcedure
GO
DROP Table SomeTable


HTH, Jens Suessmeyer.

Wednesday, March 21, 2012

Quotes

What is the difference using the single or double quotes in a stored
procedure ?
Ex1: where username = @.username
AND status = "D" -- or 'D'
Ex2: if @.stringtype = "D" -- or 'D'
Select ...............
Thanks.See "SET QUOTED_IDENTIFIER" in BOL.
Example:
use northwind
go
set quoted_identifier off
go
select 1
where
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
go
set quoted_identifier on
go
select 1
where
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
go
The first "select" statement will return '1', but the second one will give
an error because sql server will consider the string as an identifier.
AMB
"DXC" wrote:
> What is the difference using the single or double quotes in a stored
> procedure ?
> Ex1: where username = @.username
> AND status = "D" -- or 'D'
> Ex2: if @.stringtype = "D" -- or 'D'
> Select ...............
>
> Thanks.|||Thanks...........
"Alejandro Mesa" wrote:
> See "SET QUOTED_IDENTIFIER" in BOL.
> Example:
> use northwind
> go
> set quoted_identifier off
> go
> select 1
> where
> "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
> go
> set quoted_identifier on
> go
> select 1
> where
> "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
> go
>
> The first "select" statement will return '1', but the second one will give
> an error because sql server will consider the string as an identifier.
>
> AMB
> "DXC" wrote:
> > What is the difference using the single or double quotes in a stored
> > procedure ?
> >
> > Ex1: where username = @.username
> > AND status = "D" -- or 'D'
> >
> > Ex2: if @.stringtype = "D" -- or 'D'
> > Select ...............
> >
> >
> > Thanks.

Quoted-Identifyer

Hi
Since short time I am experiencing the following problem when testing a
stored procedure.
Error on Insert since the following set options are not set properly:
QUOTED_IDENTIFYER
Sorry, that I do not have an exact error message, since I am working on
a german server, and I only translated the message by myself.
The error occured without changing the procedure or the data. It
suddenly appeared, then disappeared and then appeared again...
regards
StephanzDo any of your statements use "" around column names or aliases or values?
If a column name has spaces or is a reserved word, use [brackets] as opposed
to "double quotes" -- and strings should be delimited using 'single quotes'
rather than "double quotes".
"Stephan Zaubzer" <stephan.zaubzer@.schendl.at> wrote in message
news:uStQuCoyFHA.3588@.tk2msftngp13.phx.gbl...
> Hi
> Since short time I am experiencing the following problem when testing a
> stored procedure.
> Error on Insert since the following set options are not set properly:
> QUOTED_IDENTIFYER
> Sorry, that I do not have an exact error message, since I am working on a
> german server, and I only translated the message by myself.
> The error occured without changing the procedure or the data. It suddenly
> appeared, then disappeared and then appeared again...
> regards
> Stephanz|||In all my Procedures there is no " (Double Quote).
I already checked this. No column name has any space or uses reserved
words... and all my strings are sourrounded with single quotes. That's
why I contacted this news group, because this behaviour seems to be kind
of strange.
Last w the procedure worked fine! This w, suddenly I got the error
and I put a "SET QUOTED_IDENTIFYER ON" right above the insert statement.
Then it worked. Today it stopped working and I moved the "SET
QUOTED_IDENTIFYER ON" statement right to the beginning of the stored
procedure and then it worked again. But I didn't change any column names
in the database nor did I change the stored procedure. That all
sometimes makes me even believe that software can be indeterministic
allthough I know that it isn't...
regards
Stephan
Aaron Bertrand [SQL Server MVP] wrote:
> Do any of your statements use "" around column names or aliases or values?
> If a column name has spaces or is a reserved word, use [brackets] as opposed
> to "double quotes" -- and strings should be delimited using 'single quotes
'
> rather than "double quotes".
>
>
> "Stephan Zaubzer" <stephan.zaubzer@.schendl.at> wrote in message
> news:uStQuCoyFHA.3588@.tk2msftngp13.phx.gbl...
>
>
>|||debug the procedure with print statments and the profiler,
I always put this at the beginning an end of my sProcs
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
...do stuff
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET NOCOUNT OFF
GO
"Aaron Bertrand [SQL Server MVP]" wrote:

> Do any of your statements use "" around column names or aliases or values?
> If a column name has spaces or is a reserved word, use [brackets] as opposed
> to "double quotes" -- and strings should be delimited using 'single quotes
'
> rather than "double quotes".
>
>
> "Stephan Zaubzer" <stephan.zaubzer@.schendl.at> wrote in message
> news:uStQuCoyFHA.3588@.tk2msftngp13.phx.gbl...
>
>|||I traced down the problem a little bit:
The problem first arised when changing to a new developement server
which is hosted on a virtual test machine rather than on my old crappy
laptop ;-)
When creating tables, stored procedures and so on I never cared about
the QUOTED-IDENTIFYER options and I now had a look in the old version of
the database on my laptop and there for each stored procedure the
QUOTED-IDENTIFYER option was set to ON. Now (with exactly the same
create scripts for the stored procedures) for each procedure the server
sets this option to OFF. This is my problem now. How does the server
determine wheter to set or unset the QUOTED-IDENTIFYER option when
creating stored procedures.
btw... The error on the insert statement happened even though I did not
have any double quotes or similar constructs. SQL server requires that
when performing inserts, deletes, updates and creates on tables with
indexed views QUOTED-IDENTIFYERS must be set to ON. Otherwise those
opererations will fail...
Stephan Zaubzer wrote:
> In all my Procedures there is no " (Double Quote).
> I already checked this. No column name has any space or uses reserved
> words... and all my strings are sourrounded with single quotes. That's
> why I contacted this news group, because this behaviour seems to be kind
> of strange.
> Last w the procedure worked fine! This w, suddenly I got the error
> and I put a "SET QUOTED_IDENTIFYER ON" right above the insert statement.
> Then it worked. Today it stopped working and I moved the "SET
> QUOTED_IDENTIFYER ON" statement right to the beginning of the stored
> procedure and then it worked again. But I didn't change any column names
> in the database nor did I change the stored procedure. That all
> sometimes makes me even believe that software can be indeterministic
> allthough I know that it isn't...
> regards
> Stephan
> Aaron Bertrand [SQL Server MVP] wrote:
>|||> sets this option to OFF. This is my problem now. How does the server
> determine wheter to set or unset the QUOTED-IDENTIFYER option when
> creating stored procedures.
The server doesn't. The connection settings in effect for the dbms
connection used to edit the procedure are used (and saved). You determine
these settings by the method (or application) you use to edit the procedure.
You should read the information in BOL under the topic of "create
procedure". There is a detailed explanation of the settings that are
relevant to procedure creation and execution - very important information!

> btw... The error on the insert statement happened even though I did not
> have any double quotes or similar constructs. SQL server requires that
> when performing inserts, deletes, updates and creates on tables with
> indexed views QUOTED-IDENTIFYERS must be set to ON. Otherwise those
> opererations will fail...
Yes - this is (relatively) common knowledge. It helps to provide complete
information when posting in the newsgroups. Had you mentioned that an
indexed view was involved, someone might have identified the actual problem
a bit quicker. As a side note, you should also verify that any triggers
that may be participating in these actions are not contributing to the
problem.sql

'QUOTED_IDENTIFIER' when updating

Hello, I am getting the following message when running a stored proc:
Server: Msg 1934, Level 16, State 1, Procedure SZ_ProcessToCPInvoices, Line
261
UPDATE failed because the following SET options have incorrect settings:
'QUOTED_IDENTIFIER'.
I cannot find any information about this error. This happens with
QUOTED_IDENTIFIER on or off.
The setting is a sticky option, so setting it before execution or inside the proc doesn't change
anything. You have to set this in the connection where you *create* the procedure.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Ric" <Ric@.discussions.microsoft.com> wrote in message
news:13732376-28A5-4352-93CB-619B20137D3D@.microsoft.com...
> Hello, I am getting the following message when running a stored proc:
> Server: Msg 1934, Level 16, State 1, Procedure SZ_ProcessToCPInvoices, Line
> 261
> UPDATE failed because the following SET options have incorrect settings:
> 'QUOTED_IDENTIFIER'.
> I cannot find any information about this error. This happens with
> QUOTED_IDENTIFIER on or off.
>
>

'QUOTED_IDENTIFIER' when updating

Hello, I am getting the following message when running a stored proc:
Server: Msg 1934, Level 16, State 1, Procedure SZ_ProcessToCPInvoices, Line
261
UPDATE failed because the following SET options have incorrect settings:
'QUOTED_IDENTIFIER'.
I cannot find any information about this error. This happens with
QUOTED_IDENTIFIER on or off.The setting is a sticky option, so setting it before execution or inside the
proc doesn't change
anything. You have to set this in the connection where you *create* the proc
edure.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Ric" <Ric@.discussions.microsoft.com> wrote in message
news:13732376-28A5-4352-93CB-619B20137D3D@.microsoft.com...
> Hello, I am getting the following message when running a stored proc:
> Server: Msg 1934, Level 16, State 1, Procedure SZ_ProcessToCPInvoices, Lin
e
> 261
> UPDATE failed because the following SET options have incorrect settings:
> 'QUOTED_IDENTIFIER'.
> I cannot find any information about this error. This happens with
> QUOTED_IDENTIFIER on or off.
>
>

'QUOTED_IDENTIFIER' when updating

Hello, I am getting the following message when running a stored proc:
Server: Msg 1934, Level 16, State 1, Procedure SZ_ProcessToCPInvoices, Line
261
UPDATE failed because the following SET options have incorrect settings:
'QUOTED_IDENTIFIER'.
I cannot find any information about this error. This happens with
QUOTED_IDENTIFIER on or off.The setting is a sticky option, so setting it before execution or inside the proc doesn't change
anything. You have to set this in the connection where you *create* the procedure.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Ric" <Ric@.discussions.microsoft.com> wrote in message
news:13732376-28A5-4352-93CB-619B20137D3D@.microsoft.com...
> Hello, I am getting the following message when running a stored proc:
> Server: Msg 1934, Level 16, State 1, Procedure SZ_ProcessToCPInvoices, Line
> 261
> UPDATE failed because the following SET options have incorrect settings:
> 'QUOTED_IDENTIFIER'.
> I cannot find any information about this error. This happens with
> QUOTED_IDENTIFIER on or off.
>
>

QUOTED_IDENTIFIER and SQL DMO

I am trying to dump out scripts for stored procedure and wondering how
I could exclude 'SET QUOTED_IDENTIFIER ON/OFF' option from the output.
I gather this option becomes part of stored procedure script on
creation time...!
I couldn't find any flags in SQL DMO that could be used to ignore this
option.
Please help...
Thanks
Sandiyanhi Sandiyan,
"sandiyan" <sandiyan@.yahoo.co.uk> ha scritto nel messaggio
news:69e9c64b.0404150614.632ccd9d@.posting.google.com...
> I am trying to dump out scripts for stored procedure and wondering how
> I could exclude 'SET QUOTED_IDENTIFIER ON/OFF' option from the output.
> I gather this option becomes part of stored procedure script on
> creation time...!
> I couldn't find any flags in SQL DMO that could be used to ignore this
> option.
> Please help...
i think the Object scripting constant
SQLDMO_SCRIPT_TYPE.SQLDMOScript_UseQuotedIdentifiers shoul'd be your case...
SQLDMOScript_UseQuotedIdentifiers , vaule= -1, description=Use quote
characters to delimit identifier parts when scripting object names
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.7.0 - DbaMgr ver 0.53.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply|||> i think the Object scripting constant
> SQLDMO_SCRIPT_TYPE.SQLDMOScript_UseQuotedIdentifiers shoul'd be your case...
> SQLDMOScript_UseQuotedIdentifiers , vaule= -1, description=Use quote
> characters to delimit identifier parts when scripting object names
Thanks. I tried this and it didn't work.
Help...
regards,
Sandiyan.

Tuesday, March 20, 2012

quick yukon query

Does anyone know if the extended stored procedure xp_msver
is still present in Yukon ?I'm not sure that anyone can answer that question, without violating NDA.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Steve" <anonymous@.discussions.microsoft.com> wrote in message
news:0a8901c3b9ad$a0b8c410$a401280a@.phx.gbl...
> Does anyone know if the extended stored procedure xp_msver
> is still present in Yukon ?|||On second thought, since Beta 1 has been released from NDA, I guess I can
tell you that it exists in Beta 1. But that does not guarantee that it will
exist in the final product.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/|||Thanks Aaron, I appreciate your helpfulness !
>--Original Message--
>On second thought, since Beta 1 has been released from
NDA, I guess I can
>tell you that it exists in Beta 1. But that does not
guarantee that it will
>exist in the final product.
>--
>Aaron Bertrand
>SQL Server MVP
>http://www.aspfaq.com/
>
>.
>

quick transaction inside a stored procedure question

a transaction block inside a sproc

if after one of the tran statements, I bust out of the sproc with a return statement

do I have to rollback explicitly first or does the tran rollback automatically?

appreciate the tip

After returning to another procedure the @.@.TRANCOUNT should be still increased by 1. You can test that by printing out the @.@.trancount variables in both procedure. In common, I would always handle the transcation context on my own by settings explizit transaction heaviour.

HTH, jens Suessmeyer.|||thanks jens|||

Could you please rate the thread as solved or helpful or whatever, that its no longer present as unanswerd ?

Thanks, Jens.

Monday, March 12, 2012

Quick SQL Homework Help!

Hi everyone,

I'm new to SQL, and need help with the following problem:

'Create a stored procedure, name employee salary, that will receive two parameters, the employee's id (eid) and the salary increase (incSal). The procedure will then increment the salary by the amount of incSal. The procedure will then print the employee id, name, address and the new salary.'

I don't ask for answers to homework, but today, I'm desparate. I would have asked for help earlier but for my final exam and project for this class. This homework is due later on in the evening.
PLEASE HELPany attempt from your side|||Originally posted by skd
any attempt from your side

CREATE PROC INCSAL
STORED PROCEDURE
@.EMPLOYEE ID nvarchar(20),
@.INCREASE SALARY int
AS
BEGIN
INSERT INTO SALARY (EMP_ ID, INC_SAL)
VALUES (@.EMPLOYEE ID,@.INCREASE SALARY)
PRINT "EMP_ ID", ;
PRINT "EMP_ NAME" ;
PRINT "ADDRESS";
PRINT "NEW SALARY"



END
STORED PROCEDURE AS|||see if this works
-------
CREATE OR REPLACE PROCEDURE name_employee_salary (
p_Eid IN NUMBER,
p_IncSal IN NUMBER ) AS

v_Eid employee.employee_id%TYPE;
v_Ename employee.employee_name%TYPE;
v_Eaddress employee.employee_address%TYPE;
v_Esalary employee.employee_salary%TYPE;

BEGIN

UPDATE employee
SET salary=salary + p_IncSal
WHERE employee_id = p_Eid
COMMIT;

SELECT employee_id, employee_name, employee_address, employee_salary
INTO v_Eid, v_Ename, v_Eaddress, v_Esalary
FROM employee
WHERE employee_id=p_Eid;

DBMS_OUTPUT.PUT_LINE ('employee Id : ' || TO_CHAR(v_Eid) );
DBMS_OUTPUT.PUT_LINE ('employee Name : ' || v_Ename );
DBMS_OUTPUT.PUT_LINE ('employee Address : ' || v_Eaddress );
DBMS_OUTPUT.PUT_LINE ('employee New Salary: ' || TO_CHAR(v_Esalary) );

END;|||This is far better than what I had. I'm tweaking it in SQL now. Thanks a bunch.|||My professor didn't show us this:

DBMS_OUTPUT.PUT_LINE ('employee Id : ' || TO_CHAR(v_Eid) );
DBMS_OUTPUT.PUT_LINE ('employee Name : ' || v_Ename );
DBMS_OUTPUT.PUT_LINE ('employee Address : ' || v_Eaddress );
DBMS_OUTPUT.PUT_LINE ('employee New Salary: ' || TO_CHAR

Rather, he wants us to use the PRINT function:

I think this is how it must look:

PRINT ("Employee Name", Name)
PRINT ("Employee Salary", Salary)
PRINT ("Employee ID", EID)

I don't even know if I have the code right, but thanks again.|||what sql you are using, i gave you pl/sql verison.

PRINT looks ok to me.
if doesn't works then try
PRINT "Employee ID" + EID

good luck|||I'm using Microsoft SQL Server 2000, but the cd also includes IBM DB2, and MySQL|||i am not familiar with sql server but can take a look at errors you getting|||This is the code I have so far:

CREATE PROCEDURE name_employee_salary (
@.p_Eid ncvarchar(20),
@.p_IncSal
AS
BEGIN

UPDATE employee
SET salary=salary + p_IncSal
WHERE employee_id = p_Eid
COMMIT;

SELECT employee_id, employee_name, employee_salary
FROM employee
WHERE employee_id=p_Eid;

PRINT Employee_name
PRINT Employee_salary
PRINT EID

END

Here's the error message.

Error 156: Incorrect syntax near the keyword 'BEGIN'.
The name 'Employee_name' is not permitted in this context. Only constants, expressions, or variables allowed here. Columns names are not permitted.

The error said the same thing about Employee_salary, and EID
(I won't waste your time writing out the whole thing.)|||1) it might not require BEGIN and/or END which aer reserve word used in pl/sql.

2) replace employee_id, employee_name, employee_salary by
actual field of your employee table.|||post your question to SQL/SEVER forum
which is http://www.dbforums.com/f7/

good luck|||Don't you need to close the parentesis after @.p_IncSal?:

CREATE PROCEDURE name_employee_salary (
@.p_Eid ncvarchar(20),
@.p_IncSal )
...
;)

PS: I neither have any clue about MS SQL...
Good luck.|||Originally posted by LKBrwn_DBA
Don't you need to close the parentesis after @.p_IncSal?:

CREATE PROCEDURE name_employee_salary (
@.p_Eid ncvarchar(20),
@.p_IncSal )
...
;)

PS: I neither have any clue about MS SQL...
Good luck.

Thanks a lot for your help. I got the work finished on time.

Friday, March 9, 2012

Quick question: how do I get the name of the current database?

Is there an sp_zzzzzz function to return the name of the current database?
I would like to use this name as a variable in a stored procedure in order
to create names for further databases (by appending a tag, such as
MYDATABASE_BLOB001, ..._BLOB002 etc.

Thanks.SELECT DB_NAME()

Why create a database from a Stored Procedure?
--
David Portas
SQL Server MVP
--|||"Robin Tucker" <idontwanttobespammedanymore@.reallyidont.com> wrote in
message news:ct5isn$9m3$1$8302bc10@.news.demon.co.uk...
> Is there an sp_zzzzzz function to return the name of the current database?
> I would like to use this name as a variable in a stored procedure in order
> to create names for further databases (by appending a tag, such as
> MYDATABASE_BLOB001, ..._BLOB002 etc.
>
> Thanks.

select db_name()

It might be worth considering why you need multiple databases - could
BLOB001 be part of a key in a table instead? This discussion applies to
tables, not databases, but the principle is exactly the same:

http://www.sommarskog.se/dynamic_sql.html#Sales_yymm

Simon|||The issue is that we have one database with our adjacency list in and then
one or more with our media blobs in. Our users won't be using full SQL
server, so we have 2Gb limit on MSDE. When one of the blob databases
reaches close to 2Gb, we rollover to the next blob database. In my
adjacency table I store the blob database ID and Key for the blob associated
with each node. I also have a table with all of the blob databases listed,
so I can lookup and find which database the ID refers to.

Can't help it. Customers are cheapskates ;)

"Simon Hayes" <sql@.hayes.ch> wrote in message
news:41f65413$1_3@.news.bluewin.ch...
> "Robin Tucker" <idontwanttobespammedanymore@.reallyidont.com> wrote in
> message news:ct5isn$9m3$1$8302bc10@.news.demon.co.uk...
>> Is there an sp_zzzzzz function to return the name of the current
>> database? I would like to use this name as a variable in a stored
>> procedure in order to create names for further databases (by appending a
>> tag, such as MYDATABASE_BLOB001, ..._BLOB002 etc.
>>
>>
>> Thanks.
>>
>>
>>
> select db_name()
> It might be worth considering why you need multiple databases - could
> BLOB001 be part of a key in a table instead? This discussion applies to
> tables, not databases, but the principle is exactly the same:
> http://www.sommarskog.se/dynamic_sql.html#Sales_yymm
> Simon|||"Robin Tucker" <idontwanttobespammedanymore@.reallyidont.com> wrote in
message news:ct5l4s$ig$1$8300dec7@.news.demon.co.uk...
> The issue is that we have one database with our adjacency list in and then
> one or more with our media blobs in. Our users won't be using full SQL
> server, so we have 2Gb limit on MSDE. When one of the blob databases
> reaches close to 2Gb, we rollover to the next blob database. In my
> adjacency table I store the blob database ID and Key for the blob
associated
> with each node. I also have a table with all of the blob databases
listed,
> so I can lookup and find which database the ID refers to.
> Can't help it. Customers are cheapskates ;)

Something to be aware of: I think that MSDE may also limit you on the number
of databases you are allowed so there may be a limit on the number of times
you can "rollover" to another database.

Brian.

www.cryer.co.uk/brian

Quick question to check NULL values in input parameters in a stored procedure

Hi:

I have a stored procedure that calls 3 stored procedures. If some of my input parameters are NULL, I would like to skip the call to another stored procedure. Can you someone please help me with this? I would like to find out what is NULL, before I execute the other stored procedures. Thanks so much.

MA

check with is not null

example

If @.Var1 is not null
begin
exec proc1 @.Var1
end

If @.Var2 is not null
begin
exec proc2 @.Var2
end

If @.Var3 is not null
begin
exec proc3 @.Var3
end


Denis the SQL Menace
http://sqlservercode.blogspot.com/

|||Is there a way loop thru the parameters in one go, because in some instances I am dealing with a set of 50 or more parameters. Thanks.|||

something like this perhaps

declare @.v int
declare @.v2 int
declare @.v3 int


select @.v =1,@.v2 =3

if exists (select * from (select @.v as a union all
select @.v2 union all
select @.v3) z where a is null)
begin
print 'at least one parameter has a null value'
end

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||

Going back to your initial response, which I think I will respond as an Answer to my question, because it is my best bet at this moment. I do have a quick question in reference to your first response, here it is:

If I have more than parameters, that I need to check for NULL, and if its NULL then dont execute the SP, and vice versa, how would i do that? Can i do something like this, my goal is to check/validate that if all values passed in are NULL, then dont call the sp:

IF @.CitizenshipStatusCode is null and
@.GovtIDTypeCode is null and
@.AlienID is null and
@.EmploymentStatusCode is null and
@.EmployerName is null and
@.EmployerAddress1 is null and
@.EmployerAddress2 is null and
@.EmployerAddress3 is null and
@.EmployerCity is null and
@.EmployerStateCode is null and
@.EmployerZipCode is null and
@.EmployerCountryCode is null and
@.Position is null and
@.WorkForeignPhoneExchange is null and
@.WorkAreaCode is null and
@.WorkPhoneNumber is null and
@.WorkExtension is null and
@.WorkEmail is null and
@.EmploymentYears is null and
@.EmploymentMonths is null and
@.MonthlySalaryAmount is null and
@.MonthlyRentAmount is null and
@.OtherMonthlyIncome is null and
@.ResidenceTypeCode is null and
@.CreatedPersonID is null and
@.UpdatedOn is null and
@.CreatedPersonID is null and
@.UpdatedOn is null
BEGIN
Set @.IsNull = 1
END
ELSE
Set @.IsNull = 0

|||

you could use coalesce since coalesce returns the first non null value

examples

declare @.v varchar(40)
declare @.v2 int
declare @.v3 int

select @.v ='1',@.v2 =3
if coalesce(@.v,@.v2,@.v2,null) is null
begin
select 'is null'
end
else
begin
select 'is NOT null'
end
go

declare @.v varchar(40)
declare @.v2 int
declare @.v3 int

--will be null
if coalesce(@.v,@.v2,@.v2,null) is null
begin
select 'is null'
end
else
begin
select 'is NOT null'
end

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||thanks I think this is what I can use. Also, why do you have the word null at the end, inside the parantheses. Is that necessary? Whats the purpose of that?|||It is not necessary to have NULL at the end. If all of the inputs to COALESCE is NULL then it will return NULL anyway.

Quick Question on SP and Transactions

Hello
Say if I have a Store Procedure that creates a named
transaction.
Can I have a different SP which commits or rollbacks it ?
Thanks
Yes, if the second SP was called by the first SP from within the same
transaction. In that case, it would all be in the same calling stack and
transaction space.
However, I generally don't like the idea of having transaction bounds cross
procedures like that. I find that it inevitably leads to transaction and
logic errors since programmers will get conufsed about how the transactions
interact with each other.
"Jimbo" <anonymous@.discussions.microsoft.com> wrote in message
news:414c01c488fb$bda7dc00$a301280a@.phx.gbl...
> Hello
> Say if I have a Store Procedure that creates a named
> transaction.
> Can I have a different SP which commits or rollbacks it ?
> Thanks
>

Quick Question on SP and Transactions

Hello
Say if I have a Store Procedure that creates a named
transaction.
Can I have a different SP which commits or rollbacks it ?
ThanksYes, if the second SP was called by the first SP from within the same
transaction. In that case, it would all be in the same calling stack and
transaction space.
However, I generally don't like the idea of having transaction bounds cross
procedures like that. I find that it inevitably leads to transaction and
logic errors since programmers will get conufsed about how the transactions
interact with each other.
"Jimbo" <anonymous@.discussions.microsoft.com> wrote in message
news:414c01c488fb$bda7dc00$a301280a@.phx.gbl...
> Hello
> Say if I have a Store Procedure that creates a named
> transaction.
> Can I have a different SP which commits or rollbacks it ?
> Thanks
>

Quick Question on SP and Transactions

Hello
Say if I have a Store Procedure that creates a named
transaction.
Can I have a different SP which commits or rollbacks it ?
ThanksYes, if the second SP was called by the first SP from within the same
transaction. In that case, it would all be in the same calling stack and
transaction space.
However, I generally don't like the idea of having transaction bounds cross
procedures like that. I find that it inevitably leads to transaction and
logic errors since programmers will get conufsed about how the transactions
interact with each other.
--
"Jimbo" <anonymous@.discussions.microsoft.com> wrote in message
news:414c01c488fb$bda7dc00$a301280a@.phx.gbl...
> Hello
> Say if I have a Store Procedure that creates a named
> transaction.
> Can I have a different SP which commits or rollbacks it ?
> Thanks
>

Monday, February 20, 2012

Queue Reader - remote procedure call failed

I am running transactional repl with an updateable subscription between two servers running SQL Server 2000 SP3, all agents running on the publisher. Every now and then, the Queue reader fails. I enable logging and attempt restart. The output file looks n
ormal to me; several queries for queued data, but then it seems to timeout. It just sits there for 3 minutes, then fails and retries. I can successfully query the other server, so I know it's not a communications problem. The event viewer simply says "the
remote procedure call failed and did not execute". I can't find any other error messages.
Does anyone have any advice? Thank you.
Microsoft SQL Server Replication Queue Reader Agent 8.00.760
Copyright (c) 2000 Microsoft Corporation
Microsoft SQL Server Replication Agent: [MIALDCS-1].9
Trying to Connect to Local Distributor
Connecting to QueueReader 'MIALDCS-1.distribution'
Server: MIALDCS-1
DBMS: Microsoft SQL Server
Version: 08.00.0760
user name: dbo
API conformance: 2
SQL conformance: 1
transaction capable: 2
read only: N
identifier quote char: "
non_nullable_columns: 1
owner usage: 31
max table name len: 128
max column name len: 128
need long data len: Y
max columns in table: 1024
max columns in index: 16
max char literal len: 524288
max statement len: 524288
max row size: 524288
[7/30/2004 12:17:19 PM]MIALDCS-1.distribution: select count(*) from master.dbo.sysprocesses where [program_name] = 'Queue Reader Main (distribution)'
[7/30/2004 12:17:19 PM]MIALDCS-1.distribution: select top 1 id, name from MSqreader_agents
[7/30/2004 12:17:19 PM]MIALDCS-1.distribution: select SERVERPROPERTY('IsClustered')
Queue Reader Agent [MIALDCS-1].9 (Id = 3) started
Repl Agent Status: 1
[7/30/2004 12:17:19 PM]MIALDCS-1.distribution: execute dbo.sp_MShelp_profile 3, 9, N''
Opening SQL based queues
[7/30/2004 12:17:19 PM]MIALDCS-1.distribution: exec master.dbo.sp_MSenum_replsqlqueues N'distribution'
Worker Thread 608 : Starting
The Message Queuing service does not exist[7/30/2004 12:17:19 PM]MIALDCS-1.distribution: exec dbo.sp_MShelp_subscriber_info N'MIALDCS-1', N'MIALDCS-2'
The Message Queuing service is not available
Connecting to MIALDCS-2 'MIALDCS-2.Island'
Server: MIALDCS-2
DBMS: Microsoft SQL Server
Version: 08.00.0760
user name: dbo
API conformance: 2
SQL conformance: 1
transaction capable: 2
read only: N
identifier quote char: "
non_nullable_columns: 1
owner usage: 31
max table name len: 128
max column name len: 128
need long data len: Y
max columns in table: 1024
max columns in index: 16
max char literal len: 524288
max statement len: 524288
max row size: 524288
MIALDCS-2.Island: {? = call dbo.sp_getsqlqueueversion (?, ?, ?, ?)}
MIALDCS-2.Island: {? = call dbo.sp_replsqlqgetrows (N'MIALDCS-1', N'Island', N'Island')}
[7/30/2004 12:17:31 PM]MIALDCS-1.distribution: exec dbo.sp_helpdistpublisher @.publisher = N'MIALDCS-1'
Connecting to MIALDCS-1 'MIALDCS-1.Island'
Worker Thread 608 : processing Transaction [2LhOShgh_agC2<T]?LH.h-5--09M--] of [SQL Queue]
Worker Thread 608 : Started Queue Transaction
Worker Thread 608 : Started SQL Tran
MIALDCS-1.Island: {? = call dbo.sp_getqueuedarticlesynctraninfo (N'Island', 44)}
SQL Command : <exec [dbo].[sp_MSsync_del_Leg_Seat_Map_1] N'MIALDCS-2', N'Island', 'F2', '101', '2004-07-24 00:00:00.000', '1', 0, 0, ' ', ' ', 0, 12632256, ' ', 'Y', ' ', 'N', 'N', '', '', '', '', '', '', '', '', ' ', ' ', ' ', 'E8613112-29DC-4563-B3F0-58
665C4967B9', 1>
(hundreds more records follow)
what command is it failing on?
The problem is probably related to the execution of a single proc, which is
locking on the publisher.
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"LeeH" <LeeH@.discussions.microsoft.com> wrote in message
news:055E41A9-DA76-403B-8D93-3F4C32BA6DDE@.microsoft.com...
> I am running transactional repl with an updateable subscription between
two servers running SQL Server 2000 SP3, all agents running on the
publisher. Every now and then, the Queue reader fails. I enable logging and
attempt restart. The output file looks normal to me; several queries for
queued data, but then it seems to timeout. It just sits there for 3 minutes,
then fails and retries. I can successfully query the other server, so I know
it's not a communications problem. The event viewer simply says "the remote
procedure call failed and did not execute". I can't find any other error
messages.
> Does anyone have any advice? Thank you.
> Microsoft SQL Server Replication Queue Reader Agent 8.00.760
> Copyright (c) 2000 Microsoft Corporation
> Microsoft SQL Server Replication Agent: [MIALDCS-1].9
> Trying to Connect to Local Distributor
> Connecting to QueueReader 'MIALDCS-1.distribution'
> Server: MIALDCS-1
> DBMS: Microsoft SQL Server
> Version: 08.00.0760
> user name: dbo
> API conformance: 2
> SQL conformance: 1
> transaction capable: 2
> read only: N
> identifier quote char: "
> non_nullable_columns: 1
> owner usage: 31
> max table name len: 128
> max column name len: 128
> need long data len: Y
> max columns in table: 1024
> max columns in index: 16
> max char literal len: 524288
> max statement len: 524288
> max row size: 524288
> [7/30/2004 12:17:19 PM]MIALDCS-1.distribution: select count(*) from
master.dbo.sysprocesses where [program_name] = 'Queue Reader Main
(distribution)'
> [7/30/2004 12:17:19 PM]MIALDCS-1.distribution: select top 1 id, name from
MSqreader_agents
> [7/30/2004 12:17:19 PM]MIALDCS-1.distribution: select
SERVERPROPERTY('IsClustered')
> Queue Reader Agent [MIALDCS-1].9 (Id = 3) started
> Repl Agent Status: 1
> [7/30/2004 12:17:19 PM]MIALDCS-1.distribution: execute
dbo.sp_MShelp_profile 3, 9, N''
> Opening SQL based queues
> [7/30/2004 12:17:19 PM]MIALDCS-1.distribution: exec
master.dbo.sp_MSenum_replsqlqueues N'distribution'
> Worker Thread 608 : Starting
> The Message Queuing service does not exist[7/30/2004 12:17:19
PM]MIALDCS-1.distribution: exec dbo.sp_MShelp_subscriber_info N'MIALDCS-1',
N'MIALDCS-2'
> The Message Queuing service is not available
> Connecting to MIALDCS-2 'MIALDCS-2.Island'
> Server: MIALDCS-2
> DBMS: Microsoft SQL Server
> Version: 08.00.0760
> user name: dbo
> API conformance: 2
> SQL conformance: 1
> transaction capable: 2
> read only: N
> identifier quote char: "
> non_nullable_columns: 1
> owner usage: 31
> max table name len: 128
> max column name len: 128
> need long data len: Y
> max columns in table: 1024
> max columns in index: 16
> max char literal len: 524288
> max statement len: 524288
> max row size: 524288
> MIALDCS-2.Island: {? = call dbo.sp_getsqlqueueversion (?, ?, ?, ?)}
> MIALDCS-2.Island: {? = call dbo.sp_replsqlqgetrows (N'MIALDCS-1',
N'Island', N'Island')}
> [7/30/2004 12:17:31 PM]MIALDCS-1.distribution: exec
dbo.sp_helpdistpublisher @.publisher = N'MIALDCS-1'
> Connecting to MIALDCS-1 'MIALDCS-1.Island'
> Worker Thread 608 : processing Transaction
[2LhOShgh_agC2<T]?LH.h-5--09M--] of [SQL Queue]
> Worker Thread 608 : Started Queue Transaction
> Worker Thread 608 : Started SQL Tran
> MIALDCS-1.Island: {? = call dbo.sp_getqueuedarticlesynctraninfo
(N'Island', 44)}
> SQL Command : <exec [dbo].[sp_MSsync_del_Leg_Seat_Map_1] N'MIALDCS-2',
N'Island', 'F2', '101', '2004-07-24 00:00:00.000', '1', 0, 0, ' ', ' ', 0,
12632256, ' ', 'Y', ' ', 'N', 'N', '', '', '', '', '', '', '', '', ' ', ' ',
' ', 'E8613112-29DC-4563-B3F0-58665C4967B9', 1>
> (hundreds more records follow)
>
|||I don't see anything in the log that indicates failure. It seems that the
agent just restarts. The event viewer simply says "the remote procedure call
failed and did not execute".
"Hilary Cotter" wrote:

> what command is it failing on?
> The problem is probably related to the execution of a single proc, which is
> locking on the publisher.
>
> --
> Hilary Cotter
> Looking for a book on SQL Server replication?
> http://www.nwsu.com/0974973602.html
>
> "LeeH" <LeeH@.discussions.microsoft.com> wrote in message
> news:055E41A9-DA76-403B-8D93-3F4C32BA6DDE@.microsoft.com...
> two servers running SQL Server 2000 SP3, all agents running on the
> publisher. Every now and then, the Queue reader fails. I enable logging and
> attempt restart. The output file looks normal to me; several queries for
> queued data, but then it seems to timeout. It just sits there for 3 minutes,
> then fails and retries. I can successfully query the other server, so I know
> it's not a communications problem. The event viewer simply says "the remote
> procedure call failed and did not execute". I can't find any other error
> messages.
> master.dbo.sysprocesses where [program_name] = 'Queue Reader Main
> (distribution)'
> MSqreader_agents
> SERVERPROPERTY('IsClustered')
> dbo.sp_MShelp_profile 3, 9, N''
> master.dbo.sp_MSenum_replsqlqueues N'distribution'
> PM]MIALDCS-1.distribution: exec dbo.sp_MShelp_subscriber_info N'MIALDCS-1',
> N'MIALDCS-2'
> N'Island', N'Island')}
> dbo.sp_helpdistpublisher @.publisher = N'MIALDCS-1'
> [2LhOShgh_agC2<T]?LH.h-5--09M--] of [SQL Queue]
> (N'Island', 44)}
> N'Island', 'F2', '101', '2004-07-24 00:00:00.000', '1', 0, 0, ' ', ' ', 0,
> 12632256, ' ', 'Y', ' ', 'N', 'N', '', '', '', '', '', '', '', '', ' ', ' ',
> ' ', 'E8613112-29DC-4563-B3F0-58665C4967B9', 1>
>
>