SSIS Pacakge Success/failure Based On Stored Procedure

Mar 11, 2008

I have an SSIS package that executes a stored procedure. In that stored procedure is a try/catch block. If the try isn't successful, it goes to the catch block which does a rollback. So when I execute the SSIS package, it tells me that the stored procedure was ran successfully because there essentianlly were no errors and everything ran fine, but in reality, everytime it goes into the catch block and does a rollback, I want the SSIS package to fail as well. How would I send back a failure to the SSIS package from the stored procedure?

View 13 Replies


ADVERTISEMENT

Script Task - Set Variable Value Based On Success Or Failure

Feb 14, 2008



Please excuse my ignorance as I'm a complete noob when it comes to vb.net.

I have 2 script tasks, each connected to an upstream task via Success and Failure constraints. Each script assigns a value to a variable, depending on whether the task succeeds or fails.

My code thus far is:




Code Snippet
Public Sub Main()

Dts.Variables("strEmailBody").Value = _
"Business Model Reporintg Control Complete - Status = Success"

Dts.TaskResult = Dts.Results.Success

End Sub




What i want to do is use a single script task depending on the success or failure of the package, setting the variable value accordingly.

If there are no errors Then

"Success"

Else

"Failure"

I've tried




Code SnippetIF CBool(Dts.Results.Success) Then...




But whislt it compiled, didn't evaluate correctly during runtime.


Can anyone suggest where I'm going wrong? Again I'm totally new to .net and I'm surprised I've gotten this far!


Thanks in advance.

Leigh

View 5 Replies View Related

How Do You Check For The Success Or Failure Of A Procedure Run In SQL

Mar 18, 2008

I have a number of stored procedures that run one after the other. How do you code to get the success or failure so that some logic can be applied accordingly? I've heard of the TRY CATCH structure, but I new and have yet to use it. How many different ways can success or failure be handled in code?

View 4 Replies View Related

SQL 2012 :: SSIS - OLEdb Destination Get Success / Failure Status

Feb 19, 2015

I have a SSIS pkg that gets data from SQL and do data conversion and Insert into OLE db AS400 destination, There is a flag column in SQL table , that has to be updated to true, once the records are inserted in AS400 how do i do that in SSIS

SQL oledb ---------> dataConversion ---------------> AS400 OLE db Destination
|
update SQL table Flag column<---------------------------------|

View 9 Replies View Related

SSIS Package Execution Completes Without Giving Any Success Or Failure Message

Sep 4, 2007

Hi,

We are using SSIS to load some 100k records from flat file to Oracle Destination. We are using Oracle 10g client.
But during the execution after some 5hrs or 6hr with 900k records upload we are getting the message Package execution completed. In the Execution results there is no message related to success or failure and the tasks in the Data Flow where yellow in color. What might be the problem? Any information regarding this case will be helpful for us.

Regards,
Roopa.

View 3 Replies View Related

SSIS Not Detecting Oracle Stored Procedure Failure

May 29, 2006

Hi,

I figured out a way to execute an Oracle Stored Procedure from an Execute SQL Task by using

Declare
Begin
SomeStoredProc(?,?,?);
End;

with an OLE DB connection using the Oracle Provider for OLE DB.

The parameters are getting passed in and the procedure executes but if for some reason it fails SSIS is painting the task green and keeps processing. I'm guessing that's because the outer Declare/End statement completed sucessfully.

I couldn't get it to work as a function with a return value. :(

Is there another way to execute an Oracle stored procedure that I missed?

Can you call an Oracle stored procedure from a Script Task and then fail it on parameter value?

Thanks

John Colaizzi

View 4 Replies View Related

Error: Communication Link Failure When Executin Stored Procedure In SSIS

May 19, 2008

Hi all,

I am wondering if you guys have any experience with failing Stored Procedures running inside a SSIS package with the following error:

=====================================================
Message
Executed as user: GAALPSVR034FSYSTEM. Microsoft (R) SQL Server Execute Package Utility Version 9.00.3042.00 for 64-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 8:51:22 AM Error: 2008-05-19 09:06:55.15 Code: 0x00000000 Source: usp_SLIM_Site_PreProcess Description: TCP Provider: The specified network name is no longer available. End Error Error: 2008-05-19 09:06:55.18 Code: 0xC002F210 Source: usp_SLIM_Site_PreProcess Execute SQL Task Description: Executing the query "Exec usp_SLIM_Site_PreProcess" failed with the following error: "Communication link failure". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 8:51:22 AM Finished: 9:06:55 AM Elapsed: 932.203 seconds. The package execution failed. The step failed.
======================================================

Sometime it fails when gets called through a job and sometimes even when a package is open in a design mode. The actual Stored Procedure NEVER fails if called in SQL Server Management Studio.

Any ideas or suggestions will be very helpful and appreciated
Thanks for your help!

Jacob

View 3 Replies View Related

Passing Execute DTS Package Result (success/failure) To Calling SSIS Package

Mar 6, 2008

I have a SSIS job, one of the last steps it performs is to execute a SQL 2000 DTS package. This has to be done as a SQL 2000 DTS package as it is performing rebuilds of SQL 2000 Analysis Services dimensions and cubes. We've found that when the DTS fails the SSIS job is happily completing showing as a success, we would prefer to know it went wrong.

As far as I'm aware SSIS merely starts the DTS off and doesn't care about it's result. I've taken a look in to turning on the logging for the execute DTS package and thought that the ExecuteDTS80PackageTaskTaskResult would give me the answer I need...but is merely written to the log not available as an event-handler. It also looks like it is not safe to put a SQL task in as the next item to go look at the SQL 2000 system tables to look at the log for the DTS package as the SSIS documentation warns that the DTS package can continue to run after the execute DTS package task has ended.

Ideally I want any error raised within the DTS package to cascade up to be an error in the SSIS job, I can then handle it appropriately. I cannot find a way to do this. Is there a way?

If not, can anyone suggest how in the remainder of the SSIS tasks I can be sure that the DTS has completed before I start any other tasks that will check for the SQL 2000 log of its execution?

View 5 Replies View Related

Success Of Stored Procedure

Jul 17, 2001

Is there a parameter allowing to verify successful execution of a stored procedure?

Something that can be run as the last line in a stored procedure to verify its success...?

Thanks!

View 1 Replies View Related

Checking Success Of A Request In A Stored Procedure

Jul 23, 2005

Hi,Say I have a stored procedure which does two INSERT operation.How can I check if the first INSERT succeeded in order to know if Ishould carry on and do the second one ?Regards

View 1 Replies View Related

SQL 2012 :: SSIS Passing Parameters To Stored Procedure That Changes Based On The Data Being Passed?

Jun 23, 2015

Using the following:

SQL Server: SQL Server 2012
Visual Studio 2012

I have created an SSIS package where I have added an Execute SQL Task to run an existing stored procedure in my SQL database.

General Tab:

Result Set: None
Connection Type: OLE DB
SourceType: Direct Input
IsQueryStoredProcedure: False (this is greyed out and cannot be changed)
Bypass Prepare: True
SQL Statement: EXEC FL_CUSTOM_sp_ml_location_load ?, ?;

Parameter Mapping:

Variable Name Direction Data Type Prmtr Name Prmtr Size
User: system_cd Input NVARCHAR 0 10
User: location_type_cd Input NVARCHAR 1 10

Variables:

location_type_cd - Data type - string; Value - Store (this is static)
system_cd - Data type - string - ??????
The system code changes based on the system field for each record in the load table

Sample Data:

SysStr # Str_Nm
3 7421Store1
3 7454Store2
1815061Store3
1815063Store4
1615064Store5
1615065Store6
1615066Store7
7725155Store8

STORED PROCEDURE: The stored procedure takes data from a load table and inserts it into another table:

Stored procedure variables:
ALTER PROCEDURE [dbo].[sp_ml_location_load]
(@system_cd nvarchar(10), @location_type_cd nvarchar(10))
AS
BEGIN .....................

This is an example of what I want to accomplish: I need to be able to group all system 3 records, then pass 3 as the parameter for system_cd, run the stored procedure for those records, then group all system 18 records, then pass 18 as the parameter for system_cd, run the stored procedure for those records and keep doing this for each different system in the table until all records are processed.

I am not sure how or if it can be done to pass the system parameter to the stored procedure based on the system # in the sys field of the data.

View 6 Replies View Related

How Does Xp_cmdshell Decide Success Vs. Failure?

Jun 29, 2006

Hi all,

I have a stored proc that uses xp_cmdshell to boot off a batch file on the NT side of the box (box OS is Windows 2000 Advanced Server).

Here is the pertinent code:/*----- Kick off the NT bat job to suck over the data through the web service pipe*/
SELECT @NTCommand = 'D:TradeAnalysisWondaDataStoreJobsPullFromWONDA _InstitutionalRankings.bat ' + CONVERT(varchar(10), @ReqDate, 101)
EXECUTE @e_error = master.dbo.xp_cmdshell @NTCommand
SELECT @m_error = CASE WHEN ISNULL(@e_error, 0) <> 0 THEN (@e_error + 50000) ELSE @@Error END
IF @m_error <> 0 GOTO ErrorHandlerThe trouble is that the batch file is failing (soft error, caught internally to the batch file, which then kills itself, screaming loudly all the way).

The batch file is using the following "voice" in which to scream in pain as it dies (a.k.a., using this code to terminate itself, which kills the cmd shell and returns 13 as an error code)REM WonDBService.exe says we failed
Date /T
Time /T
EXIT /B 13

Meanwhile, back at the ranch (errr...back in stored procedure), what is being returned is a ZERO (in the first code block, @e_error is being set to ZERO when the xp_cmdshell returns from the bat file.

So, now that I have ruled out the obvious *LOL* how can I get my xp_cmdshell to realize it has failed miserably at the one, tiny, simple, not-too-much-to-ask, job that it is designed to do?

View 2 Replies View Related

Packege Success, Despite Task Failure

Sep 12, 2006

Hello,

When I run my package, a task will fail, however, the package will claim that it was successful. Why is this, and how can I trigger a failed package when one task fails?

Thanks in advance.

View 4 Replies View Related

Transact SQL :: Call SP And Return 1 Or 0 On Success And Failure

Jun 1, 2015

When I execute Parent SP, it should  Return 1 when Child SP is executed Successfully and Zero when Child SP fail .below are sample SP 

CREATE PROCEDURE EXEC_CHILD_PROC
AS
BEGIN
SELECT 99/0
END

[code]...

I tried several way , but did not get correct syntax to modify Parent SP give 1 or 0 on child SP execution

View 6 Replies View Related

Foreach Loop .. Renaming Files On Success And Failure ?? Where ? How?

Feb 23, 2008

ummm. sorry, I've read and seen the tutorials but somehow and missing this.

I have a foreach container. Inside a dataflow task, with an XML source, a data conversion (cause of urrr UNICODE) and and an ole DB data source.

By design (and for this simple example), I get a volation if I attempt to load loads with out deleting entries from my table. No biggie, I would just like this simple package to rename my file to extension .good or .bad depending on success of each loop.
Where and what do I need for this?

Thank you for any help or information!

View 3 Replies View Related

Ensuring SOAP Request Success/Failure Notification

May 2, 2007

More of a general SOAP service call question.



Does anybody have any experience/advice on how to ensure that SOAP service call success/failures are returned to the calling app?



Consider a client that calls a SOAP service during which the client goes down and is unable to receive the SOAP response, the work having been done by the service. Similarly, the SOAP service may perform the task but a failure in the return makes the client think the process failed.



What would be the best way to ensure that the client is notified to avoid the call having to be made again?



Are there middleware tools that can be used to provide a form of message queuing for SOAP service calls?



Thanks



View 1 Replies View Related

SQL Server Admin 2014 :: Send Email On Scheduler Job On Both Failure And Success

Jun 10, 2015

I have configured smtp email in MS sql server and configure email to schedular job when schedular jobs become failed. Can i configure email so that email will be sent from scheduler job on both success of job and Failure of job?

View 3 Replies View Related

Execute 2000 DTS Pacakge SSIS In SQL 2005

May 8, 2008

I have a legncy DTS package when upgrading to SQL 2005, I used "SQL Business Intelligence Development Studio" to create a project, the control flow is "Execute 2000 DTS Package", by right click "Execute Task" of the control flow, the color changed from yellow to red, the message said "package Execution completed". When I try to schedule this package in SQL Server Agent, the job failed. When I run dtexec, got following error message.


C:>dtexec /file "C:Documents and SettingslyangMy DocumentsVisual Studio 200
5ProjectsTraingDTSTraingDTSDTSTraining.dtsx"

Microsoft (R) SQL Server Execute Package Utility
Version 9.00.1399.06 for 32-bit
Source: Execute DTS 2000 Package Task
Execute DTS 2000 Package Task is initiated: 0% complete

End Progress

Error: 2008-05-08 09:13:35.74
Code: 0x00000000
Source: Execute DTS 2000 Package Task
Description: System.Runtime.InteropServices.COMException (0x80040427): Execut
ion was canceled by user.
at DTS.PackageClass.Execute()
at Microsoft.SqlServer.Dts.Tasks.Exec80PackageTask.Exec80PackageTask.ExecuteT
hread()
End Error

Progress: 2008-05-08 09:13:35.74
Source: Execute DTS 2000 Package Task
Execute DTS 2000 Package Task is completed: 100% complete
End Progress
Warning: 2008-05-08 09:13:35.74
Code: 0x80019002
Source: DTSTraining
Description: The Execution method succeeded, but the number of errors raised
(1) reached the maximum allowed (1); resulting in failure. This occurs when the
number of errors reaches the number specified in MaximumErrorCount. Change the M
aximumErrorCount or fix the errors.
End Warning

DTExec: The package execution returned DTSER_FAILURE (1).


Can anyone tell me what does the error message mean and how to solve them?


Thanks very much in advance!


Lisa

View 3 Replies View Related

SSIS Pacakge Error:'Deferred Prepare Could Not Be Completed'

Aug 4, 2006

Hello,
I am trying to use the Import export wizard to created a package,
using the provide source query option. If i just copy the query from a text file
and try to paste , sql only accepts it partially. so i saved it as a sql file
and then opened it in the window. However, when i click on 'next' or 'parse' , i
get the below error.

TITLE: SQL Server Import and Export Wizard

------------------------------
The statement could not be parsed.

------------------------------
ADDITIONAL INFORMATION:
Deferred
prepare could not be completed.
Query timeout expired (Microsoft SQL Native Client)


The query is pretty big, but it executes successfully in the Management Studion Query Explorer window. I had no problem creating a package using DTS with the same query in Sql 2000. I also tried to migrate the package already existing in Sql 2000, but even though i can migrate it successfully , the package does not execute in Sql 2005. Also i tried other queries which are as big as this one, again the query source window during import/export does not seem to accept large queries??? I depend heavily on large queries for my packages, which i run daily. I have not had any issues with this is sql 2000. Can someone help me with this???

Thanks in advance.

Ram

View 6 Replies View Related

How To Create Global Variable For Connection Manager In SSIS PAcakge

Jul 6, 2006

Hi,



now i am currently using SSIS Package using BUI, The Source and Destination File we Given Manullay Connect the Server name ,And Table . Instead of given Manual . How to create Global Variable Connection Manager.

Suppose Today i am Working Developement Server. Latter i will be changed Production Server Database. At That time we have to Going to Modify all the Connection .Instead of This How to Create the Connection Manager Gloabe Variable . and How to Use .Please Any one give Sample For Connection Manager variable for Different Server.





Thanks & Regards,

Jeyakumar.M

chennai

View 16 Replies View Related

How To Insert One Row With Multiple Time Depding On Source Column Value In SSIS Pacakge

Jun 5, 2006

Hi !

I need help for SSIS Pacakge. using condtional Split How to insert One records with Multiple time depending on Source column value .Is there possible to wrtie the condition in Conditional split.



For Exmaple :

Source Table Name : tbl_source

following Column Name: col_Name1,Col_Name2,Col_Name3, col_Id,Col_Descrip

table contain only one records:GRD1,SRD1,FRD1,100,Product



I want Insert the Destiantion table the Follwing Condition. using Conditional Split.

1)Cond1 (!(ISNULL(GRD1))

2)Cond2 !(ISNULL(SRD1))

3)Cond3 !(ISNULL(FRD1))

I need the Following output



Destination Table Name : tbl _Dest(for One record in source table i need following records in destination)

Coulmn Name , Column Value , ID

Row 1 GRD GRD1 100

Row 2 SRD SRD1 100

Row 3 FRD FRD1 100



How to achieve this result. can u anyone help me.using Conditional split iam getting only first condition Result.



Thanks & regards

M.Jeyakumar



View 12 Replies View Related

C# Stored Procedure / OpenXML Failure - Can Anyone Help..???

Jan 9, 2006

 
Hi,
I have some c# code which calls a SP which is erroring Basically I pass in a XML string which can be upto 5 MB is size (not sure about overflow issues here), which then calls a SP which inserts the data into a SQL table.
The c# code is as follows:
-------C#----------------------
SqlConnection conn = new SqlConnection(DBConn);

using(StreamReader sr = new StreamReader(xmlLocationString))
{
try
{
string @xmlInput = sr.ReadToEnd();
SqlCommand cmd = new SqlCommand();
cmd.Connection=conn;
cmd.CommandText = "[AddArgentinaTrades]";
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@xmlInput", SqlDbType.Text, 5120000));
cmd.Parameters["@xmlInput"].Direction = ParameterDirection.Output;
conn.Open();

cmd.ExecuteNonQuery();
}

catch(SqlException SqlExp)
{
Console.WriteLine(SqlExp.Message);
}
finally
{
conn.Close();
sr.Close();

}
}
------------------Stored Proc-----------------------
 
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'AddArgentinaTrades' AND Type ='P')DROP PROCEDURE AddArgentinaTradesGO
CREATE PROCEDURE AddArgentinaTrades@xmlInput as textAS
Declare @idoc  int
EXEC master.dbo.sp_xml_preparedocument @idoc OUTPUT, @xmlInput
INSERT INTO MarketRiskdev.dbo.Import_ArgentinaSELECT  un_cid, tnum, snum, cid, entityid, ctype, why, comp, oc, bs, ae, cp, trd_date, set_date, mat_date, val_date, trader, famt, price, coupon, next_coupon, last_coupon, cpnfreq, cpnrate, cpntype, daycounttype, exch_notion,contract_spot, base_cur, year_basis, buy_currency, buy_amount, sell_currency, sell_amount, [timestamp] FROM OPENXML(@idoc, 'ArgentinaInputFile/Data',2)WITH (un_cid varchar(50), tnum nvarchar(50), snum nvarchar(50), cid varchar(50), entityid varchar(50), ctype varchar(50),  why  varchar(50),  comp  varchar(50),  oc  varchar(50),  bs  varchar(50),  ae  varchar(50),  cp  varchar(50),  trd_date datetime,  set_date datetime,  mat_date datetime,  val_date   datetime,  trader  varchar(50),  famt  float(8),  price  float(8),  coupon  float(8),  next_coupon datetime,  last_coupon datetime,  cpnfreq  int,  cpnrate  float,  cpntype  int,  daycounttype smallint,  exch_notion smallint,  contract_spot float(8),  base_cur varchar(50),  year_basis int,  buy_currency varchar(50),  buy_currency varchar(50),  buy_amount float(8),  sell_currency varchar(50),  sell_amount float(8),  [timestamp] varchar(50))  
EXEC  master.dbo.sp_xml_removedocument @idoc
GO
Error Msg:
A severe error occurred on the current command.  The results, if any, should bediscarded.
Can anyone help here as I have no idea. I have tried reducing the size of XML to 5KB and still get the same error????

View 1 Replies View Related

Stored Procedure DTS Package Partial Failure

Jul 22, 2005

I am running a DTS Package from a stored procedure using xpcmdshell. The DTS Package begins with a SQL Task to delete records from 2 tables (this works fine), but the data transfer task for importing records from a SQL Anywhere 5.0 database gives me the error 'Unable to connect to database server: Unable to start database engine'. the weird thing is that from Enterprise Manager I can execute the DTS Package and it works fine. What am I missing here?????

thanks
dzap1

View 10 Replies View Related

Continue Processing Stored Procedure, When A Failure Occurs...

Apr 8, 1999

All,
Is there a way, in SQL Server 6.5, to continue processing within a stored procedure even though an error occurs? An example I am inserting records into a temp table within a stored procedure, and there may be duplicate UNIQUE keys, I simply want the procedure to continue inserting records ignoring the failure.

Thank you,
Scott Kolek
Development Manager

SKM Software
http://www.skm-software.com

View 3 Replies View Related

SQL 2012 :: Use SSIS Or Stored Proc Or Combination To Handle Stopping A Process On Failure

Apr 7, 2015

A project I'm working on consists of a Main stored procedure which then runs about 30 nested procedures. The client wants to know when a certain nested SP fails, but wihtout rollbacks, as they may want to fix a data item manually (such as a missing Patient ID, that they have to call someone about). At this point, we don't want to roll back anything but halt the rest of the nested SP's and send out an email to someone that they have to check out a missing PatientID.

I'm wondering if an SSIS package would handle this better than just using a Stored Procedure. When that SP runs, it will also update a "Process tracking" table in the backend, that would update [Lastprocessran] with a number. I'm thinking that if they run the main SP again, after making a manual correction, that they could re-run the main SP, and it would bypass any step that already ran successfully based upon the [Lastprocessrun] number.

View 2 Replies View Related

SSIS Job Success But Package Didn't Run

Mar 16, 2007

I created a SSIS package that imports a file then moves the file to a folder called processed.
I created a job that runs the package. The pack works fine when I run it from the SQL Storage Area. When I run the job I get the following message:


Started: 9:58:15 AM DTExec: The package execution returned DTSER_SUCCESS (0). Started: 9:58:15 AM Finished: 9:58:21 AM Elapsed: 6.047 seconds. The package executed successfully. The step succeeded.

showing that the job supposedly completed successfully.


I know that the package the not run because the data did not get imported and the file did not move.

Can anyone explain the package may not run but we still get a job completion status of success?

View 6 Replies View Related

Report Based On Stored Procedure - ODBC

Jun 25, 2001

Can anyone tell me if this can be done?

I'm using CR8 against SQL Server 7 and am trying to use a stored procedure as my data source.

Basically my boss would like to move all the code that is now client-side(formula fields, parameters, suppressions, etc.) to the server-side.

I connect by Database>ODBC and then choose my sp here.
I get the error: "There are no fields in the file"
All my sp is doing is accepting two parameters: a report type and a user name, and then generating a report based on this data.
I can post the exact sp but it is a pretty long IF THEN ELSE block.

I checked the Seagate site and it said to convert the database driver to the native driver;
I guess this would mean to connect by: Database>More Data Sources>Microsoft SQL Server
But we need to connect by ODBC since we don't want the popup for the Login to Database, Server, etc., to be entered by the client.

Can someone tell me if there is a way around this to connect by ODBC using stored procedures.

Thanks in Advance.

View 1 Replies View Related

Analysis :: Building A Cube Based On Stored Procedure

Jul 29, 2015

I am new to SSAS. I have requirement to build a cube based on SQL Stored procedure. This Stored Procedure contains lot of temp tables, which are aggregated as measure columns.

Initially I have done creating views on each temp table, finally I created a view which calls like 15 views. when I try to execute the view, it is taking long time to execute the view.

I tried building cube on this view, when I try to deploy, even it is taking long time to deply..I have waited for 2 hours, still the deployement process going..

What I wonder is, is there any other way I can build cube based on SQL stored Procedure.

View 2 Replies View Related

Write A Stored Procedure Based On Recursive Data.

Feb 25, 2008

Hello, I am hoping someone can help me in this. I am looking to write a stored procedure that will return the heirarchy of an organization. I will display how the heirarchy might look and then list the tables involved.

John Smith

- Jacob Jones
- Lisa Thompson
- Samuel Barber

- Paul Smith
- John Jackson

Ok, so Jacob, Lisa, an Samuel report up to John Smith. Paul and John Jackson report up to Samuel Barber.

Here are the tables:

Users holds the user_id, first_name, last_name, and reports_to_user_id.
User_Roles holds the user_id, role_type_id
Role_Types holds the role_type_id, and the type (which could be Administrator, Standard, Guest) for example. In addition, Role_Types also has ranking which must be taken into consideration as well. 1 being the top rank and 9 being the lowest.

Thanks very much in advance,
Saied

View 12 Replies View Related

Report Based On Optional Parameters From Stored Procedure

Jan 12, 2008



I have the following stored procedure:



Code Block
CREATE PROCEDURE udsp_td_queryowner
@state varchar(10) = NULL,
@businesstype varchar(20) = NULL,
@size int = NULL,
@sortorder varchar(20) = 'state'
AS
SELECT gl_t.state AS [State],
gl_t.business_type AS [Business Type],
gl_t.lowsize AS [Low Size],
gl_t.highsize AS [High Size],
e.InternetAddress AS [Owner]
FROM gl_territory gl_t JOIN employee e ON gl_t.employeenumber = e.EmployeeNumber
WHERE state = COALESCE(@state, state) AND
business_type = COALESCE(@businesstype, business_type) AND
COALESCE(@size, lowsize, highsize) between lowsize AND highsize
ORDER BY CASE WHEN @sortorder = 'state' THEN gl_t.state
WHEN @sortorder = 'business type' THEN gl_t.business_type
WHEN @sortorder = 'owner' THEN RTRIM(e.FirstName) + ' ' + RTRIM(e.LastName)
END ASC,
CASE WHEN @sortorder = 'low size' THEN gl_t.lowsize
WHEN @sortorder = 'high size' THEN gl_t.highsize
END ASC,
CASE WHEN @sortorder = 'statedesc' THEN gl_t.state
WHEN @sortorder = 'business typedesc' THEN gl_t.business_type
WHEN @sortorder = 'ownerdesc' THEN RTRIM(e.FirstName) + ' ' + RTRIM(e.LastName)
END DESC,
CASE WHEN @sortorder = 'low sizedesc' THEN gl_t.lowsize
WHEN @sortorder = 'high sizedesc' THEN gl_t.highsize
END DESC





What it allows me to do is enter in any number of the variables when running the stored procedure. For example, EXECUTE udsp_td_queryowner @state = 'IA' would give me everything in the table in the state of IA regardless of the other field values. Likewise, if I ran EXECUTE udsp_td_queryowner @state = 'KY', @size = 15 it would return the records that are in KY and the size of 15 is in the range of the low and high value.


If I run the first example in Query Analyzer I get 53 records from the data I have. It returns every record that has IA as the state. I run the same thing in Reporting Services and all I get is 3 records. Just the 3 records for the state of IA where the business type is either null or blank (I can't tell.) If I allow all of the variables to accept Nulls then it returns the correct data. However, I would like to find a better alternative because when the report is run it returns all of the records in the table initially and if they user wants to enter in any parameters they have to toggle off the null box for the corresponding paramter.


Any ideas?

View 12 Replies View Related

Grouping Data Based On Return From Stored Procedure

Jun 15, 2007

I'm having some difficulty getting the appropriate results for my scenerio. I have two different datasets that I'm using. One is consisting of two joined tables and the other consisting of one sp. The sp's parameters rely on two things- one is the companyNum (inputed when the user runs the report) and two is the ContactNumType. The ContactTypeNum comes from the dataset of tables. I need to have a table consisting of this format:


ContactNumType1 (From the Tables)
File_Name1 (From the sp)
File_Name4 (From the sp)
File_Name3 (From the sp)



ContactNumType2 (From the Tables)
File_Name2 (From the sp)
File_Name7(From the sp)



ContactNumType3 (From the Tables)
File_Name5 (From the sp)



ContactNumType4 (From the Tables)
File_Name6 (From the sp)

File_Name10 (From the sp)
File_Name8(From the sp)
File_Name9 (From the sp)

So essentially what is going on is that every returned File_Name is grouped based upon the type of ContactNumType. My table returns the appropriate ContactNumTypes and the appropriate number of File_Names but returns only the first File_Name for each row. The File_Names should only grouped by the ContactTypeNums and each be unique. Is there any way to do that?


-------------------------------------------------------------------------------------------
Edited: I still am trying to work this out. I've tried a few run-arounds but none have worked. Adding custom code apparently is too risky at this point because of the security precautions that I've been instructed to take. Any help would be greatly appreciated as this project has been going on for days now....

View 3 Replies View Related

Execute External Process From CLR Based Stored Procedure

Aug 13, 2007



Hi All,

I am trying to create a CLR based stored procedure in C#. When i tried printing simple "Hello" from it, it works fine.
Now requirement is to run an exe file from it. For that i use process.start. But when i try to execute the procedure i get all the security execptions. Can someone please help. Following is the code snippet.
-------------------------------------------------------------------------------------------------------------------------------------------------------------

public partial class StoredProcedures

{

[Microsoft.SqlServer.Server.SqlProcedure]

public static void RunProc(string arg)

{

SqlPipe pipe = SqlContext.Pipe;

pipe.Send("Hello");

Process.Start("E: est.exe");

}

}



CREATE ASSEMBLY [RunProcess]

FROM 'RunProcess.dll'



CREATE PROCEDURE dbo.sqlclr_RunProc

(

@arg nvarchar(1024)

)

AS EXTERNAL NAME [RunProcess].[StoredProcedures].[RunProc]

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Thanks
Sid

View 6 Replies View Related

Task Failed, SSIS Package Reporting Success

Mar 26, 2008

I'm debugging a SSIS package in Visual Studio and I have a task that failes but the overall package is reporting success. The deployed package in SQL2005 is doing the same thing.


Task failed: FactVisitApplicationInventory

SSIS package "PACE to PACE DW PROD.dtsx" finished: Success.

The program '[4652] PACE to PACE DW PROD.dtsx: DTS' has exited with code 0 (0x0).


I have set FailPackageOnFailure=True, FailParentOnFailure=True, and MaximumErrorCount=0 on this task and am executing just this single task in Studio and I can't get the Package to report a failure.


Any ideas?

View 3 Replies View Related







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