stored-procedures

LINQ to SQL, Stored Procedure problem handling an INT32 field that can also be NULL

I have a stored procedure that returns two int Values. The first can not be null but the second can actually return a null value. When I try to execute my stored procedure using LINQ to SQL it fails with the statement: "The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type." I tried t...

What is the best way to debug CLR stored procedures

I have a fairly complex CLR stored procedure. What is the best way to debug the procedure? I would like to step through it if possible. ...

How do I display total runtime in SqlServer Management Studio 2005?

I usually do not use Sql Server Management Studio, I usually use Linqpad to run all my db queries. Anyhow.... My boss seems to think that stored procs are "a lot faster than linq". So to test this, I want to run a simple stored proc and display the time it takes to run against an equal linq statement. Any good ideas on how to achie...

Why do I need Stored Procedures when I have LINQ to SQL

My understanding of Linq to Sql is it will take my Linq statement and convert it into an equivalent SQL statement. So var products = from p in db.Products where p.Category.CategoryName == "Beverages" select p Just turns into Select * from Products where CategoryName = 'Beverages' If that's the case, ...

How to Obfuscate SQL Sprocs?

Is there a way to hide/protect/obfuscate MS SQL Stored Procedures? ...

Different execution plan when executing statement directly and from stored procedure

While developing a new query at work I wrote it and profiled it in SQL Query Analyzer. The query was performing really good without any table scans but when I encapsulated it within a stored procedure the performance was horrible. When I looked at the execution plan I could see that SQL Server picked a different plan that used a table sc...

What security benefits are provided by using stored procedures to access data?

I have seen some guidance which recommends that you secure a database by layering all data access through stored procedures. I know that for SQL Server, you can secure tables, and even columns against CRUD operations. For example: --// Logged in as 'sa' USE AdventureWorks; GRANT SELECT ON Person.Address(AddressID, AddressLine1) ...

MS SQL Auditing

Hello. I have a problem with a Database at my work. There is currently auditing in place, but its clunky, requires a lot of maintence, and it falls short in a few regards. So I am replacing it. I want to do this in as generic of a way as possible and have designed the tables, and how everything will link and be updated. Now, thats all ...

Using DateTime in a SqlParameter for Stored Procedure, format error

I'm trying to call a stored procedure (on a SQL 2005 server) from C#, .NET 2.0 using DateTime as a value to a SqlParameter. The SQL type in the stored procedure is 'datetime'. Executing the sproc from SQL Management Studio works fine. But everytime I call it from C# I get an error about the date format. When I run SQL Profiler to w...

Package creation issues using SQL Developer

So I've never worked with stored procedures and have not a whole lot of DB experience in general and I've been assigned a task that requires I create a package and I'm stuck. Using SQL Developer, I'm trying to create a package called JUMPTO with this code... create or replace package JUMPTO is type t_locations is ref cursor; proc...

My SQL sproc with an update

I have a stored procedure that is used when a new transaction is inserted. This procedure inserts properly into the transactions table but I also need to update another related table based on inserted values. Based on the Product_ID I need to update PT_Pct_to_Salon in a table called 'Salon' with a value from a table called 'Zen_Product...

How do I return multiple datatables from a SQL Server stored procedured?

I need to make two queries on two different tables and the data isn't really related. So when I call the stored proc through my code, I should be getting a DataSet with two DataTables, one DataTable for each query. How is that done in SQL Server stored procs? ...

Are stored procedures obsolete?

Duplicate: http://stackoverflow.com/questions/216569/are-the-days-of-the-stored-procedure-numbered Background We have a consultant who develops web applications using PHP and Ruby on Rails (RoR) who is responsible for designing/maintaining/developing a small web application for our company. I needed to build a data-feed from his MyS...

Linked Server Error using MSDTC

I am Showing An example of Stored Procedure For Data Transaction using "Linked Server" Between Two System Through Internet Alter Proc [dbo].[usp_Select_TransferingDatasFromServerCheckingforExample] @RserverName varchar(100), ----- Server Name @RUserid Varchar(100), ----- server user id @RPass Varchar(100), ---...

How to load data from stored linq procedure in combo box?

I have stored procedure in dbml file, I want do smth like this Private Sub GetData() Dim dal = New DataAccess Dim dateList = dal.context.GetAsDateList() Dim enumerator As IEnumerator = dateList.GetEnumerator() While enumerator.MoveNext() cmbDate.Items.Add(enumerator.Current) End While End Sub But I have ...

How to create a MySQL stored procedure from PHP ?

My attempts to query MySQL from PHP with a create statement of a store procedure (SP) have all failed. Is this not possible ? If indeed possible, please give an example. ...

SQL Server: Query fast, but slow from procedure

A query runs fast: DECLARE @SessionGUID uniqueidentifier SET @SessionGUID = 'BCBA333C-B6A1-4155-9833-C495F22EA908' SELECT * FROM Report_Opener WHERE SessionGUID = @SessionGUID ORDER BY CurrencyTypeOrder, Rank subtree cost: 0.502 But putting the same SQL in a stored procedure runs slow, and with a totally different execution plan CR...

How do I optimize my stored procedure?

I ran a profiler today and found that one of my stored procedures is taking a very high CPU read (1899999) and duration (3233333). How can I fix this problem? ...

Insert Data into SQL Table

The Data in my DataTable is like ID ContactName1 Designation1 ContactName2 Designation2 1 A dummy B sam The Table structure of my Table is ID ContactName Designation I am passing the values in the stored procedure as: @ContactName1 @Designation1 @ContactName2 @Designation2 I want a single insert ...

get the value of variable name stored in SQL Sproc

This is what I am trying to do Declare @Var varchar(50) Declare @Num1 varchar(50) Declare @Num2 varchar(50) Declare @Counter smallint Set @Counter=1 Set @Num1='Hello' Set @Num2='Hi' while (@Counter<2) begin Set @Var=N'@Num'+convert(varchar,@Counter) //Now I want to get the value of '@Num1' that is stored in @Var when @Count...