stored-procedures

What is the cost of an unused sproc

I've inherited a database with a surprisingly high number of unused sprocs. I've extracted the names of the used sprocs from the DLL that access it (all access is via that DLL), and from EXEC statements in those sprocs, and there are a couple hundred that are not called. Further, almost all have suspiciously verbose, uniform names: I sus...

Is there a way to do a prepared statement in linq2sql using a stored proc?

Based on what I can see the answer is no, but there is always a possibility ...

Can I set a default schema for within a stored procedure?

I'm working on the next update for StackQL. One thing I want to do is have the ability to query over several releases. So when I loaded the October data, for example, I didn't delete the old September database. It's still out there. In fact, you can even still query it by including the database name like this: select top 10 * from...

(SQL) How would I return the result set from multiple executed stored procedures?

Okay I have a queswtion about returning the recordset from multiple stored procedures. If I have a sproc which does this: exec sproc1 exec sproc2 exec sproc3 Each sproc returns just one number, so it return [no column name] 1500 [no column name] 18000 [no column name] 1253 Obviously a datareader won't be able to handle this, or a...

Modifying an Oracle Ref Cursor

Given: Oracle 10.2g is the database I have a table called emp. emp has a VARCHAR2 column called SECRET. SECRET might contain a plaintext string, or it might contain an encrypted string, but I can distinguish one from the other A function called DECRYPT already exists that, given the encrypted string, will return an unencrypted string. H...

Logic in stored procedure

I have need of some logic in a stored procedure. All the stored procedure does it perform a couple of logic rules and then returns a true or false depending on the result. The pseudo SQL code: CREATE TABLE #PV ([Date] DATETIME, Dis FLOAT, Del Float, Sold Float) INSERT #PV exec GetPVSummaryReport @ID, @PID, @From, @To SELECT AVG(Dis) / ...

MySQL ODBC Stored Procedure result is missing columns.

I have a set of stored procedures that I am using to populate an ASP.Net CheckBoxList. When running this procedure from code as { CALL ProcedureName(params); } with the type set as stored procedure, I only seem to be getting a partial result back (i.e. many columns from the actual result are missing.) If I copy the CommandText from the ...

SP TimeOut in .NET code, not in Management Studio

If I run the following in Management Studio (SQL Server 2008) : exec [USP_CNT_BookingDetail_ExtractAccountingPlanData] '4AFD6633-CB90-4165-913D-EE3EA74708DA', '7EF7CCB2-E09F-4408-AE2D-F857C063F2C1' I get the result back in less than a second I however I run it in VB.Net like this : Using aConnection = New System.Data.SqlClient.SqlCo...

Insert stored procedure is not compiling

Visual studio 2005 is still asking me for a create or alter after writing create procedure. What could be wrong? USE metroengineeringdatabase GO CREATE PROCEDURE dbo.InsertRecords ( @assetcodeId nvarchar(20), @name_of_asset nvarchar(20), @unit_no nvarchar(20), @manufacturer nvarchar(20), @make nvarchar(20), @model nvarchar(20), @capaci...

Is it possible to obtain result set of a sp as a table that I can query?

Hi, Is it possitble to get a stored-procedure's result set as a table so that I can query that? something like: SELECT PK_Item, Count(PK_Item) FROM (pMyStoredProcedure) --This sp returns a table that has PK_Item column GROUP BY PK_ITEM ORDER BY PK_ITEM DESC I am not an T-SQL expert but my friend says it is kind of impossible to do th...

MySQL: Can stored procedure information be extracted from the information schema?

Is it possible to retrieve stored procedure information like name, parameter nane/position/type from the Information Schema in MySQL or possible in some other way? ...

MySQL query that computes partial sums

What query should I execute in MySQL database to get a result containing partial sums of source table? For example when I have table: Id|Val 1 | 1 2 | 2 3 | 3 4 | 4 I'd like to get result like this: Id|Val 1 | 1 2 | 3 # 1+2 3 | 6 # 1+2+3 4 | 10 # 1+2+3+4 Right now I get this result with a stored procedure containing a cursor and ...

asp.net: which data collection should be used to return a table

I'm using a stored procedure to create a temporary table and want to return it in a data collection: public static >>data collection<< reportData(int intUserID) { SqlConnection con = Sql.getConnection(); try { SqlCommand cmd = new SqlCommand(); cmd = new SqlCom...

Variables and stored procedures

As a follow-up to my previous question I would like to know if there is a simple way of doing the following (which doesn't compile): CREATE TABLE #PV ([ID] INT, [Date] DATETIME, Dis FLOAT, Del Float, Sold Float) INSERT #PV @ID, exec GetPVSummaryReport @ID, @PID, @From, @To The reason is I need to join #PV onto another table by [ID], b...

How do I run SQL queries on different databases dynamically?

I have a sql server stored procedure that I use to backup data from our database before doing an upgrade, and I'd really like it to be able to run the stored procedure on multiple databases by passing in the database name as a parameter. Is there an easy way to do this? The best I can figure is to dynamically build the sql in the stored ...

Does Informix have scheduled triggers?

I need an Informix database to update some records on December 31 at 11:59; can Informix do this on a trigger, or does it have a scheduler of some sorts? I'm an Informix noob btw. I'm using informix 11.1 for hp-ux ...

Can't create Informix stored procedure using ISQL command?

I'm having trouble creating this stored procedure on IBM Informix Dynamic Server Version 10.00.FC9 (see Jonathan Leffler's answer to this post here) using the 'isql' command from Informix SQL. I get an error on the ( char for each of his two examples near RETURNING CHAR(8) ex. 1: CREATE PROCEDURE ampm_time(tm SMALLINT) RETURNING CHAR(...

DateTime manipulation in SQL Server EXECUTE sp_executesql

I am trying to do the following: EXECUTE sp_executesql N'SELECT TOP 10 * FROM dbo.Items WHERE DateCreated BETWEEN @start AND @end' , N'@start DATETIME, @end DATETIME' , @start = '20091001' , @end = GETDATE() --problem is caused by this line Error: Msg 102, Level 15, State 1, Line 5 Incorrect syntax near ')'. I need to...

C# CLR Stored Proc won't Deploy to SQL Server 2005

I'm developing a C# SQL Server 2005 stored procedure that does data validation for my application. I have a nice framework built, that is working. The validation methods are along the lines of: private void TestDate() { TestFields(delegate (string value) { if (value == String.Empty || value == "") return true; ...

Stored proc does not display results

The stored proc below does not display any results with SQL Server 2005. I can take the same instructions and run it as a query and I get results, What am I missing. ALTER PROCEDURE [dbo].[usp_SubtractStops] @p NVARCHAR(1024) = '209 208 207 206 205 204 203 113 297 19 7 12 11 6 232 233 234 235 236 237 273 271 272 210 211 212 213 214 21...