Trigger Not Being Called

Aug 20, 2007

My package inserts rows into tables with triggers.

The triggers are not being called.

What might be causing this?

View 1 Replies


ADVERTISEMENT

What Is This Called?

Mar 11, 2008

Hi,
I just want to know how do you called when you are accessing another pc thru \. I forgot how it is called.

Second, I like to know what [MACH] and [INST]. They don't look like directories.

\MultforestHEALTH[MACH][INST]HEALTH_WAREHOUSEDeploy_20080228p_Vitals_FACT.sql'

View 9 Replies View Related

Called Web Page From DTS

Jan 16, 2004

How can I execute or access a web page from a DTS package?

Both SQL server AND website are hosted on the same server (a Dual 2.4Gz Xeon with 2Gb RAM, RAID 5 etc)

I have 2 tables in SQL server 2000 that hold orders. These need to be posted into another table at a predefined time (ie: 4:30pm) and at the same time, access a remote address (a web service) and post certain elements of the order back.

Basically, can anyone help me out on how to execute a web page from a DTS.

I do NOT want to access a DTS from a webpage, which is all I'm finding at the moment.

View 5 Replies View Related

Coinitialization Has Not Been Called

Oct 17, 2001

Hello,
Question is, when I try to create relationships in SQL 7 without using the wizard..upon adding the tables I get an errror message that says "Coinitialization has not been called". What does this mean?

View 1 Replies View Related

How Do I Specify More Than I Argument In A Called SP?

Jan 24, 2007

CREATE PROCEDURE sp_getT
@m1 int ,
@txn int ,
@Pan varchar(50) ,
@Act varchar(50) OUTPUT,
@Bal Decimal(19,4) OUTPUT,
@CBal Decimal(19,4) OUTPUT
AS

declare @pBal money, @pCbal money, @pAct money
SET NOCOUNT ON


IF @m1 = 200
BEGIN
IF @txn = 31
BEGIN
exec ChkBal @Pan, @pBal output, @pCbal output, @pAct out
END
END

SET @Act = @pAct
SET @Bal = cast(@pBal as Decimal(19,4))
SET @CBal = cast(@pCBal as Decimal(19,4))

return @Act
return @Bal
return @CBal

the above code returns this error message

"Server: Msg 8144, Level 16, State 2, Procedure CheckBalance, Line 0
Procedure or function ChkBal has too many arguments specified."


How do i specify all the arguments i want in the called procedure?

View 14 Replies View Related

What Is This Methodology Called

Jul 31, 2007

Hi everyone -

I'm stumped on what to cal this, there might even be
a method or pattern named for what i am trying to accomplish...

In the database, a number field is included on each table

When the DAL reads the record from the database, it is passed to
the client - work is possibly done to the record and is sent
back to the DAL for update.

A query is done against the table to retrieve the record again,
the numbers are compared - if they don't match, it is assumed the record
been modified by another user/thread/activity. An error is returned to the client stating the data has been changed.

if the numbers match, the record is updated with the number field being incremented by one.

what is this methodology called (beside crap :-) )


thanks
tony

View 7 Replies View Related

Need A So-Called SSN Encryption

Mar 30, 2006

Hello, perhaps you guys have heard this before in the past, but here iswhat I'm looking for.I have a SQL 2000 table with Social security numbers. We need tocreate a Member ID using the Member's real SSN but since we are notallowed to use the exact SSN, we need to add 1 to each number in theSSN. That way, the new SSN would be the new Member ID.For example:if the real SSN is: 340-53-7098 the MemberID would be 451-64-8109.Sounds simply enough, but I can't seem to get it straight.I need this number to be created using a query, as this query is areport's record source.Again, any help would be appreciated it.

View 9 Replies View Related

SelectedIndexChanged Not Being Called

Jan 19, 2007



Hi

I have a drop down list which gets populated from database but I want to add the default value as

--Select----



View 4 Replies View Related

How Triggers Are Called

Apr 22, 2008

This seems like a basic question but I have not been able to find the answer in the help files or by searching this forum.

Is a trigger called for each row updated or is it called once for all rows updated?

for example if I have:



Code Snippet
CREATE TRIGGER mytrigger

ON mytable
AFTER UPDATE
AS
BEGIN

EXEC e-mail-me inserted, N'mytrigger', getdate()
END



and I do this



Code Snippet
UPDATE mytable
SET mycolumn = N'whatever'
WHERE ID > 5 AND ID <= 10



Assuming there is a record for each nteger value of ID, than will mytrigger run 5 times (once for each row updated) or one time (with inserted containing all 5 rows)?

View 3 Replies View Related

UDF Used In SubQuery: Is It Called At EACH Row?

May 6, 2008

Hi,

When a column is evaluated against an UDF in a SELECT ... or WHERE ... It makes sense that the UDF is called for every row of the SELECT. But is it still true if the UDF is called in a subquery as below?





Code Snippet

SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus())
I've made a test and the SQL Profiler Trace shows that the UDF is called only once.

Can anyone confirm if my test is valid and most importantly that the UDF is called only once? FYI, I never use sub queries. This is to clarify a technical detail for our performance investigation.

Thank in advance for any help.


Here is the code to setup the test:
USE NorthWind
GO

CREATE TABLE dbo.UdfTest (
LineID int Identity(1,1) NOT NULL,
AnyText varchar(200) COLLATE database_default NOT NULL
)
GO

INSERT dbo.UdfTest (AnyText) VALUES ('Test1')
INSERT dbo.UdfTest (AnyText) VALUES ('Test2')
INSERT dbo.UdfTest (AnyText) VALUES ('Test3')
GO

CREATE FUNCTION dbo.F_Bogus (
)
RETURNS @tab TABLE (
LineID int NOT NULL,
AnyText varchar(100) COLLATE database_default NOT NULL)
AS
BEGIN
INSERT @tab (LineID, AnyText) VALUES (1, 'UDF1')
INSERT @tab (LineID, AnyText) VALUES (2, 'UDF2')
INSERT @tab (LineID, AnyText) VALUES (3, 'UDF3')
INSERT @tab (LineID, AnyText) VALUES (4, 'UDF4')
INSERT @tab (LineID, AnyText) VALUES (5, 'UDF4')

RETURN
END
GO

Here is the capture of SQL Profiler when executing the statement:
SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus())

SQL:BatchStarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SQLtmtStarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SPtarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (1, 'UDF1') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (2, 'UDF2') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (3, 'UDF3') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (4, 'UDF4') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (5, 'UDF4') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus RETURN 51 2008-05-06 17:58:31.577
SQLtmtCompleted SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SQL:BatchCompleted SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543

View 5 Replies View Related

How To Check Which Tables Were Called?

Oct 12, 2005

Hello everyone:

I have some nightly jobs that execute stored procedure to call the tables? I want to know which table are called by these stored procedures. Is it possible? Any idea will be appreciated.

Thanks

ZYT

View 5 Replies View Related

Procedure Sp_sqlagent_log_jobhistory Not Being Called

Oct 13, 2007



I am encountering an issue which is effecting our production environment, none of our sql jobs are now saving any kind of job history, nor are the status of the jobs being saved.
I have run a profiler trace and it seems as if procedure : sp_sqlagent_log_jobhistory is not being called during the execution of any of our jobs
Has anyone else encountered anything similar?

View 3 Replies View Related

SP Not Working Correctly? When Called From App

May 3, 2006

Hi

In a stored procedure the following code snippet 1 checks against duplicate data being inserted. I've tested it with snippet 2 and it works as expected. However, when the procedure is called from ASP.NET the check seems ineffective. I still get the error msg. The application uses a SqlDataSource with the following parameters.

Any suggestions?

Thanks,

Bakis.

PS I want to ask a question on the ASP.NET forum .The login/pwd for this forum "get me in" to the .net forum in the sense that when I log in I see a logout link. I don't get an "ask a question" button though. Is there a separate screening for each forum?

<UpdateParameters>

<asp:Parameter Name="CatItemUID" Type="Int32" />

<asp:Parameter Name="CatName" Type="String" />

<asp:Parameter Name="Item" Type="String" />

<asp:Parameter Name="Quad" Type="Int16" />

<asp:Parameter Name="UID" Type="Int64" />

</UpdateParameters>



snippet 1 :

if (@CatItemComboExists > 0 )
BEGIN
--print @CatItemComboExists
return 0
END

snippet 2:

begin tran
declare @return_status int
EXECUTE @return_status = spUpdateCatItemRec 343, 'blah','blih', 2,3
print @return_status
rollback

error msg only if proc is called from app

Violation of UNIQUE KEY constraint 'IX_tblCatItemUID'. Cannot insert duplicate key in object 'tblCatItemUID'.

View 3 Replies View Related

Need To Find Out The Name Of My Stored Proce Being Called. How Can I Do This?

Oct 12, 2006

I am maintaining some C# and ASP.NET code with SQL server 2000. My code calls a stored procedure. The code is a little confusing as to the name of the SQL Server stored procedure that is calling. At this point I don't know how to trace into or debug the stored procedure. Kind of hard to do in the first place when you are not absolutely certain as to the stored proc to be called.I can take an educated guess as to which stored procedure is being called. I figure if I can deliberately make a certain stored procedure fail then this might be able to somehow give me the name of the stored proc that I am calling.So is there a way to do this. Namely make a stored procedure fail, or to return the name of the stored Proc?I would sincerely appreciate some help with this problem.

View 1 Replies View Related

SqlDataSource And Stored Procedure Not Getting Called

Feb 23, 2007

Im using a SqlDataSource control. Ive got my "selectcommand" set to the procedure name, the "selectcommandtype" set to "storedprocedure"What am i doing wrong ?  Ive got a Sql 2005 trace window open and NO sql statements are coming through  "ds" runat="server" ConnectionString="&lt;%$ ConnectionStrings:myConnectionString %>" SelectCommand="my_proc_name" SelectCommandType="StoredProcedure">

"txtF1" Name="param1" Type="String" />
"txtF2" Name="param2" Type="String" />
"" FormField="txtF3" Name="param3" Type="String" />
"" FormField="txtF4" Name="param4" Type="String" />



  

View 2 Replies View Related

Store Procedure Called - Timeout

Sep 12, 2005

Hi All,I have a report ASP.NET page that allow users to run a report by clicking a buttion to call a store procedure to generate the report, however, the store procedure is taking a few minutes to return the data, thus I got the 'timeout' error message on my page. How do I extend the time on my page?Thanks

View 3 Replies View Related

How-to Return Calculated Values From A Called SP

Dec 11, 2001

Can someone please reply w/ example syntax on how to receive calculated variables from an invoked SP. DESCRIPTION:

sp_caller invokes sp_calc_values (passing @var1, @var2) via:
exec sp_calc_values @var1, @var2

sp_calc_values receives @var1, @var2 then calculates @var3, @var4

HOW does sp_caller receive the calculated values @var3, @var4 ???

thx in advance

View 2 Replies View Related

Different Behaviour Of A SP Called From SQL Query And From MS Access

Feb 2, 1999

Hi,
Please help me to elucidate a mistery !

I have a little SP in a database:

CREATE PROCEDURE XXXTest AS

DECLARE @a varchar(50)

SELECT @a = NULL

IF @a NOT IN ('x', 'y')
BEGIN
RAISERROR ('Error',16,1)
RETURN 0
END
RETURN 1

If I execute it from SQL Server, it returns 0. (after the error, of course).
If I execute it from MS ACCess through a Pass Through Query, it returns 0.
On the same server !!!
How could it to make me that ? I have been thought the SP is executed entirely on the server !!!

Thanks in advance clearing me the mind.
Mircea.

View 2 Replies View Related

What Is Called In Sqlserver For RPAD And LPAD?

May 31, 2001

Running sqlserver 2000
In oracle, it is called rpad and lpad for adding character to the left of
the output string or right of the output string.

Example,

I am selecting a zip_code 10200 and it truncates last 2 zeros when I
run select on the table.

If I just run select zip_code from test;

I will receive following result in oracle.

102


So, I run select rpad(zip_code,5,'0') from test;

This will add last two zeros to the the string.


Result in Oracle;
10200

How can you do this in sqlserver?

Please let me know.

Thanks,
Ranjan

View 2 Replies View Related

SP Skips Execution Of Child SP When Called From C#

Sep 14, 2005

Hello all. I have a stored procedure that seems to skip the execution of an entire line of code (which happens to be a call to execute another stored procedure), but ONLY if it is being used from C# (using the System.Data.SqlClient namespace... object: SqlCommand, etc).

Basic structure:

Event SP: top-most parent
-->Calls UpdateXs SP: This is the SP that will not call his child SP
----->Calls UpdateX: This is the SP that is being ignored when called from .NET (In a loop, each iteration, max iterations 10).

(1) I can call the top-most stored procedure (Event SP) with the same arguments in Query Analyzer and all SP's will execute.
(2) I can call UpdateXs SP with the same arguments that are being passed to it from Event SP in the Query Analyzer, and again, it's child sp executes (UpdateX).
(3) I can also call the last child (UpdateX) directly in Query Analyzer with the same arguments that are passed in production (from executing the top-most parent in C#), and it executes correctly.

I'm positive that at no point the last child (UpdateX) is being passed NULL values. I made debug tables and before execution of an SP from within another SP, I store all the arguments in a debug table--none are null. Also, to figure out what was wrong with the last child (UpdateX) , the first statement in inserts into another debug table, just to show that that execution has made it into the sp--when the top parent is called from C#, it doesn't insert into my table (doesn't execute).

There are statements inside Event SP that execute after the sp call to UpdateXs SP. These statement always execute. Also, there are statements inside UpdateXs SP that execute after the sp call to the last child. These statement always execute too.

I am now clueless. I had developed & debugged all sp's in Query Analyzer before trying to use it live (with the C#). It's always fine in Query Analyzer, but ALWAYS skips the last sp in production.

Is there some fundamental principle I am missing here in MS SQL stored procedures? I am only 3 levels deep in SP calls, so I didn't think that would be an issue (I have made SP's that went a LOT deeper in calls than that in the past with no issues).

Any insight much appreciated. Thanks in advance.

View 2 Replies View Related

Creating A VIEW Called Vw_HoursWorked

Jan 27, 2007

Hello,

I am a student and is currently busy with an SQL project. I am having trouble with creating a view to calculate and display the hours worked for each call rate..

It goes...

I have two tables: rate and consultancydetail.

The rate table consists of columns named - id, time descripiton and rate.

The consultancydetail table - invoiceID, rateID date, startTime and endTime.

My view should display the rateId column and then there should be a column created in the view for the total hours.

total hours is calculated by adding the difference between startTime and endTime and then added to each total for each rateId.

PLEASE CAN SOMEONE HELP. I am new to this and know it should be a simple thing.

cheers,
Arend

View 5 Replies View Related

Creating A View Called Vw_ProductAverage

Jan 31, 2007

Hi,

I have to create a view that displays the average quantity used per invoice for each product. and substitute NULL values with zeros.

Please I need help and will appreciate any!

I have a MATERIALDETAIL table with columns invoiceID, productCode and Quantity.

THIS IS WHAT I HAVE SOFAR:
*************************
create view vw_ProductAverage
as
select distinct product_code
from materialdetail
go

select * from vw_productAverage
go

***************************

PLEASE help.

View 2 Replies View Related

FoxPro Index Called From SQL Server

Jul 20, 2005

Hi,I have a large FoxPro table with an index that I need to be Queried from SQLServer by OLE.DB or ODBC. If I query the DBF directly a search takes 1Minute +. Is there a way I can call the data from the table and use theexisting FoxPro Index?ThanksSteve

View 1 Replies View Related

Configuration Settings In A DLL Called From SSIS

May 27, 2008

OK, here's the scenario:

I have some libraries (DLL) that I call from a regular console application. The data access methods get the connection string from the app.config, nothing special there.

The thing is: now I need to use the libraries inside a SSIS package. I call them from a script task, and everything is fine, except for the connection string.

Is there a way that I can get the connection string from the SSIS package configuration like I would from the app.config? Maybe some alternative to ConfigurationManager.AppSettings["ConnString"] in the DTS Runtime?

Thanks in advance...

View 3 Replies View Related

Pre And PostExecute Event Handler Called More Than Once

Feb 10, 2006

I have a task configured on the post execute event handler of a package expecting this task to be executed only once after the completion of all the other tasks in the package. But I found the task configured on the post execute event of the package getting executed as many times as the number of tasks in the package + 1 . Is there any workaround for this problem?

View 1 Replies View Related

RAISERROR Of A SPROC Fails The SQl Job, From Which It Is Called

Apr 3, 2008



Hi All,

I have a Stored Procedure, which has a RAISERROR statement with LOG. I am calling this SP from a Job. Whenever the RAISERROR is executed, it also fails the job.. How should this be handled? The article:

http://support.microsoft.com/kb/309802 says that this has been fixed in SP4, but I am working on SQL Server 2000 SP4, but still it persists here. Can anyone please help me resolve issue? Can this be handled in Code? Or, Is it confirmed that even SP4 has not fixed this? Or is this a known issue and we need to live with it?

Thanks a lot,

Manoj Deshpande.

View 3 Replies View Related

Bcp Fails When The Called SP Has An Update Statement

Jan 24, 2008

This is a very weird problem. SQL 2000. A bcp calls an SP:

bcp "exec MyDB.dbo.usp_DF_NA_Analytics_OOW" queryout SomeFile.dat -T -c -t "|" -S "MySvrMyInst"

SP code:
----------------------------
CREATE PROCEDURE dbo.usp_DF_NA_Analytics_OOW AS
BEGIN
SET NOCOUNT ON

--Declare Variables
DECLARE @CURRENTDATE DATETIME
DECLARE @BEGINTIME DATETIME
declare @feedname varchar(50)
set @feedname = 'DF_NA_Analytics_OOW'
SET @CURRENTDATE = CURRENT_TIMESTAMP

-- ensure there is a row for us - create 1 if it doesn't exist
exec usp_datafeed_timestamp_init @feedname

SET @BEGINTIME = (
SELECT LastRunTime
FROM NewAccounts.dbo.DataFeed_Timestamp
WHERE TaskName = @feedname
)

select oowReason.OOWTransaction_id,
oowReason.Position,
oowReason.ReasonCode,
oowTx.UpdateDateTime
from OOWTransaction oowTx (nolock)
join OOWReason oowReason (nolock)
on oowReason.OOWTransaction_id = oowTx.OOWTransaction_id
WHERE oowTx.UpdateDateTime >= @BEGINTIME and oowTx.UpdateDateTime < @CURRENTDATE
ORDER BY oowReason.OOWTransaction_id, Position

-- update the timestamp
exec usp_UPD @feedname, @currentdate
end
------------------------------


ALTER procedure dbo.usp_UPD (@feedname varchar(50), @lastruntime datetime)
as
begin
set nocount on


if not exists (select * from dbo.datafeed_timestamp where lower(taskname) = lower(@feedname))
INSERT INTO Datafeed_Timestamp(TaskName, LastRunTime) VALUES(@feedname, @lastruntime )
else
update Datafeed_Timestamp
set LastRunTime = @lastruntime
where TaskName = @feedname
end
----------------------------------------

The above bcp fails consistently unless the "exec usp_UPD" is completely removed.
Even if I substitute it with the update stmt instead of the SP call, it still fails.

I move the usp_UPD call and move it above the select making the select as the last command in the SP -- still fails.
Removed Order by -- still fails.

The weird thing is -- several other SPs that follow the same exact format (only select query is different) - they all succeed everytime.

This above bcp fails everytime unless the usp_UPD is fully removed.
I have tried putting the result dataset into a table variable and select it in the end -- still fails. several other attempt to workaround - fails -- by fails I mean "0 rows returned" from bcp -- when the UPD is removed, it returns the correct dataset. Otherwise always returns 0 rows.

Outside bcp, if I simply execute the SP from QA, it returns the correct dataset everytime. From bcp, it just doesn't like it. It returns 0 rows everytime, but does the UPD task -- the value does get updated adter execution.

Any thoughts/ideas? This thing is driving me NUTS


Thanks,
Rajesh

View 1 Replies View Related

DeriveParameters Throws When Called Against A C# Function?

Aug 24, 2006

When I call DeriveParameters against a function written in SQLCLR function it throws an exception. I've been working on this a little while and haven't found a fix. I understand that I could write additional code to do the same work DeriveParameters does, but it seems like this should work.

This is the exception thrown:


[InvalidOperationException: The stored procedure 'GSI.Utils.IsMatch' doesn't exist.]

The function is defined as


CREATE FUNCTION [Utils].[IsMatch](@Value [nvarchar](4000), @RegularExpression [nvarchar](4000))
RETURNS [bit] WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [RegularExpressionsHelper].[UserDefinedFunctions].[IsMatch]

The C# function is defined as:


[Microsoft.SqlServer.Server.SqlFunction(IsDeterministic=true)]
public static SqlBoolean IsMatch(SqlString Value, SqlString RegularExpression)
{
Regex rx = new Regex( RegularExpression.ToString() );
string s = Value.ToString();

return new SqlBoolean(rx.IsMatch(s));
}

This is the code I'm using to call DeriveParameters:


static void Main(string[] args)
{
using (SqlConnection conn = new SqlConnection(m_GetConnectionString()))
{
conn.Open();

SqlCommand myCommand = new SqlCommand("GSI.Utils.IsMatch", conn);
myCommand.CommandType = System.Data.CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(myCommand);
}
}

I found that DeriveParameters seems to call sp_procedure_params_managed and when I call it myself it returns the parameters correctly for T-SQL functions, but returns no records when I specify a SQLCLR function.


DECLARE @procedure_name sysname;
DECLARE @group_number int;
DECLARE @procedure_schema sysname;
DECLARE @parameter_name sysname;

SET @procedure_name = 'IsMatch';
SET @group_number = 1;
SET @procedure_schema = 'Utils';
SET @parameter_name = null;

DECLARE @RC int

EXECUTE @RC = [GSI].[Sys].[sp_procedure_params_managed]
@procedure_name
,@group_number
,@procedure_schema
,@parameter_name


I'm able to execute the function without issue and I'm able to use DeriveParameters against everything in the database except C# based functions (and I've tried others besides IsMatch). I'm attempting to run DeriveParameters from a console application and from ASP.NET, both running .NET 2.0.

I've experienced the same behavior in these versions:


SQL Server 2005 Enterprise Edition RTM (MSDN Image on Virtual Server)
SQL Server 2005 Enterprise Edition SP1 (MSDN Image on Virtual Server)
SQL Server 2005 Enterprise Edition SP1 + Hotfix kb918222 (MSDN Image on Virtual Server)
SQL Server 2005 Developer Edition SP1

Has anyone else seen similar behavior?

Any advice would be greatly appreciated -- Thanks

Steve

View 4 Replies View Related

Sender Activation Procedure Never Gets Called

Jan 25, 2008



Hi,

I have implemented the code from the 'Recycling Conversations' post that Remus Resanu has posted. For some reason my sender activation procedure never gets called. I thought it was working at one point but now can not get it to work. Messages are being sent correctly from sender to receiver but the c_audit_send_queue_activation procedure never gets called.

According to my code that calls 'begin conversation timer(@dlg) timeout=30;' I would think that after 30 seconds that my activated procedure would get called with a DialogTimer message but it does not. Nor does the activation procedure on the sender get called when I manually end conversations on the receiver side.

Thanks in advance for any help.


Here is my send procedure:



Code Snippet
create procedure [dbo].[c_audit_p_send_message]
@msg nvarchar(max)
as
begin
if @msg is not null
begin
begin try
set nocount on;
declare @dlg uniqueidentifier
declare @counter int;
declare @error int;
declare @errid bigint, @dbname nvarchar(128)
set @counter = 1;
begin transaction;
while(1=1)
begin
select @dlg = dialog_id from dbo.audit_dialog with(holdlock) where audit_dialog_id_X = @@spid
if @dlg is null
begin
begin dialog conversation @dlg
from service [tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender]
to service '//TyMetrix360Audit/DataWriter','7A9690F7-11A5-4ABB-ACBA-EECC1A58ACB7'
on contract [//TyMetrix360Audit/Contract] with encryption = off;
begin conversation timer(@dlg) timeout=30;
insert into dbo.audit_dialog(audit_dialog_id_X, dialog_id) values(@@spid, @dlg)
end;
send on conversation @dlg message type [//TyMetrix360Audit/Message] (@msg)
set @error = @@ERROR;
if @error = 0
begin
break;
end
set @counter = @counter + 1;
if @counter > 10
begin
raiserror(N'Failed to SEND on a converstation for more than 10 times.',16,1) with log;
insert into audit_error (error_procedure, error_line, error_number, error_message, error_severity, error_state, audited_data)
select error_procedure(), error_line(), error_number(), error_message(), error_severity(), error_state(), @msg
break;
end
delete from dbo.audit_dialog where dialog_id = @dlg;
set @dlg = null;
end
commit transaction;
end try
begin catch
insert into audit_error (error_procedure, error_line, error_number, error_message, error_severity, error_state, audited_data)
select error_procedure(), error_line(), error_number(), error_message(), error_severity(), error_state(), @msg
select @errid = scope_identity(), @dbname = db_name()
raiserror (N'Error while sending Service Broker message to TyMetrix360Audit. Error info can be found in ''%s.dbo.AUDIT_ERROR'' table with id: %I64d', 16, 1, @dbname, @errid) with log;
end catch
end
end
GO


here is the activatation procedure:




Code Snippet
create procedure [dbo].[c_audit_p_send_queue_activation]
as
begin
declare @dlg uniqueidentifier
declare @msgtype sysname
declare @msg varbinary(max)
begin transaction;
receive top(1) @dlg = conversation_handle, @msgtype = message_type_name, @msg = message_body from dbo.TyMetrix360AuditQueue
if @dlg is not null
begin
delete from audit_dialog where dialog_id = @dlg
if @msgtype = N'http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer'
begin
send on conversation @dlg
message type [//TyMetrix360Audit/Message/EndConversation] ('');
end
else if @msgtype= N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
begin
end conversation @dlg
end
else if @msgtype = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
begin
end conversation @dlg
declare @error int;
declare @description nvarchar(4000);
with xmlnamespaces ('http://schemas.microsoft.com/SQL/ServiceBroker/Error' as ssb)
select @error = cast(@msg as xml).value('(//ssb:Error/ssb:Code)[1]', 'int'), @description = cast(@msg as xml).value('(//ssb:Error/ssb:Description)[1]', 'nvarchar(4000)')
raiserror(N'Received error Code:%i Description:''%s''', 16, 1, @error, @description) with log;
insert into audit_error (error_procedure, error_line, error_number, error_message, error_severity, error_state, audited_data)
select error_procedure(), error_line(), error_number(), error_message(), error_severity(), error_state(), @msg
end
end
commit transaction;
end










and here is the code that creates the service broker on the sender:




Code Snippet
if exists (select * from sys.routes where name = 'TyMetrix360Route') drop route TyMetrix360Route
if exists (select * from sys.services where name = N'tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender') drop service [tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender]
if exists (select * from sys.service_queues where name = N'TyMetrix360AuditQueue') drop queue TyMetrix360AuditQueue
if exists (select * from sys.service_contracts where name = N'//TyMetrix360Audit/Contract') drop contract [//TyMetrix360Audit/Contract]
if exists (select * from sys.service_message_types where name = N'//TyMetrix360Audit/Message') drop message type [//TyMetrix360Audit/Message]
if exists (select * from sys.service_message_types where name = N'//TyMetrix360Audit/Message/Blob') drop message type [//TyMetrix360Audit/Message/Blob]
if exists (select * from sys.service_message_types where name = N'//TyMetrix360Audit/Message/EndConversation') drop message type [//TyMetrix360Audit/Message/EndConversation]
GO
create route TyMetrix360Route authorization dbo with
service_name='//TyMetrix360Audit/DataWriter',
broker_instance='7A9690F7-11A5-4ABB-ACBA-EECC1A58ACB7',
address='TCP://SFT3DEVSQL01:4022'
create message type [//TyMetrix360Audit/Message] validation=none;
create message type [//TyMetrix360Audit/Message/Blob] validation=none;
create message type [//TyMetrix360Audit/Message/EndConversation] validation=none;
create contract [//TyMetrix360Audit/Contract]([//TyMetrix360Audit/Message] sent by initiator, [//TyMetrix360Audit/Message/Blob] sent by initiator, [//TyMetrix360Audit/Message/EndConversation] sent by initiator);
create queue dbo.TyMetrix360AuditQueue
alter queue dbo.TyMetrix360AuditQueue with activation(status=on,max_queue_readers=1,procedure_name=[c_audit_p_send_queue_activation],execute as owner);
create service [tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender] authorization dbo on queue dbo.TyMetrix360AuditQueue
grant send on service::[tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender] to public
GO

View 3 Replies View Related

Update Stored Procedure Not Working When Called From C#

Jul 11, 2007

OK, I have been raking my brains with this and no solution yet. I simply want to update a field in a table given the record Id. When I try the SQL in standalone (no sp) it works and the field gets updated. When I do it by executing the stored procedure from a query window in the Express 2005 manager it works well too. When I use the stored procedure from C# then it does not work:
 1. ExecuteNonQuery() always returns -1 2. When retrieving the @RETURN_VALUE parameter I get -2, meaning that the SP did not find a matching record.
So, with #1 there is definitely something wrong as I would expect ExecuteNonQuery to return something meaningful and with #2 definitely strange as I am able to execute the same SQL code with those parameters from the manager and get the expected results.
Here is my code (some parts left out for brevity):1 int result = 0;
2 if (!String.IsNullOrEmpty(icaoCode))
3 {
4 icaoCode = icaoCode.Trim().ToUpper();
5 try
6 {
7 SqlCommand cmd = new SqlCommand(storedProcedureName);(StoredProcedure.ChangeAirportName);
8 cmd.Parameters.Add("@Icao", SqlDbType.Char, 4).Value = newName;
9 cmd.Parameters.Add("@AirportName", SqlDbType.NVarChar, 50).Value = (String.IsNullOrEmpty(newName) ? null : newName);
10 cmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
11 cmd.Connection = mConnection; // connection has been opened already, not shown here
12 cmd.CommandType = CommandType.StoredProcedure;
13 int retval = cmd.ExecuteNonQuery(); // returns -1 somehow even when RETURN n is != -1
14 result = (int)cmd.Parameters["@RETURN_VALUE"].Value;
15
16 }
17 catch (Exception ex)
18 {
19 result = -1;
20 }
21 }

 And this is the stored procedure invoked by the code above:1 ALTER PROCEDURE [dbo].[ChangeAirfieldName]
2 -- Add the parameters for the stored procedure here
3 @Id bigint = null,-- Airport Id, OR
4 @Icao char(4) = null,-- ICAO code
5 @AirportName nvarchar(50)
6 AS
7 BEGIN
8 -- SET NOCOUNT ON added to prevent extra result sets from
9 -- interfering with SELECT statements.
10 SET NOCOUNT ON;
11
12 -- Parameter checking
13 IF @Id IS NULL AND @Icao IS NULL
14 BEGIN
15 RETURN -1;-- Did not specify which record to change
16 END
17 -- Get Id if not known given the ICAO code
18 IF @Id IS NULL
19 BEGIN
20 SET @Id = (SELECT [Id] FROM [dbo].[Airports] WHERE [Icao] = @Icao);
21 --PRINT @id
22 IF @Id IS NULL
23 BEGIN
24 RETURN -2;-- No airport found with that ICAO Id
25 END
26 END
27 -- Update record
28 UPDATE [dbo].[Airfields] SET [Name] = @AirportName WHERE [Id] = @Id;
29 RETURN @@ROWCOUNT
30 END

 As I said when I execute standalone UPDATE works fine, but when approaching it via C# it returns -2 (did not find Id).

View 2 Replies View Related

Field That Will Automatically Be Increased By 1 Whenever SELECT Is Called. How To Do It?

Jan 9, 2004

i have a field Count that i want it to be automatically increased by 1 whenever a SELECT stament is called. i come out with the following sql query and it works on SQL Query Analyzer:

declare @count int
select @count = count+1 from pictures_posts where itemtype='3'
update pictures_posts set count=@count where itemtype='3'
select postID, color, count from pictures_posts where itemtype='3'
go


but i am thinking it must be a much better to do this. can you guys help?

View 5 Replies View Related

Create A Database Called DBA_Status (was Question!!)

Feb 24, 2005

Is it possible to create a database on a server called DBA_Status, and keep status of every database and servers that you are responsible for or do I have to created a DBA_Status on every server that I am responsible for???

Thanks

View 1 Replies View Related

Anyone Heard Of Product For Sqls Called MyDTS?

Oct 14, 2005

Who makes this? It's some sort of dts writer/scheduler I think.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved