stored-procedures

T-SQL stored procedure returns null in code, but works in console

I have a stored procedure CREATE procedure [dbo].[get_unique_identifier] AS DECLARE @ret_val INT UPDATE seq SET @ret_val = id = id + 1 RETURN @ret_val that queries a table (seq) that has a single int column and single row, increments the value and then then returns it. Don't ask why I'm doing this, but in short, the idea is to simulat...

Stored Procedures not that fast?

Hoho there. I was just trying to enhance the performance of my application (.NET 3.5, C#) with the use of stored procedures. So I wrote a little test-app to see how much faster these are in comparison to normal queries which looks like this: private static long _StartStored; private static long _EndStored; private static l...

How to encrypt all existing stored procedures of a database

Is there any possibility to encrypt all existing stored procedures of a SQL Server 2008 database AFTER they have been created via an SQLCMD script? The reason I want to do this is the following: I'd like to develop the stored procedures without encryption so I can easily click on "Modify" in SQL Server Management Studio to check their c...

filling custom c# objects from data received stored procedure

public class User { public string FirstName { get; set; } public string LastName { get; set; } } public class Address { public string City { get; set; } public string Country { get; set; } } /* * There are 2 c# objects i have shown * There is a stored procedure in my application which * returns data for both objects ...

Is it possible to have a stateless timed function.

I'm trying to set a reminder in a system to fire at a certain time. This is a web based app, so it's not like it will be in memory all the time. Ideally I'd like to avoid using a service or job on the server(mainly out of curiosity, to see if there is a more efficient way to do it) For example, imagine how many Ebay bids are constantl...

I need help for writing a Stored Procedures in SQL Server 2005

I’m a newbie in Stored Procedures in SQL Server 2005. Let’s say we have a table with these columns: Id (GUID), UserId (string), DayOfYear (int), Score (int). I need a SP with one input (inputDayOfYear) which copy last day (inputDayOfYear=10 => last day DayOfYear=9) data with new Id but old UserId and Score, and current DayOfYear (th inp...

MySQL calling a stored proc from another stored proc.

I am working on a stored proc (parent) that calls another stored proc (child). The child proc returns a record set with 1 row every time. What I need to do is pull the data from the child proc and use it in the parent proc. Using methodology from MSSQL I would assume I could just populate a temp table, but I am not quite sure how to do...

RIA services, EF and stored procs

I have this problem for 2 months now How can I use stored procedures whith RIA. I was using LinqToSql and everithing works fine. I've made an class in designer and mapped it to a SP. Now in EF I saw this ComplexTypes I've imported son SP with result in ComplexTypes. But in DomainDataSource are not appear. OK. But how can I use the...

Oracle Stored Procedure with out parameter using Nhibernate

How can I access the value of an out parameter of an oracle stored procedure in the .net code - Oracle stored procedure being called via Nhibernate? Sample working code would help. ...

Transaction count exception in vb.net (SQL Exception)

I am getting below exception when i am going to enter record in a table through StoredProceduer of sqlserver i have a field which i need u update immediately after insert of new record in table. for that i created a sotredprocedure in which i wrote insert command first and after that i wrote a update command for same recored but it gave ...

stored procedure exception handling in asp.net

Do i need to use try catch in my stored procedure to know where exactly in my procedure error has occured or can i achieve the same if i useSqlConnection.BeginTransaction in my ASP.NET form or simple try catch may be...??? I tried implementing try catch in my stored procedure..i m using sql server 2005 but it does not know TRY and CATCH...

optional parameters in SQL Server stored proc?

Hi everyone, I'm writing some stored procs in SQL Server 2008, and wondered if the concept of optional input parameters is possible here? I suppose I could always pass in NULL for parameters I don't want to use, check the value in the stored proc, then take things from there, but I was interested if the concept is available here. Th...

Problem with xml select in tsql - can't seem to orgenize multi nodes in the right order

Hello every one....this is my code, i am trying to make a simple 3 nodes select in XML and it is not working, i am getting the parent, the second nodes (all of them) and then the third nodes (all of them) (categories->category(all)->products(all) and not in the right order (categories->category->all products for that category) selec...

Performance Standalone Procedure vs Packaged Procedure in Oracle

What is the difference of performance between standalone procedure and packaged procedure? Which will be good performance wise and why? Is there any difference in execution of both? ...

stored procedure error handling

i have this procedure for inserting rows in tables(sql server 2005) CREATE PROCEDURE ans_insert ( @q_desc varchar(2000), @sub_id int, @marks int, @ans1 varchar(1000), @ans varchar(1000), @userid varchar(15), @cr_date datetime ) AS BEGIN BEGIN TRY BEGIN TRANSACTION DECLARE @q_i...

How to Insert Records based on the Previous Insert?

Here's my procedure: PROCEDURE add_values AS BEGIN INSERT INTO TABLE_A ... SELECT t.id, t.name FROM TABLE_C ("This selection will return multiple records") END While it inserts in TableA, I would like insert into another table(TableB) for that particular record which got inserted in tableA. The columns in TableA and TableB ar...

Is it wiser to use a function in between First and Next Insertions based on Select?

PROCEDURE add_values AS BEGIN INSERT INTO TableA SELECT id, name FROM TableC ("This selection will return multiple records") While it inserts in TableA i would like insert into another table(TableB) for that particular record which got inserted in tableA Note:The columns in TableA and TableB are different , is ...

Linq to SQL with Stored Procedures

I want to add custom (compound and read-only) attributes to my stored procedure results class. When I did that, I got the error LINQ - Cannot assign value to member XXX. It does not define a setter. I then found this blog post - the author suggests that decorating the partial class with the [Table] attribute will resolve the problem. ...

How to DROP a version of a Stored Procedure in SQL Server

We have some legacy stored procedures that use the now deprecated feature of SQL Server that allowed you to create multiple versions of a procedure within a procedure. For instance we have.. [up_MyProc] [up_MyProc];2 You can still create these "versions" by appending the version on the end of the name. However without dropping the p...

Combining 2 TSQL statements into 1

Hi, I need to combine the following two SQL statements into one. Any help is greatly appreciated. Thanks. SELECT C.*, M.members_Email FROM tbl_Campaigns C JOIN tbl_Members M ON C.campaign_MemberId = M.members_Id WHERE C.campaign_MemberId = @userID ORDER BY C.campaign_Key DESC SELECT COUNT(*) FROM tbl_CampaignRecipients WHERE reci...