stored-procedures

SQL Server, not inserting records in correct position after deleting one or more records

I know, is a very basic question, but I am in the process of re-learning sql stored procedures, and this is what happended: I was practicing with some simple delete / insert routines, when encountered with this: if I ONLY insert records: 1. dog 2. cat 3. t-rex 4. llama all is ok, then I call a delete procedure, passing the colum...

Error with mysql procedures ERROR 1304 & ERROR 1305

I am new to using procedures and cannot seem to get mine working. I am using MySQL v5.1.36 and inputing my code using MySQL Console on a WAMPP server. If I go to (re)create the procedure. I get error #1304 (42000). mysql> DELIMITER // mysql> mysql> CREATE PROCEDURE modx.getCRID (IN x VARCHAR(255),OUT y INT) -> BEGIN -> ...

In SQL Server 2008, how should I copy data from database to another database?

I'm trying to write a stored procedure to copy a subset of data from one set of tables to an identical set of tables in a different database. The "source" database needs to be a parameter to the stored procedure. I've struggled with this for two days now, and I thought I had a good solution: Validate that the schemas are the same. Cr...

Does SQLite support store Procedures

Hi, I am evaluating the SQLite database for my requirement. Do SQLIte support the store procedures ? If yes then what is the limitations? Does SLIte support the range? Thanks Saurabh ...

How to use the result of a complicated query in self-join?

I'm writing a stored procedure on SQL Server 2000. I've written a complicated select statement that takes 18 seconds to run. The question is, how can I self-join the result correctly and efficiently? Is it possible to manage it in a single select statement without repeating the big query statement that I currently have? Or should I sa...

Should stored procedures check for potential issues when executing?

Let me explain this question a bit :) I'm writing a bunch of stored procedures for a new product. They will only ever be called by the c# application, written by the developers who are following the same tech spec I've been given. I cant go into the real tech spec, so I'll give an close enough example: In the tech spec, we're having to...

Paging with the Telerik MVC grid when using a sproc

The documentation only shows how to bind to an IEnumerable (which uses linq to page and sort) ... but I need to go against a sproc because expressing the query I'm working on with linq is proving to be a bit slow. Can anyone provide any guidelines or pointers on what's the best way to do this? ...

MySQL stored procedure for duplicating records from 4 inter-related tables

I have 3 tables, networks, nodes, networknodes, networkconnections. networknodes has 3 fields network_node_id, network_id, and node_id, the last two are forien key references to network. and a network may include multiple copies of same node (but with diffrent network_node_id) networkconnections has the fileds networkconnection_id, sta...

SQL wildcards not returning data?

I have a select statement that is used in a gridview via a stored procedure: SELECT * FROM T_Computer WHERE (ISTag LIKE '%' + @ISTag + '%') AND Status <> 'Trashed' AND Status <> 'Sold' AND Status <> 'Stored' The @ISTag, an nchar is determined by a textbox value, if the textbox is empty I have the default value set to %, which in my mi...

Use stored procedure output parameter

ALTER PROCEDURE dbo.StoredProcedure8 @emp_code bigint, @co_id bigint, @p decimal(8,2) output AS SELECT @p = (select sum(tran_value) from emp_ded_ben_trans where emp_code=@emp_code and co_id=@co_id and period_flg=2 and tax_flg=0) RETURN ...

mysql server: stored procedures - when do i create the stored procedures?

Hello. I found tutorials on creating a stored procedures on the net, I just don't understand when exactly do I need to execute the creation of the stored procedure. do the stored procedures creation should be executed each time i restart my MySQL server ? do I need to execute the stored procedures creation sql each time I start my app...

Incorrect syntax near 'ERROR_MESSAGE'

BEGIN TRY BEGIN TRANSACTION -- DO SOMETHIING COMMIT TRAN END TRY BEGIN CATCH IF(@@TRANCOUNT > 0) ROLLBACK TRANSACTION RAISERROR(ERROR_MESSAGE(), ERROR_SEVERITY(), ERROR_STATE()) --ERROR: Incorrect syntax near 'ERROR_MESSAGE'. END CATCH What wrong in the raise error statement? ...

Call a stored procedure with another in Oracle

Hi, does anyone know of a way, or even if its possible to call a stored procedure from within another? And if so how would you do it? Here is my test code: SET SERVEROUTPUT ON; DROP PROCEDURE test_sp_1; DROP PROCEDURE test_sp; CREATE PROCEDURE test_sp AS BEGIN DBMS_OUTPUT.PUT_LINE('Test works'); END; / CREATE PROCEDURE test_sp_1 ...

Stored procedure: Searching in a table when passing an array of values

Hi, I need to create a stored procedure which receives a parameter (named @codes). This is a string which contains a list of codes separated by a semicolumn. I'd need to look inside a table and return all rows that have a code (which is in the column EANcodes) which was passed in the @codes parameter. Can anyone help me get started. M...

WCF and Stored Procedure Options

I'm making my first WCF Service and I am unsure which route I should take with stored procedures and Linq to Sql. I understand that I can drag and drop stored procs to my DBML file and call them that way, or call them directly, not using the dbml. Is there a reason why i should choose one over the other? I guess I'm a little confused... ...

MySQL stored procedures or php code?

A general question, without a specific case in mind - is it usually preferred to use MySQL stored procedures over writing a PHP script that performs the same calculations and queries? What are the benefits of each method? ...

Why does this stored procedure not return the correct ID?

Intermittently this stored procedure will return an ID that is in the millions when it should actually only be around 400. set ANSI_NULLS OFF set QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[TestStoredProcedure] ( @Title VARCHAR(50), @ID INT OUTPUT ) AS DECLARE @ResultsTable Table(InsertedID INT); INSERT INTO Table ( T...

ASP Classic - Recordset Object vs. Command Object

Hi I am using ASP Classic and SQL Server 2000 to create dynamic websites. I am a bit confused about when to use a recordset object and when to use a command object when querying the database. I was told that if the stored procedure would be returning records from a SELCT statement then I should use a recordset, however if I am up upda...

LINQ to SQL - How do stored procedures interact with unsubmited datacontext changes?

Someone here asked: "Linq-To-Sql enables calling SPs. If this SP executes an update/delete/insert, do I need to SubmitChanges() after it?" And the answer was: "No you don't. The code will work. Submit changes is only concerned with modified LINQ to SQL objects and not stored procs." I would just like to clarify: (Please excuse me, I...

Possible to create/call C# from a SPROC?

Is it possible to create a stored procedure that can call a function/generate C# code? I already know how to call a stored procedure from C# (I was surprised at how easy it is, I thought it'd be much more complex) but what I'm trying to do is have a stored procedure generate code based on certain information from SQL, but my problem for...