stored-procedures

Pass Query Results to a csv file and Send it as mail using SQL Server 2005

I have two tasks and since I am new to it, I need some help/advice from the masters. What I need to do is send the result of q select query to a csv file which can have delimeter as comma or tab and then send this file as mail to a particular receipient. Hoping for some great advice ...

Throwing Exceptions in SQL CLR Stored Procedures

Is it good design to throw exceptions from SQL CLR stored procedures? Since we are in the context of SQL Server, do any special considerations need to be made? Is this bad design? [Microsoft.SqlServer.Server.SqlProcedure] public static void MyStoredProcedure(string foo) { if (string.IsNullOrEmpty(foo)) { throw new Argum...

MySql Stored Procedure's parameter with the same name as affecting's column, is it possible?

Hi again, I have a sequence table with two columns, name, value, and I have a stored procedure for incrementing the value provided the name DROP PROCEDURE IF EXISTS p_generate_sequence; delimiter | CREATE PROCEDURE p_generate_sequence (name VARCHAR(30)) BEGIN START TRANSACTION; -- Variable "name" equal to column "name", how to ...

execute sp in a select statement

For an instance I a select statement and it is returning 1000 rows. I need to execute a particular stored procedure for every row the the select statement is returning. have you got any idea how can I do that? ...

Can I call a Stored Procedure from an EntityDataSource?

(ASP.net 3.5, C#, SQL Express 2008) I want to have a Web Form, where I can search for "Solutions" (my table) using a keyword entered by the user and after the result comes back and populates a GridView. I already have parts of this search via a stored procedure that is hooked up to my Entity Data Model. On this page I have an EntityDa...

Creating a stored procedure to return the rowcount of another stored procedure

Title says it all - is it possible to do this? I have some filters set in my source Stored Procedure and I really don't want to have to duplicate it in another just to get the rowcount. ...

How can I open a file using java stored procedure

Hello all, I am using oracle database 10g. I have to write a java stroed procedure through which i can call a file at the server and store it locally at the users machine. Im using oracle Apex 3.1.1. ...

Linq over Stored Procedures

What are some pros and cons of using linq over stored procedures? ...

Should I use a single procedure for multiple operations, or split them into multiple procedures?

I am writing stored procedures for several operations in a database, I just wanted to know: Is it better to design a single procedure for a table which can perform add, modify, delete operations or... Should I design seperate procedures for each operations Which approach would be better? ...

MySql Stored procedure creation Error

I am trying to create a stored procedure in my mysql database usin the below code.I am getting an error.Please help me to solve My MySQl version is 5.0.51b CREATE PROCEDURE tv_insert_user(IN firstName VARCHAR(25), IN lastName VARCHAR(25), IN emailId VARCHAR(22),IN countryId INT,IN stateId INT) BEGIN INSERT INTO tv_user_master(FI...

Can you do a select on the results of a stored procedure in T-SQL

select * from (EXEC sp_SomeStoredProc) If you can't do this then what is stopping it from being added to the SQL standard or T-SQL? ...

multiple instances of named argument in list

Hi, I have a problem executing oracle procedures from Visual Studio 2008's Server Explorer, when i try to execute a procedure all the input parameters are doubled! it only happend to me in one workstation, i've tried to reinstall oracle products, but it doesn't helped me... i get the following error message when i try execute the pro...

SQL Stored Procedure : Incorrect syntax within imbricated IFs

I get "Incorrect syntax" errors on every nested IF and ELSE statements in the following code... what's wrong ? ALTER PROCEDURE [WTFAULT].[usp_WTFault_GetPartFaultStatus] ( @linxPartId int = -1, @faultStatus varchar(10) output ) AS BEGIN DECLARE @NbFaultsInParts int, @NbPartsReturned int SET @NbPartsReturned = (SELECT COU...

What is the easiest way to wrap a Stored Procedure in a Web Service?

We have a Legacy system that contains a number of stored procedures that we'd like to expose to other applications as web services. We are building the web services with JBoss. The stored procedures can run from Oracle, DB2 or MS SQL Server databases. JDeveloper has a wizard to generate the stubs and deploy to an ear file that would ru...

Mysql stored procedure : cant run from PHP code

I have below stored procedure to check the user name availability DELIMITER $$; DROP PROCEDURE IF EXISTS tv_check_email$$ CREATE PROCEDURE tv_check_email (IN username varchar(50)) BEGIN select USER_ID from tv_user_master where EMAIL=username; END$$ DELIMITER ;$$ when i run this from my mysql front end tool, it is working fine cal...

List of Stored Procedures/Functions Mysql Command Line

Dear all how can I see the list of the stored procedures or stored functions in mysql command line like show tables; or show databases; commands. ...

SQL Server 2005 stored procedure performance problem

I have the following issue: when a stored proc is called from my application, every now and then (like 1 time out of 1000 calls), it takes 10-30 seconds to finish. Typically, the sproc runs in under a second. It's a fairly simply proc with a single select that ties together a couple of tables. All the table names are set with a (NOLOC...

Reference stored procedure in another database?

From a stored procedure or function in a given MySQL database, is it possible to reference a stored procedure or function in another MySQL database, as follows? SELECT some_table.field1, some_table.field2, another_database.STORED_PROCEDURE(arg), ... FROM ... WHERE ... ...

Comma separated values in a database field

I have a products table. Each row in that table corresponds to a single product and it's identified by a unique Id. Now each product can have multiple "codes" associated with that product. For example: Id | Code ---------------------- 0001 | IN,ON,ME,OH 0002 | ON,VI,AC,ZO 0003 | QA,PS,OO,ME What I'm trying to do ...

result set

hi all, I m having a stored procedure which returns two result sets based on the success or failure. SP sucess result set: name, id ,error,desc SP failure result sret: error,desc I m using the following query to get the result of the stored procedure .It returns 0 for success and -1 for failure. declare @ret int DECLARE @tmp TABL...