Tag: stored-procedures

Register output parameter for calling stored procedure in SQL

I have this stored procedure: create procedure sp_findMaxEmployee @maxID as varchar(10) OUTPUT as SET @maxID = (SELECT MAX(e_ID) FROM Employee) go I try to register an output parameter like this: public string generateID() { connection = new SqlConnection(connectionStr); cmd = new SqlCommand(“sp_findMaxEmployee”, connection); SqlParameter param = new SqlParameter(); param.ParameterName = “@maxID”; param.Direction = ParameterDirection.Output; param.SqlDbType […]

SQL Server 2008 – INSERT for table working but UPDATE/DELETE hangs

I have a dead simple stored procedure which only does an INSERT to a table. The stored procedure takes several parameters (it’s called from C# code) and does a simple insert. Everything works fine with the insert – however, in some cases, there might be a PK violation, in which case I check the error […]

VB: Stored Procedures and Passing in Parameters

I am having a difficult time getting a stored procedure to execute with a parameter being passed into it. I have changed out the code with different examples from the web, but I keep getting the below error, so I must be ding something wrong. *Conversion failed when converting the varchar value ‘Error’ to data […]

Some issue with logical tables (DELETED, INSERTED) in procedure

I try use logical tables in procedure but I have error: “Invalid object name DELETED” So first question can I use logical tables in procedure? If yes how can I do this? This is a code USE Operator GO CREATE PROCEDURE generuj ( @nazwaTabeli VARCHAR(20) ) AS BEGIN SET NOCOUNT ON; — — Check if […]

Procedure or function “Procedure name” expects a parameter “Param name” which was not supplied occurs rarely

I have a web service function in VB.NET that will send parameters to a SQL Server stored procedure. Everything works perfectly for two months in the deployed machine. But now the error Procedure or function GetEmployeeDetails expects a parameter @Progress which was not supplied’ occurred only once on the deployed machine. Before and after the […]

sql server(Find the difference between 2 columns in 2 rows )

I am having a problem with a Cashback Report I am building. Here is the code of my Stored Procedure and what i want. –SP CODE CREATE PROCEDURE [dbo].[CashbackPromo] @startDate DateTime, @endDate DateTime AS create table #CashbackInfo ( UserID int, PreviousBal money, DepositAmount money, NewBalance money, LostMoney money ); –DECLARE @startDate DateTime =’2014-06-07 00:00:00′ –DECLARE […]

Map Stored Procedure Result without Columns to a Model

I have a stored procedure that returns two columns without specifying their name, one is the ID (int) and the other one is a string. It is not possible for me to alter the stored procedure so that it can return the results with column names If I let Visual Studio to create the .edmx […]

Stored procedure with optional parameters

I have a C# application that sends the parameters to the following stored procedure: @Lot nchar (112)= NULL, @Oper nchar (112)= NULL SELECT [Lot].Lot, lot.Oper FROM DB where (@Lot is null or ( Lot= @Lot)) and (@Oper is null or ( Oper= @Oper)) I cannot get any results if I leave fields blank in my […]

Dynamic table pivot on store procedure

I’m doing a web interface to bind objects to users. I use SQL Server 2008 R2. It is object of a different kind. I have a desire to display a table dynamically in SQL to avoid doing it in PHP (which would be cumbersome and time to be displayed). I explain a bit of my […]

SQL Server: Intermittent Invalid object name 'dbo.computed_view1'. Could not use view or function 'dbo.view2' because of binding errors

I’m using SQL Server 2008 R2. I have a view; let’s call it view1. This view is complex and slow. It cannot be made into an indexed view because it uses left joins and various other trickery. As such, we created a stored procedure which basically: obtains an exclusive lock selects * into computed_view1_tmp from […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.