stored-procedures

SQL 2008 Change Data Capture Query Performance Issue (SP vs. straight query)

Before I open a ticket with Microsoft Support, I thought I'd try the community! I have an application in development for which we are using Change Data Capture in SQL 2008 R2 (developer edition, currently). For some particularly complex queries, we wanted to wrap the queries into stored procedures, exposing common parameters, to avoid c...

C# .net and CLR Stored Procedures Question

Are normal operations like: DELETE From Product where ProductId = x faster in CLR then normal MS SQL 2005 Server Stored Procedures? ...

Table choosing algorithm

Below I'm using simple example, real tables are bigger, I cannot store devices in one table, I can not merge device1 and device2 tables. I have three tables: device1, device2, computer(device3), device1 and device2 have id from the same sequence, device3 is computer. Table device3 can be connected with device1 and device2 (many-to-many)...

SQL - Optimizing complex paged search querys

Hi, I'm currently developing a stored procedure for a complex search in a big database. Because there are many thousand entries, that could be returned I want to use paging. Although it is working, I think it's too slow. I read a lot of posts and articles regarding pagination of SQL queries and optimizing performance. But most 'optimizat...

MySQL: failed to create function {functionName}

This works on MySQL 5.0.41, but on 5.1.31 it just says "failed to create function". I type this in the console: delimiter | <press enter> CREATE DEFINER=`root`@`localhost` FUNCTION `ucwords`( str VARCHAR(128) ) RETURNS varchar(128) CHARSET utf8 BEGIN DECLARE c CHAR(1); DECLARE s VARCHAR(128); DECLARE i INT DEFAULT 1; DECLARE boo...

query multiple tables and combine results into one return table for stored procedure?

I have several different tables, but they all have 2 columns that are the same name. I want to write a stored procedure that searches one column in all of the tables and returns the result. Ideas? I'm fairly nub when it comes to SQL. ...

Performance of stored proc when updating columns selectively based on parameters?

I'm trying to figure out if this is relatively well-performing T-SQL (this is SQL Server 2008). I need to create a stored procedure that updates a table. The proc accepts as many parameters as there are columns in the table, and with the exception of the PK column, they all default to NULL. The body of the procedure looks like this: CRE...

How do I use a MySQL Stored Procedure with Variables?

Hi, I found a stored procedure that calculates whether a point is in a polygon or outside of it. But, I'm having a little trouble adapting it to my needs. The stored procedure is called as follows: SET @point = PointFromText('POINT(5 5)') ; SET @polygon = PolyFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'); SELECT myWithin(@point, @...

How to execute stored procedure from Access using linked tables

I have an Access 2003 database that connects to a SQL Server 2008 box via ODBC. The tables from SQL Server are connected as linked tables in Access. I have a stored procedure on the SQL Server that I am trying to execute via ADO code. The problem I have is that Access cannot seem to find the procedure. What do I have to do within Access ...

Stored Procedure could not be found

We use SQL server 2008 as our RDBMS and we have a database that has a different user rather than dbo as its owner. The problem is in one machine a stored procedure can not run unless its owner is mentioned. If we connect to our database using this user and try to execute the following : exec ourSP we get a "could not find ourSP" err...

Perl Dbi and stored procedures

How can i retrive the return value of stored procedure by using perl and the dbi against sql server ? could someone provide example. ...

Failed to execute stored procedure from the JDBC code using mysql connection

Hi, I have one database. I executed a stored procedure on it. I wrote some JDBC code to connect to this database. When I am calling this stored procedure from my JDBC code it is throwing SQLException. One interesting thing I found is that I have one user other than root user. This user has all the privileges to this database where th...

Capture resultset from a stored procedure with varying columns

I am trying to capture the result set of a stored procedure where the number of columns and their data types vary each time. I know if I had a linked server (or had the permission to create one - which I don't) that would refer to its own server I could use openquery to do a select into statement but that is not being possible. Is ther...

Gridview display multiple tables?

I have a gridview setup that gets its data from a SQL database stored procedure. This procedure will return one of several different tables. The gridview complains if the table is different than the one previously displayed. How do I work around this? ...

ASP Stored Procedure to GridView

Hello All, I am attempting to use an existing stored procedure to populate a gridview. First, I execute the stored procedure and use a SqlAdapter to put it into a DataSet. I know this works because DataSet.Tables[0] contains my data. However, when I create a GridView and bind the data to the GridView, nothing is displayed. Here is th...

Problems while trying to make a query with variables in the conditions (stored procedure)

Hi!! I'm having a problem. I'm trying to do a query... I remember that in the past I did something like this but today this query is returning nothing, no error, no data, just nothing... the query is something like this: SELECT field1, @variableX:=field2 FROM table WHERE (SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX A...

Difference between stored procedures and extended stored procedures

What is the basic difference between SQL Server stored procedures (sp_) and extended stored procedures (xp_)? Why there are extended procedures anyway? ...

MySQL stored procedure to INSERT DELAYED but CREATE TABLE first if needed?

I'm planning on doing a lot of INSERT DELAYED into MyISAM tables. But the tables might not exist yet. Let's say e.g. a new table will exist for each day. So instead of detecting absence of table in my client and creating then retrying the insert, it seems like a good case for a stored procedure ("function"). Is this possible, and wha...

SQL Server and Oracle Extended/External Procedures Compatibility

Is a extended/external stored procedure written in C and currently working under SQL Server viable to work under Oracle as well? ...

Why (and when to) use stored procedures?

Possible Duplicate: What are the pros and cons to keeping SQL in Stored Procs versus Code What would be appropriate scenario when stored procedures should be used? I stumbled upon implementation where almost whole data manipulation was handled by store procedures, even simplest form of INSERT/DELETE statements were wrapped an...