stored-procedures

Complicated MySQL Stored Proceedure

I have a semi-complicated stored proceedure that I need to create. I'm not exactly a DBA here but no one else in my company is better than I am. The basic idea is I have a group of tasks. The user completes these tasks and gets a flag for each task completed. To be considered "complete" the user has to have all of a group of given tasks ...

Pagination in for searching

table 'sample' contaning fields [AffiliateId] as a primary key, [AffiliateCode] L, [Name] , [AddressId] [, [Url] , [EmailId] , [ShopId] , i need a stored procedure for custom paging ...

MySQL: Views vs Stored Procedures

Since MySQL started supporting stored procedures, I've never really used them. Partly because I'm not a great query writer, partly because I often work with DBAs who make those choices for me, partly because I'm just comfy with What I Know. In terms of doing data selection, specifically when considering a select that is essentially a d...

Problem updating Connection String in Visual Studio Sql Service Projects

I have created a few clr stored procedures and had them setup to our development environment. I now want to update the connection string on the database tab of the project but its not saving. Here is the list of things I have done: I checked to make sure that the project file and user project file were not read-only I have deleted th...

How to Find the list of Stored Procedures which affect a particular column ?

Im working on this large DB which has a lot of the business knowledge embedded in the SPs[I know!] and there is a lot of chaining between the SPs. i.e one stored proc calling another. Im want to find out a list of stored procedures which update a particular column. How would I do that. Using showplan_All as outlined in http://stacko...

Need a tool to automatically indent and format SQL Server stored procedures

In my current project I've been inherited with lots of long (1200+ lines) SQL Server stored procedures with some horrible indentation and formatting which makes them almost unreadable. Is there some tool that I can use to automatically format these and make them more readable? I don't want to go through it manually and indent it. ...

Why is maximum length of varchar less than 8,000 bytes?

So I have a stored procedure in a SQLServer 2005 database, which retrieves data from a table, format the data as a string and put it into a varchar(max) output variable. However, I notice that although len(s) reports the string to be > 8,000, the actual string I receive (via SQLServer output window) is always truncated to < 8,000 bytes....

MySQL How to INSERT INTO [temp table] FROM [Stored Procedure]

This is very similar to question 653714, but for MySQL instead of SQL Server. Basically, I have a complicated select that is the basis for several stored procedures. I would like to share the code across the stored procedures, however, I'm not sure how to do this. One way I could do this is by making the shared select a stored procedu...

Which ORM is the best when using Stored Procedures

So, I asked before what a good ORM was and the answer seemed to be nhibernate. I went through the giant learning curve and well it’s awesome, but totally won’t work for me. I sadly must use stored procedures and its ability to use them is very limited. So I have Business objects (DEVELOPERS WRITE) and some SPROCS (DBA WRITE)…… I know wh...

How do you get full error information for a stored procedure error out of LINQ-to-SQL or SQL Server?

Hi, I am calling a stored procedure through LINQ-to-SQL (yes, I know it's deprecated). I am getting back an error, but the IExecuteResult only seems to be able to provide me with a number, when I would like the full string error description (like what you would get if you executed the SQL by hand in SQL Management Studio). Alternatively...

What's the most elegant way to use stored procedures?

I'm re-writing the inline SQL in my repository class to use stored procedures instead (security requirement). After using Fluent NHibernate and Linq2Sql in the past I'm finding it to be extremely unwieldy and inelegant. EDIT: To clarify, I'm not looking for an ORM solution that works with stored procs. I just want some advice on a nice ...

Exporting Dataset to Excel

Greetings all, I have the following bit of code that I have used in the past to export a DataSet generated from the Stored Procedure 'HISTORICAL_COSTS' to Excel. Dim c As Long = 1 For Each dc As DataColumn In Me.WOCostDataSet. & _ HISTORICAL_COSTS.Columns .Cells(1, c).Value = dc.ColumnName.ToString ...

How do I Execute SQL Stored Procedures from within another Stored Procedure?

Everytime I refresh my DB with a backup file. I have to run about 10 stored procs separately because the backup file does not contain them. Is there a way to have one single sql script that refrences all these 10 stored procs and just run that ONE file compared to TEN? ...

SQL Multiple Parameter Values

What options are available in SQL 2005 to pass in multiple values to store procedures Psuedo codes In C# code List<string> myApplicationList; .... (code to assign values) **Construct parameter list** Call stored procedure [spSelectMaster] with myApplicationList SQL stored procedure CREATE PROCEDURE [Ecn].[spSele...

Performance Implications of Comments in SQL Stored Procedures

Recently at my day-job were were instructed that any comments regarding our stored procedures MUST NOT exist inside the stored procedure and rather Extended Properties must be used. In the past we used something like this. /* * NOTE: Auto-Generated Procedure DO NOT MODIFY */ CREATE PROCEDURE dbo.MyProc AS SELECT * FROM MyTable GO T...

String literals not supported in stored procedure calls to DB2 for z/OS

I'm getting the error below when calling a simple SP from the Rational Application Developer Data Perspective when connecting to a DB2 DB instance running on z/OS. Also when calling from SQuirreL. Straight SQL queries run no problem. The query also works fine when called from my JAVA code. 'Error: [ibm][db2][jcc][10243][10940] Stri...

Enterprise library caching parameters on stored procs?

I'm trying to standardise some data access code with my colleagues. One of the aforementioned colleagues asserts that the EntLib Data Access Block trys to cache parameters on stored proc calls. I've had a look in reflector and there is some evidence that it could be caching them. But I don't think it does in the following situation. ...

db2 storage error when running stored procs

I am seeing the above error when running a small number of stored procs in our application. The actual error that we get is sqlcode=-930, which according to the db2 documentation is: 'There is not enough storage available to process the statement.' Question: how can i increase the storage available to these procs? has anyone else enco...

iSeries stored procedure - how to get handle on the spool file output?

We have a stored procedure written using a CL and RPG program combination. When called locally on the iSeries all is fine. When called externally (for example from a SQL frontend) the RPG program cannot get a hadle on the spool file it produces because the spool file appears under a different (random?) job number and user. The jobs run ...

Pass Query Result to a csv file and Send it as attachement using SQL Server 2005

I have two tasks and since I am new to it, I need some help/advice from the masters. What I need to do is send the result of q select query to a csv file which can have delimeter as comma or tab and then send this file as an attachement to a particular receipient. Hoping for some great advice ...