stored-procedures

mysql stored procedure syntax errors with dates

Hi I am having fun trying to get a stored procedure to parse correctly in MySQL. My issue is with dates. I am trying to get the store procedure to create a start date that is the beginning of the current month e.g. 2009-07-01. Using this date I then use the DATA_ADD() function to add a month so that it reads 2009-08-01. However my pro...

ASP.Net - TableAdapter is returning phantom results

Hi, I have a TableAdapter that is fetching rows from an Stored Procedure. For some reason, when there are no results, the TableAdapter returns an INT with value 0 instead of NULL. The SP has NOCOUNT ON. The problem with this is that I have a ListView in the frontend with an EmptyDataTemplate, which is not being shown. When I ran the qu...

MySQL stored procedure call from ASP.NET 2 throws Use Procedure bodies exception

Hi I have the following scenario. I am calling stored procedures to MySQL 5.x from my .NET 2 application. All stored procedures have parameters and they work fine with the exception of two which throw the following exception (only when deployed to production): "When calling stored procedure and 'Use Procedure bodies' is false, all param...

I cant see SQL Queries in MySQL Stored Procedure!

I have created numbers of stored procedures in MySQL through remote access. And those procedures worked well. After a few days when I connected to Database through remote access. All stored procedures were alive but while was trying to call those procedures, I realized that SQL queries inside procedures had gone. Anyone knows the reason...

Copy SQL Stored Procedures between DataSources/Schemas?

Hi Friends, I've created SQL stored procedures in our development schema and its working fine. Now we are in the task of moving our development codes to production one. How do I copy those stored procedures from one schema to another schema? Do I need to re-compile whole procedures on targeted schema? Or Is there any way register those p...

Calling stored procedure via query and getting return value in C# without output parameters

Hello Is there anyway I can execute stored procedure via EXEC (so not specifying command type as StoredProcedure in C#) and get result? I tried to execute query DECLARE @R int EXEC @R = proc p1, p2 and then to grab @R but without success. What I don't want is to do it the usual way by adding parameters and using ParameterDirection...

Is it worth use ORM with Stored Procedures

My company's polices forces to use only stored procedures (SP) to talk with DB (no dynamic execution of SELECT, VIEWS on app side available) Business objects (BO) are fetched from DB. There is implemented simple BO-DB mapper using SQL Reader and this seems working well. Form DB side we have one parametrized SPs for each Business Object ...

C# Linq to SQL Stored Procedures

I have a stored procedure that returns a scalar int. I am using C# and Linq to get the resulting data, but I get the following error when I compile: foreach statement cannot operate on variables of type 'int' because 'int' does not contain a public definition for 'GetEnumerator' My question is how do I get the resulting data if the st...

Insert into a temp table from a stored procedure on Sql Server 2000

I'm trying to accomplish what is described here: http://sqldev.wordpress.com/2008/05/06/insert-into-temporary-table-from-stored-procedure/ The article says (with support via comments) that this works on SQL sever 2000 but may not be as easy. This was a little tricky pre 2008 – as it turns out in SQL Server 2008 this can be do...

SSRS Report from Oracle DB - Use stored procedure

I am developing a report in Sql Server Reporting Services 2005, connecting to an Oracle 11g database. As you post replies perhaps it will help to know that I'm skilled in MSSQL Server and inexperienced in Oracle. I have multiple nested subreports and need to use summary data in outer reports and the same data but in detail in the inner ...

Cursors vs duplicate code/logic

Hello, I heard it's not good to use cursors, as they "unnatural" to DBMS and they provide bad perfomance. But imagine the following situation: I have a stored procedure and I need to call this stored procedure for every customer from France (for example). I have a few options, such as using cursor, write all stuff in one query and call s...

How do I call a stored procedure from NHibernate that has no result?

I have a stored procedure that logs some data, how can I call this with NHibernate? So far I have: ISession session = .... IQuery query = session.CreateQuery("exec LogData @Time=:time @Data=:data"); query.SetDateTime("time", time); query.SetString("data", data); query.?????; What should the method ????? be? Or am doing something more...

What is the best way to store user generated conditions and consistently check them?

An application keeps track of hundreds of variables. Users are able to create conditions which can be simple (ex: if one variable is true) or complex (ex: if 34 variables are true AND 22 variables are false AND 2 variables are equal to each other). If the condition ever becomes true, it fires off some action. What is the best way to achi...

MS-SQL 2005 search: conditional where clause with freetext

I'm writing a fairly complex stored procedure to search an image library. I was going to use a view and write dynamic sql to query the view, but I need to use a full text index, and my view needs outer joins (http://stackoverflow.com/questions/1094695/ms-sql-2005-full-text-index-on-a-view-with-outer-joins) So, I'm back to a stored proc...

How to Retrieve names of stored procedures in SQL Server?

Hi, SO crowd! Is there any way to retrieve the names of the stored procedures by some SELECT from the system table or any system SP? I need to retrieve all the stored procedure names with their signatures (if possible) or just names. I know how to do that in MySql, but similar queries don't work (of course, since all the system DBs na...

2008 SQL EXPRESS stored procedures - mine are missing

Hi I'm using VWD 2008 (SP1) and SQLExpress 2008. I'm creating a database first and then looking at using DynamicDataControls (seem useful and staright foward for a beginner like me). Within VWD I created a new Dynamic Data Web Application. Then I added a new SQL database item. I noticed that this doesn't include stored procedures or......

Mass Renaming of Tables and Stored Procedures

I need to rename all of my tables, stored procedures and obviously the code within each stored procedure that was referencing the old table names. Why is the best way to do this? Some methods I have considered: SP_Rename - Gets half the job done. However this doesn't change the code within the SP itself In addition to RedGates' Refa...

nHibernate - stored procedures and composite keys

I'm trying to map the output of a stored procedure to an object in my project using nHibernate. The object is delcared like this: public class NewContentSearchResult { public string Name { get; set; } public string ContentType { get; set; } public int Count { get; set; } public int CMIId { get; set; } public int Fea...

Can LINQToSQL be used with sproc that uses sp_executeSQL? If not, how do you handle?

LINQToSQL doesn't like my sproc. It says that the sproc has return type "none", which is probably, because I am using an sp_ExecuteSQL statement to produce the results. The SQL Server Sproc Code I have a stored procedure similar to the following CREATE PROCEDURE Foo @BarName varchar(50) AS BEGIN DECLARE @SQL NVARCHAR(1024) SET @S...

Finding a stored procedure

Hi , How can we find a particular stored procedure. I need to find a stored procedure which I don't know is in which database. Can somebody please, help with a script. Thanks ...