stored-procedures

User Granted Access to Stored Procedure but Can't Run Query

I am working on a product that runs an SQL server which allows some applications to login and their logins are granted permission to run a stored procedure- AND NOTHING ELSE. The stored procedure is owned by an admin; the stored procedure takes a query and executes it, then the results are returned to the application. Unfortunately I c...

Is it possible to use output parameters with ExecuteQuery<T>?

Normally, when you want to call a stored procedure directly through Linq to Sql, you can use the ExecuteQuery method: result = dc.ExecuteQuery<MyTable>("Exec myStoredProcedure"); And if you need to call it with parameters, you can add them through string substitution: string query = "Exec myStoredProcedure "; for (int i = 0; i < para...

How to debug stored procedures in Sybase ASE?

Is there a good tool from either Sybase or elsewhere that will enable me to debug stored procedures in Sybase ASE? I need to be able to set breakpoints & watchpoints. Previously, in Sybase ASA (not ASE), I used Sybase Central to do this. There is a plugin for ASE, but I doubt it will let me debug procedures. ...

Stored Procedure Execution Plan - Data Manipulation

I have a stored proc that processes a large amount of data (about 5m rows in this example). The performance varies wildly. I've had the process running in as little as 15 minutes and seen it run for as long as 4 hours. For maintenance, and in order to verify that the logic and processing is correct, we have the SP broken up into secti...

SQL - how to check table for new data?

Hey, I need to create a stored procedure that upon exceution checks if any new rows have been added to a table within the past 12 hours. If not, an warning email must be sent to a recipient. I have the procedures for sending the email, but the problem is the query itself. I imagine I'd have to make an sql command that uses current date...

Why can't a stored procedure read a table from another database (I must be using GRANT and DENY wrongly)

I have two Microsoft SQL Server 2000 databases, and a stored procedure on one tries to read data from the other. This used to work fine, but since I became security-conscious and changed the login (SQL user) from "db owner" to "denydatareader" the call fails. I can get things working if I use the group "datareader", but since I do not w...

Best way to implement a stored procedure with full text search

I would like to run a search with MSSQL Full text engine where given the following user input: "Hollywood square" I want the results to have both Hollywood and square[s] in them. I can create a method on the web server (C#, ASP.NET) to dynamically produce a sql statement like this: SELECT TITLE FROM MOVIES WHERE CONTAINS(TITLE,'"holly...

Stored Procedure & LINQ, Dmbl File unable to interpret the result set

I have several Stored Procedures that when added to my dbml, it seems that behind the scenes LINQ can not interpret the result set and will simply map the result as an int. I then have to create the result class myself which is a pain but also I have to go and change the designer file every time I add to my dbml because it will re-load ...

Union or Use Flow Control Logic to Determine which table to report on

I'm working with a 3rd pary app where I can't alter the tables. We built custom matching "Monthly" tables with an additional datetime column "AsOfDate" where we dump the data at the end of the month and flag those data with the date of last day of the month. I want to be able to create a single Stored Procedure (Application is designed ...

Setting classpath for a Java stored procedure in Oracle

I've got an Oracle 10g database, and I have a third-party jar file. I want to be able to run a SQL select query in my database that ultimately runs code in my third-party library to retrieve info for inclusion in a SQL result set. I see lots of tutorials on "Java stored procedures" and these seem to be a promising way to do this, but n...

PL/SQL issues returning a sequence scalar value

I'm trying to return sequence.nextval to my program from a proc stored in a package. I'm pretty green when it comes to PL/SQL and I'm kind of at a loss as to what is happening. The error that is actually being return is PLS-00306: Wrong number or types of arguments in call to PROCGET_BOOKMARKID line 1, column 7 statement ignored. He...

SQL Cursor w/Stored Procedure versus Query with UDF

I'm trying to optimize a stored procedure I'm maintaining, and am wondering if anyone can clue me in to the performance benefits/penalities of the options below. For my solution, I basically need to run a conversion program on an image stored in an IMAGE column in a table. The conversion process lives in an external .EXE file. Here ar...

How can I get dbX.dbo.procA to run in the context of dbY?

I want to separate a specific set of stored procedures into a seperate database … sort of like a library. However, when I run these procs from another database, they appear to call objects from within the library database. Here is some source code which demonstrates the problem use mylibdb go create proc gettablecount as begin de...

How to execute sp_send_dbmail while limiting permissions

Is there a way to provide access to users in my database to execute msdb.dbo.sp_send_dbmail without needing to add them to the MSDB database and the DatabaseMailUserRole? I've tried this: ALTER PROCEDURE [dbo].[_TestSendMail] ( @To NVARCHAR(1000), @Subject NVARCHAR(100), @Body NVARCHAR(MAX) ) WITH EXECUTE AS OWNER AS BEGIN ...

Any Static Code Analysis Tools for Stored Procedures?

Are there any static code analysis tools for stored procedures written particularly in PL/SQL and T-SQL? ...

Stored procedure - Send a list of parameters in for use with the IN clause

[DUPLICATE of http://stackoverflow.com/questions/337704/parameterizing-a-sql-in-clause] Issue: I need to send in a list of values into a stored procedure for use with an IN statement in the WHERE clause. Example: declare @SPType NVARCHAR ( 30 ) declare @SPCodeA int set @SPCodeA = 75 set @SPType = '''I'',''M''' select * from tabl...

Sample script for calling a stored procedure with loadrunner?

Im very new to loadrunner. I couldnt find any online material on running stored procs (for mssql) for loadrunner script. it says it need to be ansi c. I even wrote a c# that connects to db and call the stored proc in question and then used it for "recording" the task. after running it, it didnt generate the script i was hoping for. is th...

Best Approach for Cloning database records using SPs

Hi, I have to write code to clone a database entry with associated data in other tables and assign it a new ID. Simplified I have a MAIN Table with a key of ID and sub table say SUB1 with FK of ID and multiple records for each entry in MAIN. I want to copy the data for a specific ID in MAIN to new records updating the ID to a new value...

Complex processing in Stored procedures Vs .net application

We are building a new application in .net 3.5 with SQL server database. The database is fairly large having around 60 tables with loads on data. The .net application have functionality to bring data into this database from data entry and from third party systems. After all the data is available in database the system have to do lots of ...

Writing the content of a local variable back to the resultset column?

Hello! Is it possible, by using a stored procedure, to fetch a column value from resultset into a local variable, manipulate it there and then write it back to resultset column? The column datatype is integer. How would the syntax to write the value back look like? Thanks in Advance... :-) ...