Trigger Not Executing CLR Code/stored Proc

May 7, 2008

I have a database trigger that is set to call a CLR trigger/stored proc when a certain field in a table is updated. The issue is that if i execute the stored proc manually in enterprise studio, it works perfectly but the same call made through the trigger does not go through. A few more details -


I have CLR integration enabled on the sql server.

The dbo has UNSAFE ASSEMBLY rights

I have the both the assembly and the serialized dll imported in the database.


Here's the definition of the stored proc -


CREATE PROCEDURE [dbo].[WriteXMLNotification]

@TaskID [nvarchar](20)

WITH EXECUTE AS CALLER

AS

EXTERNAL NAME [DataInterfaceWebServices].[TaskUpdateXMLWriter.WriteXMLNotification].[run]



and the trigger -



CREATE TRIGGER [dbo].[tr_Task_U]

ON [dbo].[_Task]

FOR UPDATE, INSERT AS

IF UPDATE (TaskType_Status) OR UPDATE (TaskType) OR UPDATE (TaskType_SubType1)

BEGIN

SET NOCOUNT ON;

DECLARE @status AS INT

DECLARE @taskType AS INT

DECLARE @taskSubType AS INT

DECLARE @taskID as sysname

DECLARE @cmd as sysname

DECLARE @parentTask as sysname

DECLARE @NotificationXMLTaskID as sysname



SELECT @status = [TaskType_Status] FROM inserted

SELECT @taskType = [TaskType] FROM inserted

SELECT @taskSubType = [TaskType_SubType1] FROM inserted

SELECT @taskID = [TaskID] FROM inserted

SELECT @parentTask = [Parent_TaskID] FROM inserted

SELECT @NotificationXMLTaskID = [MCCTaskID] FROM _TaskNotificationXML WHERE [MCCTaskID] = @parentTask



IF (@status = 2602) AND (@taskType = 2282) AND (@taskSubType = 19500)

BEGIN

exec WriteXMLNotification @taskID;

END

ELSE IF (@taskType = 2285) AND (@parentTask IS NOT NULL) AND (@NotificationXMLTaskID IS NOT NULL)

BEGIN

exec WriteXMLNotification @parentTask;

END



END


I stepped into the trigger and it seems to execute the line " exec WriteXMLNotification @taskID;" but nothing happens, but if I run that same line manually, it works. Could it be that the impersonation by the EXECUTE AS clause is causing it to fail?

Please advise!

Thanks in Advance,
-Mihir Sonalkar.

View 1 Replies


ADVERTISEMENT

Problem Executing A Stored Proc

Mar 25, 2005

Hi All,
 I have stored proc that processes about 60,000 rows using a cursor. When I call the SP from Query Analyzer, I get the following error message after processing about 12,000 records :
 
Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (InvalidParam()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
ODBC: Msg 0, Level 16, State 1
Communication link failure
 
Connection Broken
 
 
12614 records
 
What can i do to make this SP run sucessfully ? I even tried using a table variable instead of a cursor, but got the same result.
 
THE output from SP_CONFIG is
Option                                                                                                config_value
----------------------------------------------------------------------------------------------------------------------------------







affinity mask
0

allow updates
0

awe enabled
0

c2 audit mode
0

cost threshold for parallelism
5

Cross DB Ownership Chaining
0

cursor threshold
-1

default full-text language
1033

default language
0

fill factor (%)
0

index create memory (KB)
0

lightweight pooling
0

locks
0

max degree of parallelism
0

max server memory (MB)
2147483647

max text repl size (B)
65536

max worker threads
255

media retention
0

min memory per query (KB)
1024

min server memory (MB)
0

nested triggers
1

network packet size (B)
4096

open objects
0

priority boost
0

query governor cost limit
0

query wait (s)
-1

recovery interval (min)
0

remote access
1

remote login timeout (s)
20

remote proc trans
0

remote query timeout (s)
0

scan for startup procs
0

set working set size
0

show advanced options
1

two digit year cutoff
2049

user connections
0

user options
0
 
 

View 1 Replies View Related

Executing A Stored Proc From DTS Package

Oct 1, 2005

My current task in my company is...

I got a Spreadsheet from which i have to get the data into a "Staging Table" and from there the data has to go into 10 different Tables in my database..

I had created a DTS package using ActiveX script and written a Stored Proc to get the records from Staging table to Database tables...every thing is working fine... but...


they asked me to send "TapeType' and "DealName" into two fields and "current datetime" into one more field of the stagingtable fields which are not present inthe Spreadsheet....

so in the Activex script i hard coded... destination"TapeType"= "BidTape" and destination"DealName"= "ABCD" and its working...
and for currentdate i had defined a DTS Task and in that i had written a SQL stmts..
update table....
set currentdate = getdate()
where TapeType = 'BidTape' ..... which is also working....but the problem is

if i got one more spread sheet with same "TapeType" i.e. BidTape but with different "DealName" i.e. "XYZ".... every thing is working out but....the Currentdate field is getting updated every where with as one date..???
can u suggest me a better solution here.....

and after this Iam planning to create one more Task to Execute the Proc..... but I have to pass 2parameters i.e. "Dealname" and "TapeType"... they want every thing to be get done with single mouse click...

can u suggest me here how to pass these 2parameters in the DTS package,..

I will be waiting for any one your valuable suggestions....

View 3 Replies View Related

Executing Stored Proc Across Network

Mar 17, 2004

I am trying to execute stored procedures accross a network, which return recordsets. The problem I'm having is as follows:

I need to return the recordset with cursor type adOpenStatic and not adOpenForwardOnly, which is the default when using the execute command. So I decided to use the open cammand instead which seemed to work.

the probelm is that it takes a really long time to process the open command, but the execute is very fast. Does anyone know why this might be?

Here is the code which I am using:


bool SOMEFUNCTION( ..... )
_CommandPtr objCmd = NULL;
objCmd.CreateInstance(__uuidof(Command));
bool retval = true;

try
{
objCmd->ActiveConnection = connection;
objCmd->CommandText = "sp_as_played_list";
objCmd->CommandType = adCmdStoredProc;
recordset->CursorLocation = adUseClient;

// WORKS VERY SLOWLY - get to have Static cursor
recordset->Open( (IDispatch *)objCmd, vtMissing, adOpenStatic, adLockReadOnly, adCmdStoredProc );

// Or - WORKS VERY QUICKLY - adOpenForwardOnly default cursor
recordset = objCmd->Execute( NULL, NULL, adCmdStoredProc);

if(recordset->State == adStateClosed)
{
retval = false;
}


thanks

aidan

View 1 Replies View Related

Strange Timeout Problem When Executing Stored Proc

Jul 27, 2004

We have a stored procedure that will return at most about 600 records. In almost all cases it works fine, but in a few odd cases the command times out when used from a webform. We changed the CommandTimeout property to 120 seconds... no difference. If we run a query that times out in Query Analyzer, it runs in under 3 seconds (on the SQL Server machine). We also did a lot of profiling, and for any page that runs fine, the query takes about the same time when called from a webform and run in the Query Analyzer.
We ran our tests on the pre-production environment with absolutely no one else on the machines. We also created a test page that just fills a DataSet. Straightforward... get connection object, create command, set params, create data adapter, fill dataset. It suffers the same problem.

The web server and SQL server are two separate machines. Oh, and before I forget... This is SQL 2000. It used to run SQL 7, and all the queries there were (slightly) slower, but none timed out, not even the ones that do now.

Maybe the first question should be:
How can it be that a query that runs fine in Query Analyzer times out from a webform?

View 8 Replies View Related

Executing A Stored Proc On Another Server From A Scheduled Task

Jul 20, 2005

Ok, I thought this one would be easy.I have a stored proc: master.dbo.restore_database_fooThis is on database server B.Database server A backs up database foo on a daily basis as a scheduledtask.What I wanted to do was, at the end of the scheduled task is then call thestored proc on B and restore the database.If I go into Query Analyzer and log into database A, then execb.master.dbo.restore_database_foo works.But if I take the same command and make it part of the scheduled task itfails.Error is:OLE DB provider 'SQLOLEDB' reported an error. [SQLSTATE 42000] (Error 7399)[SQLSTATE 01000] (Error 7312). The step failed.To me this seems like a permissions issue, but nothing I've tried seems tohave helped.Suggestions?----Greg D. MoorePresident Green Mountain SoftwarePersonal: http://stratton.greenms.com

View 3 Replies View Related

Wht Should Be Stored Proc Code??

Jul 25, 2007

Hey all,
I have access as my front end and has upsized to sql server 2000.
DLookup function that was in VBA code before was working fine. but after upsizing there is the problem in that code...
What could be the alternative for DLookup Function in sql server..
Do i have to write a view or stored procedure..?

Any Help appreciated.

View 14 Replies View Related

Stored Proc In SQL Code

Dec 10, 2007

Using SQL Server 2005. Writing SQL code but I need to use the reults from two different stored proc. How do you code a select statement using a stored proc. I know when using views you just use the view name in the From or join statemnt, but do you do the same with using a Stored proc. Thank you for your help. David

View 5 Replies View Related

Map Resultset From Executing A Stored Proc Into Input Columns Of A Data Flow Task

Jul 30, 2007



I need to loop the recordset returned from a ExecuteSQL task and transform each row using a Data Conversion task (or a Script Task).

I know how to loop the recordset returned by an ExecuteSQL task:

http://www.sqlis.com/59.aspx

I loop the returned recordset (which is mapped to a User variable of type System.Object) and assign the Variable Mappings in the ForEach Loop to different user variables which map to the Exec proc resultset (with names and data types).

I assume to now use these as the Available Input columns for the Data Conversion task, I drag a Data Flow task inside the For Each Loop container and double-click it, then add a Data Conversion task.

But the Input columns (which I entered in the Variable Mappings in the ForEach Loop containers) dont show up in the Available Input columns of the Data Conversion task.

How do I link the Variable Mappings in the ForEach Loop containers from the recordset returned by the Execute SQL Task to the Available Input columns of the Data Conversion task?

.......................

If this is not possible, and the advice is to use the OLEDB data flow as the input for the Data Conversion task (which is something I tried too), then the results from an OLEDB Command (using EXEC sp_myproc) are not mapped to the Available Input columns of the Data Conversion task either (as its not an explicit SQL Statement and the runtime results from a stored proc exection)

I would like to use the ExecuteSQL task to do this as the Package is clean and comprehensible. Which is the easiest best way to map the returned results from a Stored proc execution to the Available Input columns of any Data Flow transformation task for the transform operations I need to execute on each row of data?

[ Could not find any useful advice on this anywhere ]

thanks in advance!

View 4 Replies View Related

Convert SQL Code To Stored Proc

Dec 23, 2004

Dear All,

Lately i have started to convert my sql code to stored procedures, however i am still a bit new on this matter.

I have the following Sql Statement which I wish to convert to a stored procedure:-

SELECT MAX(" & id & ") As maxID FROM " & table

where id and table are parameters that I am passing to this sql from a function which is called getMaxID

for example, in the vb.net code i call it as follows:-

getMaxID("personID", "persons")

Can anyone tell me how to convert it to a Stored Proc please

Thanks for your help and time

Johann

View 2 Replies View Related

Validating Stored Proc Code

May 1, 2007

This is for SQL Server 2005

The problem: I need to validate all stored procedures on my server that they have not been altered after the application has been created.

Our server installation creates the user stored procedures for the application. Once created, I need a way to validate that the proc code has not been altered.

Previously, we were validating against the value of stats_schema_ver and crdate in the sysobjects table for the given stored procedure. During installation we would create a hash value of the crdate and stats_schema_Ver values for all our user defined procs. Then during validation, we would recreate the hash value and compare to that created during installation. If they differed, we knew that the proc code had been altered in some way.

Any alteration of the stored proc would update the stats_schema_ver- if the proc was dropped and recreated, it would update the crdate.

In 2005, the stats_shema_ver value is no longer updated when the proc is altered.

Perhaps this method was completely off-base to begin with...

So, how *does* one verify after installation that no proc code has been altered since installation?

The other option was to create a hash of the proc text definition- but that seems absolutely tedious to rehash the current proc definition every time the proc is accessed. There's also the problem that if you use the "with encryption" directive, it's no longer easy to get the text definition of the proc back out.

Appreciate any general thoughts or specific feedback.

Cheers,
Eric

View 12 Replies View Related

Trigger Job From Stored Proc

Mar 28, 2008

s it poaaible? as if so how can i trigger a job from a stored procedure?

View 2 Replies View Related

Trigger Executing Linked Server Stored Procedure

Jul 3, 2006

What is the syntax for creating a update trigger and passing the values which were updated to a stored procedure on a linked server?? Specifically need syntax for updated value, as well as the syntax for executing the stored proc on the linked server.

Thank you

View 1 Replies View Related

Trigger/Stored Proc Help Needed

Nov 29, 2007

I am fairly new to using triggers and stored procs in SQL Server and could use some help.

Scenario:

I have a table on SQL Server database running on a Windows server (of course) that contains information about articles. A second server in the shop is set up as a LAMP (Linux, Apache, MySQL, PHP) box. What I would like to do is any time the SQL server table is updated or a record is added, tables in MySQL would then be updated to reflect the changes on the first server. My thought is to try and do this with triggers and a stored proc.

Questions:
1) Assuming MySQL can be accessed through ODBC, can an ODBC connection be set up inside a stored proc or trigger, or would this have to be done through the Windows ODBC Data Sources tool in the control panel?

2) Can a Stored Proc be used in a trigger?

3) Can a Stored Proc call an outside function, such as an API call for third party software?

Thanks in advance.

View 1 Replies View Related

Debug (step Into) Sql Stored Proc From Managed Code

Aug 22, 2004

I am trying to debug sql2000 sp from managed code app with VS.Net 2003 archetect Ed..
It did not stop at the break point within the sql sp.
I did granted execute permission for sp_sdidebug.
Do I need to attach any process?

Is there anything left off by the article?
I referenced msdn article option 2: http://support.microsoft.com/default.aspx?kbid=316549

Thanks.

View 3 Replies View Related

Call Webservice From Trigger/stored Proc

Sep 17, 2004

Is it possible to call an external web service from a SQL Server trigger or stored procedure?

View 6 Replies View Related

DDL Create User In T-SQL Stored Proc/trigger

Dec 7, 2004

Hello SQL Server programming gurus:

I am trying to create a trigger that fires after a user logon and logoff and does the following:

creates a new user
deletes data from old temp table

Then I need to create a stored procedure that executes dynamically to
drop old users
remove the old user account access

We are running SQL Server 2000.
Since I am new to T-SQL programming could anyone help point me in the right direction? Can I write dynamic SQL in a trigger to do these things?

View 1 Replies View Related

Raising Error From Trigger To Stored Proc

Jul 23, 2005

I feel like I'm missing something obvious here, but I'm stumped...I have a stored procedure with code that looks like:INSERT INTO MyTableA ( ...fields... ) VALUES (...values...)IF (@@ERROR <> 0)BEGINROLLBACK TRANSACTION;RAISERROR('An error occurred in the stored proc.', 16, 1);RETURN(1);END--FORCING AN ERROR AT THE END FOR TESTING PURPOSESRAISERROR('Proc Successful',16,1)On MyTableA, there is a trigger that loops through the inserted data andstops the insert in certain circumstances, returning an error:IF (some criteria)BEGINROLLBACKRAISERROR('An error occurred in the trigger.',16,1)RETURNENDWhen I call the stored procedure from VB (connecting via RDO) witherror-causing data, the trigger successfully stops the insert, and adds thetrigger-error-msg to the errors collection, but it does NOT seem to createan error situation back in the stored procedure. The procedure finishes upwith the "Proc Successful" message, so that when I iterate through theerrors collection back in VB, I have "Proc Successful" followed by "An erroroccurred in the trigger."Is there some way I'm not finding to have the calling procedure recognizethat a raiserror occurred in the trigger and behave appropriately for anerror situation?Jen

View 1 Replies View Related

Transact SQL :: Executing Stored Procedure Within Trigger Failing But Separate Works

Nov 4, 2015

I have stored procedure on Server A which goes to ServerB to check and update table and then update on Server A as well.I have Trigger which suppose to execute stored procedure (as i mentioned above). But it failed with this error:--

Trigger code:--
CREATE TRIGGER [tr_DBA_create_database_notification] ON ALL SERVER 
AFTER CREATE_DATABASE
AS 
--execute dbadmin.dbo.usp_DBA_Refresh_DBAdmin_Tables

Error:--The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "xxx" was unable to begin a distributed transaction.Process ID 62 attempted to unlock a resource it does not own: DATABASE 21. Retry the transaction, because this error may be caused by a timing condition. If the problem persists, contact the database administrator.

Same stored procedure, if i execute manually or if i create sql job and execute this stored procedure, it works just fine..In trigger also, if i execute start job which has stored procedure, it works.My question is,why it failed when i execute stored procedure in TRIGGER.

View 5 Replies View Related

How To Identify Permissions For SQL Server Tables && Stored Proc. Via VB Code

Jul 20, 2005

I'm writing an application using VB 6.0 as the front-end GUI, and theMSDE version of SQL Server as the back-end (it's a program for areally small # of users --- less then 3-4).I'm trying to determine, through the Visual Basic interface, thepermissions of each user that's using the application on his/hermachine.For example, let's say I'm user "Michael" that's sitting down at mymachine using the app. I've written. The security for logging intoSQL Server will be setup using Windows Security (Trusted Connection)as opposed to Windows & SQL Server security. When Michael accesses aparticular form in the VB 6.0 GUI, I want to run some code thatautomatically checks Michael's permission levels on the underlyingtable (actually, a stored procedure supplying the data from the table)that supplies the data to the form he's looking at and then give himsome feedback on the form as to what type of permissions he has whilehe's browsing through the data shown in the form.For example, Michael opens a particular form, code in the backgroundis run to identify that this is Michael accessing the form, the codereturns a value that identifies what type of permissions he has on thedata in the form, and a text box on the form informs Michael (forexample) that he only has read-only permissions to the data he isviewing and cannot edit any of the data.As another example, user Karen sits down at her computer, logs intothe application, opens the same form that Michael just opened, thecode is run in VB to detect the level of permissions she has on thedata being displayed in the form, and the text box on the form informsher that she has editing permissions on the data in the underlyingtable.Etc...If anyone can post an example of the code they use in accomplishingthis task in an application they've written, I'd really appreciate apoint in the right direction or a real-world example that's beenimplemented by one of you. I've written several apps. thus far usingMSDE as the back-end, but the previous apps. I've written were forclients that didn't care about restricting access to theapplication... everyone could pretty much use the application as theydesired and do anything they desired to the data.The current client I'm writing the app. mentioned here for wants tohave security in place to where various users access the applicationwith various levels of permissions to do stuff (or *not* do stuff) tothe data in the application.Thanks very much in advance for any assistance / code provided!Sincerely,Brad McCollumJoin Bytes!

View 1 Replies View Related

How To Call AS400 Stored Proc And Evaluate The Return Code?

May 30, 2007

I am trying to use SSIS to update an AS400 DB2 database by calling a stored procedure on the AS400 using an OLE DB command object. I have a select statement running against the SQL Server 2005 that brings back 20 values, all of which are character strings, and the output of this select is piped into the OLE DB command object. The call from SSIS works just fine to pass parameters into the AS400 as long as the stored procedure being called does not have an output parameter defined in its signature. There is no way that I can find to tell the OLE DB command object that one of the parameters is an output (or even an input / output) parameter. As soon as one of the parameters is changed to an output type, I get an error like this:






Code Snippet


Error: 0xC0202009 at SendDataToAs400 1, OLE DB Command [2362]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x8000FFFF.

Error: 0xC0047022 at SendDataToAs400 1, DTS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "OLE DB Command" (2362) failed with error code 0xC0202009. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.

Error: 0xC0047021 at SendDataToAs400 1, DTS.Pipeline: SSIS Error Code DTS_E_THREADFAILED. Thread "WorkThread0" has exited with error code 0xC0202009. There may be error messages posted before this with more information on why the thread has exited.

Information: 0x40043008 at SendDataToAs400 1, DTS.Pipeline: Post Execute phase is beginning.

Information: 0x40043009 at SendDataToAs400 1, DTS.Pipeline: Cleanup phase is beginning.

Task failed: SendDataToAs400 1

Warning: 0x80019002 at RetrieveDataForSchoolInitiatedLoans: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (3) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.

Warning: 0x80019002 at Load_ELEP: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (3) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.

SSIS package "Load_ELEP.dtsx" finished: Failure.





I really need to know if the call to the AS400 stored procedure succeeded or not, so I need a way to obtain and evaluate the output parameter. Is there a better way to accomplish what I am trying to do? Any help is appreciated.

View 3 Replies View Related

Integration Services :: Unable To Get Return Code Executing SSIS Package From Stored Procedure?

Jun 11, 2015

We are executing a SSIS package using a xp_cmdshell command in a SP as shown below. This package does consumes time to execute almost 90 minutes and does get executed successfully too. But the strange thing is we don't get the result in @result variable just because somehow the next sql statement after the below highlighted statement doesn't get executed at all.  After checking execution stats for the SP using the query attached below we observed that somehow the SP vanishes out of the execution stats for the server.

 SELECT @cmd = 'dtexec /FILE "D:Program FilesMicrosoft SQL Server100DTSPackages.....PopulateReport.dtsx"'          
  SELECT @cmd = @cmd + ' /Decrypt T@!0er '          
  SELECT @cmd = @cmd + ' /set package.variables[vAppID].Value;' + CONVERT(VARCHAR(10),@appId)          
  SELECT @cmd = @cmd + ' /set package.variables[vDBName].Value;' + '"' + @db + '"'          
  SELECT @cmd = @cmd + ' /set package.variables[vBuildMFF].Value;' + CONVERT(VARCHAR(10),@BuildMFF)          
 
[code]....

View 6 Replies View Related

Exec SQL Task: Capture Return Code Of Stored Proc Not Working

May 19, 2006

I am just trying to capture the return code from a stored proc as follows and if I get a 1 I want the SQL Task to follow a failure(red) constrainst workflow and send a SMTP mail task warning the customer. How do I achieve the Exec SQL Task portion of this, i get a strange error message [Execute SQL Task] Error: There is an invalid number of result bindings returned for the ResultSetType: "ResultSetType_SingleRow".



Using OLEDB connection, I utilize SQL: EXEC ? = dbo.CheckCatLog

EXEC SQL Task Editer settings:
RESULTSET: Single Row
PARAMETER MAPPING: User::giBatchID
DIRECTION: OUTPUT
DATATYPE: LONG
PARAMETER NAME: 0

PS-Not sure if I need my variable giBatchID which is an INT32 but I thought it is a good idea to feed the output into here just in case there is no way that the EXEC SQL TASK can chose the failure constrainst workflow if I get a 1 returned or success constraint workflow if I get a 0 returned from stored proceedure





CREATE PROCEDURE CheckCatLog
@OutSuccess INT
AS

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
DECLARE @RowCountCAT INT
DECLARE @RowCountLOG INT

---these totals should match
SELECT @RowCountCAT = (SELECT Count(*) FROM mydb_Staging.dbo.S_CAT)
SELECT @RowCountLOG = (SELECT Count(*) FROM mydb_Staging.dbo.S_LOG)
--PRINT @RowCountCAT
--PRINT @RowCountLOG
BEGIN
IF @RowCountCAT <> @RowCountLOG
--PRINT 'Volume of jobs from the CAT file does not match volume of jobs from the LOG file'
--RETURN 1
SET @OutSuccess = 1
END
GO

Thanks in advance

Dave

View 6 Replies View Related

Trigger Error When Inserting Stored Proc Output Into Temp Table.

Feb 18, 2008





I writing a unit test which has one stored proc calling data from another stored proc. Each time I run dbo.ut_wbTestxxxxReturns_EntityTest I get a severe uncatchable error...most common cause is a trigger error. I have checked and rechecked the columns in both of the temp tables created. Any ideas as to why the error is occurring?

--Table being called.


ALTER PROCEDURE dbo.wbGetxxxxxUserReturns

@nxxxxtyId smallint,

@sxxxxxxxxUser varchar(32),

@sxxxxName varchar(32)

AS

SET NOCOUNT ON




CREATE TABLE #Scorecard_Returns

(
NAME_COL varchar(64),
ACCT_ID int,

ACCT_NUMBER varchar(10),

ENTITY_ID smallint,

NAME varchar(100),

ID int,

NUM_ACCOUNT int,

A_OFFICER varchar(30),

I_OFFICER varchar(30),

B_CODE varchar(30),

I_OBJ varchar(03),

LAST_MONTH real,

LAST_3MONTHS real,

IS int

)




ALTER PROCEDURE dbo.ut_wbTestxxxxReturns_EntityTest



AS

SET NOCOUNT ON




CREATE TABLE #Scorecard_Returns

(
NAME_COL varchar(64),
ACCT_ID int,

ACCT_NUMBER varchar(10),

ENTITY_ID smallint,

NAME varchar(100),

ID int,

NUM_ACCOUNT int,

A_OFFICER varchar(30),

I_OFFICER varchar(30),

B_CODE varchar(30),

I_OBJ varchar(03),

LAST_MONTH real,

LAST_3MONTHS real,

IS int

)

INSERT #Scorecard_Returns(

NAME_COL ,

ACCT_ID

ACCT_NUMBER ,

ENTITY_ID,

NAME,

ID,

NUM_ACCOUNT,

A_OFFICER,

I_OFFICER,

B_CODE,

I_OBJ ,

LAST_MONTH

LAST_3MONTHS,

IS

)

EXEC ISI_WEB_DATA.dbo.wbGetxxxxxcardUserReturns

@nId = 1,

@sSUser = 'SELECTED USER',

@sUName = 'VALID USER'

View 4 Replies View Related

Column Level Constraints... I Need A Constraint, Not A Rule, Or A Trigger Or A Stored Proc... Thnx.

Jul 17, 2001

Hello all.

First of all, I've been a reader of swynk.com for quite sometime now, and I'd like to say 'thank you' to everyone who contributes.

Today, I'm the town moron.. haha I'm having issues with column level constraints. I have a varchar(50) where I want to keep *,=,#,/, .. etc, OUT OF the value input. I don't want to strip them. I simply want for sql to throw an error if the insert contains those (and other characters). The only characters that I want in the column are A-Z and 0-9. However, it's not a set number of characters per insert. It always varies... There has to be an easier way to do this than creating a constraint for every possibilty... Any help would be greatly appreciated.

tia,

Jeremy

View 1 Replies View Related

Stored Proc Won't Update From C# .NET Code, But Will Update When Testing On Its Own.

Jul 23, 2006

I'm having a strange problem that I can't figure out. I have an SQL stored procedure that updates a small database table. When testing the Stored Procedure from the Server Explorer, it works fine. However, when I run the C# code that's supposed to use it, the data doesn't get saved. The C# code seems to run correctly and the parameters that are passed to the SP seem to be okay. No exceptions are thrown.
The C# code:
   SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["touristsConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("fort_SaveRedirectURL", conn);
cmd.CommandType = CommandType.StoredProcedure;
Label accomIdLabel = (Label)DetailsView1.FindControl("lblID");
int accomId = Convert.ToInt32(accomIdLabel.Text);
cmd.Parameters.Add("@accomId", SqlDbType.Int).Value = accomId;
cmd.Parameters.Add("@path", SqlDbType.VarChar, 250).Value = GeneratePath();
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
 The Stored Procedure:
  ALTER PROCEDURE developers.fort_SaveRedirectURL
(
@accomId int,
@path varchar(250)
)
AS
DECLARE
@enabled bit,
@oldpath varchar(250)

/* Ensure that the accommodation has been enabled */
SELECT @enabled = enabled FROM Experimental_Accommodation
WHERE Experimental_Accommodation.id = @accomId

IF (@enabled = 1)
BEGIN
/* Now check if a path already exists */
SELECT @oldpath = oldpath FROM Experimental_Adpages_Redirect
WHERE Experimental_Adpages_Redirect.accom_id = @accomId

IF @oldpath IS NULL
BEGIN
/* If Path already exists then we should keep the existing URL */
/* Otherwise, we need to insert a new one */
INSERT INTO Experimental_Adpages_Redirect
(oldpath, accom_id)
VALUES (@path,@accomId)
END
END
RETURN 

View 2 Replies View Related

Can You Trace Into A Stored Proc? Also Does RAISERROR Terminate The Stored Proc Execution.

Feb 13, 2008

I am working with a large application and am trying to track down a bug. I believe an error that occurs in the stored procedure isbubbling back up to the application and is causing the application not to run. Don't ask why, but we do not have some of the sourcecode that was used to build the application, so I am not able to trace into the code.
So basically I want to examine the stored procedure. If I run the stored procedure through Query Analyzer, I get the following error message:
Msg 2758, Level 16, State 1, Procedure GetPortalSettings, Line 74RAISERROR could not locate entry for error 60002 in sysmessages.
(1 row(s) affected)
(1 row(s) affected)
I don't know if the error message is sufficient enough to cause the application from not running? Does anyone know? If the RAISERROR occursmdiway through the stored procedure, does the stored procedure terminate execution?
Also, Is there a way to trace into a stored procedure through Query Analyzer?
-------------------------------------------As a side note, below is a small portion of my stored proc where the error is being raised:
SELECT  @PortalPermissionValue = isnull(max(PermissionValue),0)FROM Permission, PermissionType, #GroupsWHERE Permission.ResourceId = @PortalIdAND  Permission.PartyId = #Groups.PartyIdAND Permission.PermissionTypeId = PermissionType.PermissionTypeId
IF @PortalPermissionValue = 0BEGIN RAISERROR (60002, 16, 1) return -3END 
 

View 3 Replies View Related

Stored Procedure Executing Durations Are Different Between Executing From Application(web) And SQl Server Management Studio - Qu

Jan 24, 2008



Hi,

I have a web application using Stored Procedure (SP). I see that there's a SP taking long time to execute. I try to capture it by Profiler Tool, and find out that with the same SP on the same db with the same parameter. The duration of executing by my web app is far bigger than the duration of executing on SQl server management studio - query window

Please see the image through this url http://kyxao.net/127/ExecutionProblem.png


Any ideas for this issue?

Thanks a lot

View 1 Replies View Related

Stored Procedure Executing Durations Are Different Between Executing From Application(web) And SQl Server Management Studio - Query Window

Jan 23, 2008

Hi,I have a web application using Stored Procedure (SP). I see that there's a SP taking long time to execute. I try to capture it by Profiler Tool, and find out that with the same SP on the same db with the same parameter. The duration of executing by my web app is far bigger than the duration of executing on SQl server management studio - query windowPlease see the image attached http://kyxao.net/127/ExecutionProblem.png Any ideas for this issue?Thanks a lot Jalijack 

View 2 Replies View Related

Need Help Executing A Proc In Execute SQL Task

Jan 12, 2008

Hello,
I am trying to use an Execute SQL Task to execute a stored procedure with parameters in SSIS but it keeps giving me errors, for example I type in 'exec someproc ?, ?, ?' in SQL Task it wouldnt parse correctly and when I set the bypassPrepare to 'true' the package runs but gives me error at the destination saying couldnt find stored procedure 'someProc'.

Does anybody know how I can solve this problem?

Also how do I pass the results of the queries in the Execute SQL Task into the Data Flow Task? The proc is supposed to retrieve data and transform them into XML format to be placed at a XML file. I am not sure if I should used an OLEDB source or an XML source since the data has been transformed into XML. Any help will be greatly appreciated.

Please note proc runs fine when it does not have any parameters.

View 8 Replies View Related

Stored Proc - Calling A Remote Stored Proc

Aug 24, 2006

I am having trouble executing a stored procedure on a remote server. On my
local server, I have a linked server setup as follows:
Server1.abcd.myserver.comSQLServer2005,1563

This works fine on my local server:

Select * From [Server1.abcd.myserver.comSQLServer2005,1563].DatabaseName.dbo.TableName

This does not work (Attempting to execute a remote stored proc named 'Data_Add':

Exec [Server1.abcd.myserver.comSQLServer2005,1563].DatabaseName.Data_Add 1,'Hello Moto'

When I attempt to run the above, I get the following error:
Could not locate entry in sysdatabases for database 'Server1.abcd.myserver.comSQLServer2005,1563'.
No entry found with that name. Make sure that the name is entered correctly.

Could anyone shed some light on what I need to do to get this to work?

Thanks - Amos.

View 3 Replies View Related

Stored Proc Question : Why If Exisits...Drop...Create Proc?

Jun 15, 2006

Hi All,Quick question, I have always heard it best practice to check for exist, ifso, drop, then create the proc. I just wanted to know why that's a bestpractice. I am trying to put that theory in place at my work, but they areasking for a good reason to do this before actually implementing. All Icould think of was that so when you're creating a proc you won't get anerror if the procedure already exists, but doesn't it also have to do withCompilation and perhaps Execution. Does anyone have a good argument fordoing stored procs this way? All feedback is appreciated.TIA,~CK

View 3 Replies View Related

SQL Agent Executing 32bit Code

Jan 10, 2008

There is no SQL Agent forum so if this isn't the correct place please move this post.

Windows 2003 R2 x64 with SQL Server x64.

One of the steps in a SQL job I have setup requires me to run an exe. I can run this exe from the command line or by double-clicking it on this same server but when running it from a SQL job it does not run, the job just has the status 'executing' but does not do anything. I have enabled xp_cmdshell. I have also tried calling a bat file which then runs the exe and I have tried calling the bat file with SysWOW64cmd.exe. Same problem.

It seems to me the the operating system recognises the 32bit exe and runs it in that context but the SQL Agent thread keeps trying to run it as a 64bit exe and hence never gets anywhere. (My best guess)

Is there a way to force SQL job/steps to run an exe or bat file in a 32bit thread? Any other ideas.

Thanks
Scott

View 5 Replies View Related







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