stored-procedures

Entity Framework stored procedure not available

I added a reference to a stored procedure in my edmx file, then right clicked on it and selected "Create Function Import", it was added to the Function Imports folder under EntityContainer in the model browser. As I understand it I should be able to use it like so: sampleEntities db = new sampleEntities(); db.SampleStoredProcedure(); ...

MySql: Operate on Many Rows Using Long List of Composite PKs

What's a good way to work with many rows in MySql, given that I have a long list of keys in a client application that is connecting with ODBC? Note: my experience is largely SQL Server, so I know a bit, just not MySQL specifically. The task is to delete some rows from 9 tables, but I might have upwards of 5,000 key pairs. I started ou...

SQL - How to insert results of Stored_Proc into a new table without specifying columns of new table?

Using SQL Server 2005, I'd like to run a stored procedure and insert all of the results into a new table. I'd like the new table to have its columns automatically configured based upon the data returned by the stored procedure. I am familiar with using the SELECT ... INTO syntax: SELECT * INTO newtable FROM oldtable Is this possibl...

Find number of times the procedure is called using another procedure

I have two procedures A and B. Procedure A performs certain tasks. Procedure B has to monitor how many times procedure A is called in a day. How to achieve this? ...

Stored procedure, datetime

I have a search form in a website where I have to do a search in all or one column to database. I have the following stored procedure and have problem with datetime. How will I do to allow it to be null? I have problem with this both in stored procedure and i codebehind c#. Hope you can help me! ALTER PROCEDURE [dbo].[SearchPostit] ( ...

Does anyone have an implementation of sp_helpcolumn?

sp_help lists columns among other things. I am trying to get just the results that include the column information. Has anyone implemented this? ...

I need to know the disadvantages do keep Business Layer in Procedures ...

In my work, i have a friend that insists to keep the business logic inside the database using stored procedures ... What are the arguments that i can use to convince him not to do such thing? The reason he want to do this is because we have multiple systems with diferent plataforms (Web Application in .NET with VB.NET and another Deskt...

SQL Server 2005: dynamically adding parameters to a stored procedure

Scenario I have a stored procedure that takes a single parameter. I want to update this stored procedure to take a VARIABLE NUMBER OF PARAMETERS - a number that I will never know. I currently use SQLConnections through a C# interface in order to pass in a single parameter to the stored procedure and return a result. The SQL Part Lets ...

How do you handle all errors generated by a MySQL stored procedure

Background I'm writing a web application and I have a stored procedure which inserts some data into a table. As a programmer I am suspect of IO so my gut tells me I need to do some exception handling in case this write fails. The intended effect of the error handling within the stored procedure would be to set a flag to be consumed by...

Re-usable SQL Server stored procedures; nesting; global variables

I want to make some re-useable, somewhat-dynamic TSQL code that can be called within many other stored procs, but I'm struggling with how to implement this with SQL Server. The environment is that many distributed source systems databases which will have their own wrapper stored procedure which will call a few of these modular stored pr...

T-SQL query to check number of existences

I have next approximate tables structure: accounts: ID INT, owner_id INT, currency_id TINYINT related to clients: ID INT and currency_types: ID TINYINT, name NVARCHAR(25) I need to write a stored procedure to check existence of accounts with specific currency and all others, i.e. client can have accounts in specific currency, so...

check for existence before insertion in stored procedure

In my stored procedure, I would like to check to make sure what I am trying to insert doesn't already exist in the table. I have tried the code below, but it seems to be giving me false positives (aka comes out to true even when it's not in the table). Is there a better way? if not exists (select myID from tableName where myID = @myID a...

Should I use a Stored Procedure to execute a complex SELECT query?

I'm working on what is turning out to be a fairly complex SELECT query. I have several hierarchical queries being nested in a single SELECT and it is getting to be quite difficult to manage. I'm running into a few places where my inline views need to be executed in more than one place, so it seems like a reasonable idea to execute thos...

Parameterized stored procedure returning "too many arguments specified"

I'm writing an ASP.NET(C#) application in Visual Studio 2008 and connecting to SQLExpress 2005. While trying to update a FormView control bound to an SqlDataSource by using a parameterized stored procedure, I constantly get an error screen saying "too many arguments specified". I have tried clearing the list and adding all the paramete...

generating log timestamps using Stored procedures in SQL server 2005

I have a Stored Procedure, Which has some select Statements and insert statements. Is there any way , I can log the Timestamps of execution before and after the sqls inside the Stored procedure? ...

SQL Server CE 3.5 SP1 Stored Procedures

I have been tasked with taking an existing WinForms application and modifying it to work in an "occasionally-connected" mode. This was to be achieved with SQL Server CE 3.5 on a user's laptop and sync the server and client either via SQL Server Merge Replication or utilizing Microsoft's Sync Framework. Currently, the application connec...

Java and PostgreSQL stored procedure - return registered as out parameter, causing issues with in parameters

I'm trying to call a PostgreSQL stored procedure from a Java app; the procedure has a DATE type parameter so I'm using a java.sql.Date type with CallableStatement.setDate(). However, executing the statement always results in an exception and the SQL logs show this: LOG: execute <unnamed>: select * from athlete.create_athlete($1,$2,$3,...

Passing Textboxes from 'form' to stored procedure is resulting in errors

I am passing form values to stored procedure parameters and it appears I may have some data type issues. The stored procedure has been tested thoroughly and is working great, so I will just include the parameters from the stored proc. I'll also include the aspx and code behind detail below. I am VERY new at this, so any help on why I a...

Deleting temporary tables with a stored procedure

Hi, I have been trying to make a stored procedure which autodeletes temporary tables. CREATE PROCEDURE DeleteTemp() BEGIN DECLARE no_more_rows BOOLEAN; DECLARE loop_cntr INT DEFAULT 0; DECLARE num_rows INT DEFAULT 0; DECLARE tmptablename VARCHAR(100); DECLARE tmpTables CURSOR FOR SELECT TABLE_NAME FROM information_schema.TABL...

What's wrong with this MySQL Stored Function?

Having trouble getting this to apply in MySQL Workbench 5.2.15 DELIMITER // CREATE DEFINER=`potts`@`%` FUNCTION `potts`.`fn_create_category_test` (test_arg VARCHAR(50)) RETURNS int BEGIN DECLARE new_id int; SET new_id = 8; RETURN new_id; END// The actual function will have a lot more between BEG...