SQL Server :: Stored Procedure - EXECUTE And EXECUTE Sp_executesql
Mar 10, 2011
I am looking through a sql stored procedure which I might need to update in the near future. Basically the stored procedure is about 20 lines long. The stored procedure first builds a query
and stores it in a variable named "@Sql". And then for the last two lines of the stored procedure it appears that the big sql statement stored in "@Sql" is executed by using the "EXEC" command. See below. What is confusing though is that the query appears to be exectuted twice? Why was the query written in this way. Don't both lines do the same thing? Why is it being done twice? Could this possibly be a mistake on the
part of the person who wrote the query. Below are the two lines I am talking about?
In my stored procedure there are 8 queries for 8 tables.Each query has joins and sub queries. I am passing parameters & stored procedure name from front end(designed in asp.net 3.5) can we execute that 8 queries at the same time i.e. parallel execution so that I can minimize stored procedure execution time?
I am getting frustrated with this problem, I dont know what i did, but now I cannot execute any stored procedured when I could last time.When I use my asp.net application to run the query, it finds the stored procedure but when I execute it is sql management studio it says it cannot find the stored procedure even though it is there.I tried to execute other procedures and the samething happens. Even when I try a simple query it says it cannot find the tableI could execute the query if i placed Use [databasename] in front, but even with this, I cannot execute stored procedures.
i need to execute stored procedure on linked server (create procedure on linked server). i had try with this:
[Code]....
SQL code is looking like this
[Code]....
UDBV68 is linked server... Now, when i execute procedure from asp.net i got error 'Incorrect syntax near 'GO'.', but sql server doesn't report error...
Dbcall has value = "EXECUTE ('Create Procedure SelectOne as Select * From FixitOnline.Os_node ',952) AT UDBV54; GO"
sing VS 2008 at a workstation, I have successfully developed a local, file-system ASP.NET 3.5 website. The wbesite included a membership page with Windows authentication and a web parts page. The SQL Server 2005 ASPNETDB database has been created at an IIS web servr. Using the ASP.Net development server of the workstation, both the membership Membership/WebParts pages at the local website worked very well.
Then, I copied the website to a virtual directory at the IIS web server and creates a remote website for the workstation. Under theASP.NET development server of the workstation, both membership and webparts pages of the remote website at the IIS web server also worked fine.
However, when running these web pages from the IIS web server machine, something wrong happened with the web parts page. (The membership page still worked very well.) For the ASPNETDB database at the IIS web server machine, there is an EXECUTE permission error on an ASPNET stored procedure.
What are the differences between the ASP.NET development server and IIS web sever, which caused the EXECUTE permission error on the ASP.NET S.P.? How to find and fix the errors?
I am trying to execute a stored procedure in LINQ. When run in SQL Server it returns several fields, mostly integer and float fields. But when I call the stored procedure in LINQ, all it returns is 0. Here is how I am calling the stored procedure :
I have a stored procedure in SQL server 2000. It is a simple select query and returns a list of account names. However, when I try to execute the stored procedure, it automatically declare @return_value as int and return this int as shown below:
I am building a website that mostly uses Stored Procedures, but now I am facing a problem such that I want to execute the Stored Procedure more than one time each with a different value .
such that when I am calling it from the .vb page I could not execute it more than one time
Is it possible to save execute stored proc command in a string variable and then execute string variable? Does this logic fits into LINQ2SQL? Why I want to do this - INstead of passing user control references to server, I want to save user control values to string in client side java script and then pass string to server to do actual stored proc execution. Hopefully this will improve performance.
I am using a gridview where i am calling a stored procedure which has 4 input parameters. Out of these 4 parameters, values are to be given such that DomainId = This has to be the row which is to be deleted. This is a primary key Domain = This field has to be passed to SP as NULL. Description= This field has to be passed as NULL. OperationType= This field has to be passed by programmer as some static value say 4 How to i need to specify these here... More details of the Question are here.
I need to run a stored procedure from an aspx page but because it takes a long time to complete, it times out at MyDataAdapter.Fill. This sp doesn't return any recordset but the number of records affected would be nice.
Protected Sub BtnProcessDT_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnProcessDT.Click Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyDataAdapter As SqlDataAdapter MyConnection = New Global.System.Data.SqlClient.SqlConnection MyConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("RevConnectionString").ConnectionString MyDataAdapter = New SqlDataAdapter("uspINSERTDT", MyConnection) MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@RowCount", SqlDbType.Int, 4)) MyDataAdapter.SelectCommand.Parameters("@RowCount").Direction = ParameterDirection.Output DS = New DataSet() 'Create a new DataSet to hold the records. MyDataAdapter.Fill(DS, "RowCount") 'Fill the DataSet with the rows returned. Basic syntax of the stored procedure. It SELECTS a single record (at a time) from a table, processes the data and UPDATES four other tables. ALTER PROCEDURE [dbo_DHT].[uspINSERTDT] (@RowCount INT OUTPUT) AS BEGIN select @RowCount=@@ROWCOUNT END
Do I need to create a DataSet if all I want to do is capture the number of records? How do I increase the timeout? This is strictly an intranet web application used by one person so performance isn't a big priority. Editing the sp to reduce the amount of time to process isn't practical due to the amount of processing that occurs.
VS2005 Version 8.0.50727.42 (RTM.050727-4200) .NET framework version 2.0.50727.3603 SQLExpress 2005 9.00.3042.00
I've searched and searched for this all day, but can't seem to find the answer. I'm looking to execute a stored procedure by clicking a button. I've set this up in a code behind manner, rather than using a datasource.
The stored procedure doesn't return any rows. All I need to do is pass a variable through it. I think I have it set up correctly, however it keeps saying the stored procedure expected the @pin variable. Here's my code:
[Code]....
I've tried changing sp1 to pin and @pin, thinking that was the problem. Am I missing something?
I need to execute a stored procedure which is a simple delete (record) query. Programmaticaly, I want to pass in a parameter "ID1".
Assume I will pass in the ID1 parameter on a delete link click event froma GridView control. What would the code be to execute the existing stored procedure?
ID1 - the parameter and primary key of the source database for the record to be deleted
GridView1 - the GridView control
spDeleteRecord - the stored procedure needing the parameter ID1 and to be executed from C# code
DeleteTableAdapter - an existing TableAdapter for the existing
basically i have two dropdown boxes to filter data and textbox with stored procedure bound to gridview.i want to be able to query data depending on the selected value passed,either using one or more parameter values.
i would like seperate sqlcommands to chose from depending on which controls i select to pass parameters.
i have included a parameter Select(control id) as this is declared by the wizard for stored procedure.
but i am not sure how it is defined on the page and passed to procedure.