Help: Why Excute A Stored Procedure Need To More 30 Seconds, But Direct Excute The Query Of This Procedure In Microsoft SQL Server Management Studio Under 1 Second
May 23, 2007
Hello to all,
I have a stored procedure. If i give this command exce ShortestPath 3418, '4125', 5 in a script and excute it. It takes more 30 seconds time to be excuted.
but i excute it with the same parameters direct in Microsoft SQL Server Management Studio , It takes only under 1 second time
where wtcomValidRelationships.[IDMember]= @IDMember
and PATINDEX('%'+@IDOther+'%',(select RelationshipIDs from wtcomValidRelationships where IDMember = @IDMember) ) > 0
end
if (@Level = 2)
begin
select top 1 @Path = convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)
from wtcomValidRelationships as A, wtcomValidRelationships as B
where A.IDMember = @IDMember and charindex(convert(varchar(100),B.IDMember),A.RelationshipIDS) > 0
and PATINDEX('%'+@IDOther+'%',B.RelationshipIDs) > 0
end
if (@Level = 3)
begin
select top 1 @Path = convert(varchar(100),A.IDMember)+ '-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)
from wtcomValidRelationships as A, wtcomValidRelationships as B, wtcomValidRelationships as C
where A.IDMember = @IDMember and charindex(convert(varchar(100),B.IDMember),A.RelationshipIDS) > 0
and charindex(convert(varchar(100),C.IDMember),B.RelationshipIDs) > 0 and PATINDEX('%'+@IDOther+'%',C.RelationshipIDs) > 0
end
if ( @Level = 4)
begin
select top 1 @Path = convert(varchar(100),A.IDMember)+ '-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)+'-'+convert(varchar(100),D.IDMember)
from wtcomValidRelationships as A, wtcomValidRelationships as B, wtcomValidRelationships as C, wtcomValidRelationships as D
where A.IDMember = @IDMember and charindex(convert(varchar(100),B.IDMember),A.RelationshipIDS) > 0
and charindex(convert(varchar(100),C.IDMember),B.RelationshipIDs) > 0 and charindex(convert(varchar(100),D.IDMember), C.RelationshipIDs) > 0
and PATINDEX('%'+@IDOther+'%',D.RelationshipIDs) > 0
end
if (@Level = 5)
begin
select top 1 @Path = convert(varchar(100),A.IDMember)+ '-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)+'-'+convert(varchar(100),D.IDMember)+'-'+convert(varchar(100),E.IDMember)
from wtcomValidRelationships as A, wtcomValidRelationships as B, wtcomValidRelationships as C, wtcomValidRelationships as D, wtcomValidRelationships as E
where A.IDMember = @IDMember and charindex(convert(varchar(100),B.IDMember),A.RelationshipIDS) > 0
and charindex(convert(varchar(100),C.IDMember),B.RelationshipIDs) > 0 and charindex(convert(varchar(100),D.IDMember), C.RelationshipIDs) > 0
and charindex(convert(varchar(100),E.IDMember),D.RelationshipIDs) > 0 and PATINDEX('%'+@IDOther+'%',E.RelationshipIDs) > 0
end
if (@Level = 6)
begin
select top 1 @Path = '' from wtcomValidRelationships
Dear all, I am using C# , asp.net and sql server 2005. Let me explain the situation. I have written procedure to insert data into the table and return last inserted value by @@identity variable. Now my question is how do I execute this process so that I can Get last inserted variable values Please help thanks
I am using MS sql 2000. I think I need to use SQL agent to run a job, but not sure how to call up the procedure! The procedure runs collectly when run from SQL query.
i create a function("changefilepermission") to execute a procedure ("grant_file_access") to change the file permission. i click the permission checkbox to change new permission, after that i will click the submit button to update change to the database. but it does not change to the database. this is my part of code. is anybody can give me a help?
thanks in advanced!!!!!!!!!
Private Sub btnsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSubmit.Click
Dim FileTitle As New String("") Dim FileName As New String("")
FileName = DGPermission.Items.Item(0).Cells(0).Text 'retrieve filename from datagrid FileTitle = DatabaseCommand(userid, "fa_title", filename) ' retrieve the filetitle from table
Dim permission As Char ' set the permission value If (CkRead.Checked) Then Permission = "r" ElseIf (CkWrite.Checked) Then Permission = "w" ElseIf (CkExecute.Checked) Then Permission = "o" End If
Try ' call the store procedure function by passing 4 value ChangeFileAccess(userid, FileName, FileTitle, Permission) ' Catch ex As Exception lblErrorMsg.Text = ex.ToString End Try End Sub
' execute store procedure function Public Sub ChangeFileAccess(ByVal userid As String, ByVal DiskFilename As String, ByVal Title As String, ByVal Access As Char) Dim UpdateCommand As SqlCommand UpdateCommand = New SqlCommand
With UpdateCommand .Connection = SqlConnection .CommandType = CommandType.StoredProcedure .CommandText = "Grant_File_Access" .Parameters.Add("@vu_id", SqlDbType.VarChar, 20).Value = userid .Parameters.Add("@DiskFilename", SqlDbType.VarChar, 64).Value = DiskFilename .Parameters.Add("@Title", SqlDbType.VarChar, 50).Value = Title .Parameters.Add("@Access", SqlDbType.Char, 1).Value = Access End With
Try UpdateCommand.Connection.Open() UpdateCommand.ExecuteReader() ' call the store procedure UpdateCommand.Connection.Close() Catch ex As Exception lblErrorMsg.Text = ex.ToString End Try End Sub
I have a Stored Procedure that has a query in it and it take 0 second and then a stored procedure that takes 16 seconds. From what I can tell they shoul be the same.
It doesn't recompile when i run the stored procedure, I checked that.
Hi,I have a web application using Stored Procedure (SP). I see that there's a SP taking long time to execute. I try to capture it by Profiler Tool, and find out that with the same SP on the same db with the same parameter. The duration of executing by my web app is far bigger than the duration of executing on SQl server management studio - query windowPlease see the image attached http://kyxao.net/127/ExecutionProblem.png Any ideas for this issue?Thanks a lot Jalijack
I have wrriten many stored procedures in the past without issue, but this is my first time using SQL Server Management Studio Express. I am having trouble creating a new stored procedure. Here is what's happening: I am opening my database, right clicking on "Stored Procedures" and selecting "New Stored Procedure". A new window opens with a template for creating a stored procedure. The window is called: "SQLEXPRESS.DBName - sqlquery1.sql". I then type up my stored procedure without an issue. However, when I go to save the stored procedure it wants to save it as a separate file in a projects folder. It does not become part of the DB (as far as I can tell). When I used to use Enterprise Manager (not an option anymore) this never happened. I'm sure I'm doing something dumb. Can someone enlighten me. Thanks,Chris
Quick question... I've created my DB in MSSQLSMS, then attempted to created a stored procedure for it. The code itself is fine, I just need to know how to actually attach it so that it appears in the "Stored Procedures" section of my Database.
I have Right Clicked on Stored Procedures > New Stored Procedure... > Edited as required > Save
When I attempt to save it, it prompts me for a file. That's fine, did that - but I can't see ANY way to actually attach this to the DB.
I have a db based on the Tracking_Schema.sql / Tracking_Logic.sql (find in &windir%/Microsoft.NET/Framework/v3.0/Windows Workflow Foundation/SQL/EN), so after executing both of them I get several stored procedures, especially dbo.GetWorkflows. And I have a solution in VS05 which when executed is filling this stored procedure with Instance-Id´s. My question is: how is the working command (like exec, truncate,..) to empty my st.procedure, not to drop/delete it?
Hi all, I am Vaibhav.I am using Microsoft SQL Server Management Studio 9.00.1399.00 on my machine , which have Windows 2000 Professional OS installed. Now I am upgrading My ystem to Windows Vista OS. And I am not getting whether Microsoft SQL Server Management Studio 9.00.1399.00 will support Windows Vista? or I have to go for Higher version available for Microsoft SQL Server Management studio ? Please asist me on same.
Hi, i can make and save a stored procedure in Visual Web Developer (via Database Explorer). It appears then in the list op stored procedure in Management Sudio. But how to do the same in Management Studio? When i make a sp and i want to save it, Management Studio asks me a name, but put the file in a Projects directory in 'My documents'. It never appears in the list of sp. Thanks tartuffe
I have a web application using Stored Procedure (SP). I see that there's a SP taking long time to execute. I try to capture it by Profiler Tool, and find out that with the same SP on the same db with the same parameter. The duration of executing by my web app is far bigger than the duration of executing on SQl server management studio - query window
Please see the image through this url http://kyxao.net/127/ExecutionProblem.png
I have a schedule task with the following command: xp_cmdshell 'bcp DBName.TBLOwner.TBLName in h:datafile.txt /fh:formatfile.fmt /Sservername /Usa /Ppassword' The error message that I recieved is "Unable to open Host file. I can run the BCP command in Dos C prompt successfully, but cannot run this in the SQL Server Scheduler. H drive is net use to the Server and it is where my data file and format file located. Does anyone has any idea? I do appreciate for your help.
So everything was working great. Now I have a few problems. The little play button is no longer available for me to puch and when I try a right click execute package a get a "Unexpected internal error: Invalid state for operation. (Microsoft Visual Studio)". Does anyone know how to fix this? Also when I try and copy tasks from within my package I get a "An error occurred while objects were being copied. SSIS Designer could not serialize the SSIS runtime objects. (Microsoft Visual Studio)" followed by "Could not copy object 'package name' to the clipboard. (Microsoft.DataTransformationServices.Design)" and then "Invalid access to memory location. (Exception from HRESULT: 0x800703E6) (Microsoft.SqlServer.ManagedDTS)"
In Execute SQL Task I am having a stmt like : (Select * from Emp where EmpNm=?) also I m passing variable value through Parameter Mapping.
Problem I am facing is that if I remove brakets from both end task is executed successfull but if I but those braket as they are task execution fails. and i need those brakets as it is inside a if statement.
Problem is with parameter passing ,even if i put some value as EmpNm="ABC " with brakets, it runs successfully
Hi All Could you guys help me i have small problem in running dbcc dbreindex.I could run this command from dbo,sysadmin and Object owner logins to rebuild the index but what i want to do is i want to run this command in a stored procedure. this is also fine if i run the stored procedure any one of above logins it executes when i grant exec permission on this procedure to public it will not execute in public group since public group is not a owner of this object.. How do i excute DBCC DBreindex from public group.Could you please help me.....................
EXEC sp_insertNewRecord 7, 'Peter', 'Wang', '678 Old St', 'Detroit',
'Michigon', '67899', 'PeterWang@yahoo.com'
GO
======================================================================= Now, I want to insert a new record into the dbo.Friends table of my shcDB by executing the following T-SQL and Visual Basic 2005 codes that are programmed in a VB2005 Express project "CallshcDBspWithAdoNet": --Form1.vb--
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Public Class Form1
Public Sub InsertNewFriend()
Dim connectionString As String = "Integrated Security-SSPI;Persist Security Info=False;" + _
"Initial Catalog=shcDB;Data Source=.SQLEXPRESS"
Dim connection As SqlConnection = New SqlConnection(connectionString)
connection.Open()
Try
Dim command As SqlCommand = New SqlCommand("sp_InsertNewRecord", connection)
=========================================================== I ran the above project in VB 2005 Express and I got the following 5 errors: 1. Name 'EXEC' is not declared (in Line 16 of Form1.vb) 2. Method arguments must be enclosed in parentheses (in Line 16 of Form1.vb) 3. Name 'sd-insertNewRecord' is not declared. (in Line 16 of Form1.vb) 4.Comma, ')', or a valid expression continuation expected (in Line 16 of Form1.vb) 5. Expression expected (in Line 16 of Form1.vb) ============================================================ I know that "EXEC sp_insertNewRecord 6, 'Craig', 'Utley', '5577 Baltimore Ave',
'Ellicott City', 'MD', '21045', 'CraigUtley@yahoo.com' "in Line 16 of Form1.vb is grossly in error. But I am new in doing the programming of T-SQL in VB 2005 Express and I am not able to change it.
Please help and advise me how to correct these problems.
I created a simple procedure in SQL Server Management Studio 2014. When I run it I see my query results but not my return value. Do I have to change settings to see the return value?
CREATE PROCEDURE temp AS BEGIN SELECT GetDate() FROM mytable RETURN 1 END EXEC temp
Hello. Does anybody knows if the are shortcuts to differrent menu items in Sql 2005 Management Studio ?For example i will to use the "Execute " button without need to use the mouse, as this case as of others.Any knows where can i find a map or a page info with the shortcuts of SQL2005 Management Studio ? Thanks
Hi all, I have the "Northwind" database in my Sql Server Management Studio Express.
In my C:ProSSEAppsSamplesForChapter02Chapter02 folder, I have the following 2 files: (1) ListColumnValues (MS-DOS Batch File) sqlcmd -S .sqlexpress -v DBName = "Northwind" CName = "CompanyName" TName = "Shippers" -i c:prosseappschapter02ListListColumnVales.sql -o c:prosseappschapter02ColumnValuesOut.rpt (2) ListColumnValues (Microsoft SQL Server Query File) USE $(Northwind) GO SELECT $(CompanyName) FROM $(Shippers) GO When I ran the following SQLcmd: C:ProSSEAppsSamplesForChapter02Chapter02>ListColumnValues.bat I got the following "ColumnValuesOut.rpt" with error messages:
'Northwind' scripting variable not defined. Msg 102, Level 15, State 1, Server L1P2P3SQLEXPRESS, Line 1 Incorrect syntax near '$'. 'CompanyName' scripting variable not defined. 'Shippers' scripting variable not defined. Msg 102, Level 15, State 1, Server L1P2P3SQLEXPRESS, Line 1 Incorrect syntax near 'CompanyName'.
I copied these T-SQL statements from a book and I do not know how to correct them. Please help and tell me how to correct these errors.
i try to open database table using Microsoft SQL Server Management Studio i got the follwing error msg i don't know what the problem
=================================== Object reference not set to an instance of an object. (SQLEditors) ------------------------------Program Location: at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.OpenTableNode.CreateDesigner(IDTDocToolFactoryProvider factoryProvider, IVsDataConnection dataConnection) at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDataDesignerNode.CreateDesigner() at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDataDesignerNode.Open() at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VirtualProject.Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ISqlVirtualProject.CreateDesigner(Urn origUrn, DocumentType editorType, DocumentOptions aeOptions, IManagedConnection con) at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ISqlVirtualProject.CreateDesigner(Urn origUrn, DocumentType editorType, DocumentOptions aeOptions, IManagedConnection con) at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDocumentMenuItem.CreateDesignerWindow(IManagedConnection mc, DocumentOptions options)
I was looking for Microsoft SQL Server Management Studio but downladed Microsoft SQL Server Management Studio EXPRESS. the express version doesn't have the SQL server agent. I read that the express doesnt support SQL server agent. Is there any add-on or service pack available for this. I am trying to find "SQL server Management studio". Any idea where I can download it?
Is Microsoft SQL Server Management Studio Express (sql 2005) compatible with Sql Server 2000 databases? I'm using Windows Vista and the sql 2000 Enterprise Manager is not fully compatible with Vista...long not responding messages. Can i use the client version of Slq 2005?
Microsoft SQL Server Management Studio ExpressI have restored the database into it with 100tables and stored procedures.I have also created the new database in it.But,i don't know how to add the existing database in to Visual Studio.Net 2005 .I m using ASP.Net.Where are the database stored ?? I don't want to create the new database,.Can anyone pls tell me ....
I was having some trouble with the DTS Wizard and so I thought I'd just reinstall the whole MSSM. I used remove programs, rebooted my Vista computer and am trying to reinstall the Server Express Toolkit. It tells me that MSSM already exists on my computer (which it doesn't).
The actual screen reads:
Existing components The following components that you chose to install are already installed on the machine. Grayed out -- Workstation components and development tools 9.2.3042.00
How do I reinstall MSSM now? It's gone from my computer.
Was trying to open AdventureWorks when i got this error: "There is no editor available "C: Program Flies.....AdventureWorksDW_Log.LDF' Make sure the application for the file type(.LDF) is installed. How can this error be corrected? I also have some error on mdf not installed.May i know how should be the initally steps to be done inorder for me to view this database. And if i do have a database from microsoft access, what are the steps that i need to do inorder to get it export to Microsoft SQL Server Management Studio Express. Please advise as i really new to it. Thanks!
I am trying to debug stored procedure using visual studio. I right click on connection and checked 'Allow SQL/CLR debugging' .. the store procedure is not local and is on sql server.
Whenever I tried to right click stored procedure and select step into store procedure> i get following error
"User 'Unknown user' could not execute stored procedure 'master.dbo.sp_enable_sql_debug' on SQL server XXXXX. Click Help for more information"
I am not sure what needs to be done on sql server side
We tried to search for sp_enable_sql_debug but I could not find this stored procedure under master.
Some web page I came accross says that "I must have an administratorial rights to debug" but I am not sure what does that mean?