stored-procedures

Stored procedure: pass XML as an argument and INSERT (key/value pairs)

How would you construct and pass XML as an argument to a stored procedure on an MS SQL 2005 server? And how would you INSERT the XML into a table? The data is in the form of key/value pairs: [ 0: [key, value], 1: [key, value], 2: [key, value] ] ...

Issues calling stored procedure from C# with large CLOB

Dear all, I'm not the first to have these issues, and will list some reference posts below, but am still looking for a proper solution. I need to call a stored procedure (Oracle 10g database) from a C# web service. The web server has an Oracle 9i client installed and I am using Microsofts System.Data.OracleClient. The procedure takes ...

Have one sproc that debugger won't step into (SQL Server 2008 Developer Edition on Win7x64)

I'm calling an sproc from SSMS, and that sproc calls a number of other ones. I can easily step through the outer sproc and, if I step-into, can walk through the sprocs being called. But one sproc simply won't be stepped into. Attempting to do so acts as if I stepped over it. That is, it runs without being stepped. There is nothing at al...

T-SQL: Creating Stored Procedure that gets Path Folder and inserts into File Path

I have a stored procedure called "sp_BulkInsert" that inserts one .csv file into my database, where you specify the full path of the file when you execute it. I am trying to create another stored procedure called "sp_ResultsDump" where you specify the folder path, which then searches the folder for all .csv files, creates a table with fi...

SQL Table "Pointer"?

Using SQl Server 2000 I have a stored procedure that joins 2 tables and then returns the data. I want this sp to be able to do this for whatever table name I pass into it, otherwise I'll have the exact same code with the exception of the table name 20 or so times in a giant if statement. Basically, how do I use a variable to point to a t...

CallableStatement vs Statement

When calling a Stored Procedure with no arguments and no output is there any advantage to using a CallableStatement over a regular Statement or PreparedStatement? ...

How can I return a list of values from a stored procedure?

Well I am calling a stored procedure from another stored procedure and I need it to return something like an array.How can I do it? ...

Calling stored procedure from Java / JPA

Hi, I am writing a simple web application to call a stored procedure and retrieve some data. Its a very simple application, which interacts with client's database. We pass employee id and company id and the stored procedure will return employee details. Web application cannot update/delete data and is using SQL Server. I am deploying ...

Why would a Stored Procedure run slower than naked T-SQL?

I have a stored procedure in a MS-SQL 2005 database that: Creates two temp tables Executes a query with 7 joins but is not otherwise terribly complex Inserts the results into one of the temp tables Executes two more queries (no joins to "real" tables) that puts records from one of the temp tables into the other. Returns a result set fr...

Providing support for access to stored procedures for data transformation product

I work a data transformation product that has a GUI interface that maps one type of object to another. So it has a bunch of elements on the left that maps to elements on the right. These can be XML, Java, or database. With database the product is built on top of Hibernate, so it creates the definitions based on importing the metadata and...

SQL Filtering A Result Set To Return A Maximum Amount Of Rows At Even Intervals

I currently use SQL2008 where I have a stored procedure that fetches data from a table that then gets fed in to a line graph on the client. This procedure takes a from date and a too date as parameters to filter the data. This works fine for small datasets but the graph gets a bit muddled when a large date range is entered causes thousen...

Grab result set and return value both from stored procedure in Linq to Sql

CREATE Procedure dbo.Ssample AS Select 1 as One , 2 as Two ,'3' as Three RETURN 2 --T-SQL way to execute declare @a int exec @a = dbo.Ssample select @a How can I retrieve the return value and the result set both in linq to sql. I would appreciate if anyone can give me the dbml markup as my designer file always get auto gener...

C# / Execute Parameterized SQL StoredProcedure via ODBC

Hello, from within a C# WinForms-App I must execute a parameterized Stored Procedure on a MS SQL Express Server. The Database Connection works, the Procedure works either, but I get an Error Message: 42000: Missing Parameter '@KundenEmail' although I'm sure I added the parameter correctly. Maybe some of you could have a look - I ...

Creating entities from stored procedures which have dynamic sql

I have a stored procedure which uses a couple of tables and creates a cross-tab result set. For creating the cross-tab result set I am using CASE statements which are dynamically generated on basis of records in a table. Is it possible to generate an entity from this SP using ADO.NET Entity framework? Cuz each time I try Get Column Info...

Return @@RowCount in LINQ to SQL INSERT

I am in the process of migrating some legacy code to LINQ to SQL and I am having some difficulty with the following Stored Procedure. BEGIN INSERT INTO tblCMOEncounterHeader ( submitter_organization_id, submission_date, begin_posting_date, end_posting_date, number_of_records_transmitted) ...

Using LINQ calling a sproc, how can I pass a var back from a method?

I have this method which worked for a while public string getSlotText(int slotID) { DataClasses1DataContext context = new DataClasses1DataContext(); var slotString = context.spGetSlotTextBySlotID(slotID); return slotString.ElementAt(0).slotText; } But what i really want now is something like public var getSlotText(int ...

SQL Server DateTime parameter 'rounding' warning

More of a warning than a question: We resolved a very puzzling bug this morning. We have a variety of reports that allow users to enter date ranges they want to run. The assumption is, if you ask for a report from 8/1/2010 to 8/10/2010 you meant to include 8/10/2010 so the end-date of the report isn't 8/10, it's something after that. I...

Create delimited string from a row in stored procedure with unknown number of elements

Using SQL Server 2000 and Microsoft SQL Server MS is there a way to create a delimited string based upon an unknown number of columns per row? I'm pulling one row at a time from different tables and am going to store them in a column in another table. ...

Convert DAL function into Stored Procedures in mysql

Hi I have class for my Data Access Layer that contains a function called GetCitiesByLocation and it looks like this public DataTable GetCitiesByLocation(long pStateID, string pKeyword) { //create database object Database db = DBHelper.CreateDatabase(); //create SELECT sql statement to be executed using string builder /...

Linq to SQL question: How to retrieve return value and resultset from Stored Proc

Folks, I have a stored proc as following: create procedure p1 as begin declare @n1 int select @n1=count(*) from Employee select top 100 * from Employee return @n1 end I want to capture @n1 as well as the Employee resultset using Linq To SQL in my C# code. I would appreciate any...