SQL Server Admin 2014 :: Permissions To Debug Stored Procedures Using SSMS?

Jun 25, 2015

What permission is required to run debug feature in SSMS(debug Stored Procedures). This is a development machine and developer requested for this.

EXECUTE permission was denied on the object 'sp_enable_sql_debug', database 'mssqlsystemresource', schema 'sys'.

EXECUTE permission was denied on object 'sp_sql_debug', database 'master'.

Is there any option other than giving sysadmin privilege on SQL?

View 0 Replies


ADVERTISEMENT

SQL Server Admin 2014 :: Read Only Replicas And Stored Procedures

Aug 6, 2014

I am curious what other people have done to implement read-only routing for a large number of procedures.

Basically figuring out when to call procedures that are read-only with read-only intent.

We have a user application that passes an encrypted string to a web service that directs it to our SQL Servers.

I've been tasked with finding a way to make this happen without changing the application.

The only thing I have been able to come up with is writing something (which I did) that will identify whether something is read-only or not and storing a big list.

Then having the web service look up the given procedure and adding the intent where needed.

View 5 Replies View Related

SQL Server Admin 2014 :: Can Backup All Stored Procedures In A Database

Oct 31, 2014

is there a way to backup all stored procedures in a database?

View 4 Replies View Related

SQL Server Admin 2014 :: Replication Could Not Find Or Execute Stored Procedures

Jul 20, 2015

Replication-Replication Distribution Subsystem: agent PRODDATA6 failed. Could not find stored procedure 'sp_MSdel_dboActiveTask_msrepl_ccs'.

Replication-Replication Transaction-Log Reader Subsystem: agent PRODDATA6. The process could not execute 'sp_replcmds' on 'PRODDATA6'.

Replication-Replication Distribution Subsystem: agent PRODDATA6. Could not find stored procedure 'sp_MSupd_dboActiveTask'.

Looks like these sp's got deleted?

View 1 Replies View Related

SQL Server Admin 2014 :: Policy Management - Table References In Stored Procedures

Feb 3, 2015

Is there any way to enforce table references in stored procedures? For Example, we have stored procedures with a ton of different formats, "dbo.table", "table", "db.dbo.table", etc. Can we make it so that for every stored procedure, the reference must be at least "dbo.table"?

View 1 Replies View Related

SQL Server Admin 2014 :: SSMS Will Only Run As Administrator

May 28, 2015

After installing SSMS on some computers - the only way we can get SSMS to run correctly is to run it as the administrator. Is there a way where you don't have to do that? These end users are logging as themselves and have accounts in SQL Server all set up - but SSMS will only launch for them if we right click and select "run as administrator".After doing some digging - it seems that this is a common problem out there.

View 3 Replies View Related

SQL Server Admin 2014 :: Restriction On DML Statements In SSMS

Apr 27, 2014

I would like to know if there is any option to Restrict DML statements in SSMS for a user where the same user should be able to perform these actions through application on particular database.

View 1 Replies View Related

SQL Server Admin 2014 :: SSMS - The Application Cannot Start

Jul 4, 2014

Has experienced this error when trying to open SSMS? Was working fine earlier. I have tried uninstall/reinstall, a few reboots,repairing the install, etc.

View 5 Replies View Related

SQL Server Admin 2014 :: SSMS Occasionally Freezing / Hanging

Jul 7, 2015

I have a weird intermittent issue with an enterprise version of SS2014. When clicking or right clicking around SSMS will lock up and display the 'SSMS is busy - waiting for an internal operation to complete'. It is only specific to the server as when I connect using my local SSMS this doesn't happen. This was happening both pre and post SP1 install.

View 4 Replies View Related

SQL Server Admin 2014 :: Deny SSMS Connections From Remote Servers?

Nov 20, 2014

Is there any way I can deny connection from SSMS only from remote servers?

View 7 Replies View Related

SQL Server Admin 2014 :: SSMS Restarts Daily On Remote Desktop?

Dec 11, 2014

I'm using ssms 2014, but got the same problem with 2012. I use ssms almost entirely on remote desktop sessions ( Windows 7, Server 2008R2, Server 2012 ). It may be related to having filtered job activity monitor windows open for hours, but about once per day ssms fails, and has to restart. Upon resuming usually only one of several queries is restored.

View 8 Replies View Related

SQL Server Admin 2014 :: SSMS - Disable Check For Memory Optimized Tables?

Oct 2, 2014

I have the following setup:

- An MSSQL 2014 Standard server that houses multiple small databases (in excess of a hundred).
- These databases are frequently dropped and restored by an application that uses this SQL Server.
- There is a business need for this setup at this time, so I can't get away from it. Therefore answers like "don't have so many small databases that are frequently dropped and restored" would be somewhat unuseful

This is the problem I have:

- When I connect SSMS 2014 to the server and expand the "Databases" node, it takes forever to display. In comparison, SSMS 2008 connected to SQL 2008R2 server with the same number of databases displays the Databases tree very quickly.

I ran a trace to see what exactly SSMS 2014 is doing. When the "Databases" node is expanded, it runs a query that checks each database for Memory-Optimized Tables (new and wonderful feature of SQL 2014 for sure, but I'm not using it, at least yet). Naturally, when you have to loop through over a hundred DBs, it takes time. Worse yet, if one of these DBs is in process of being restored, the query sits and waits to time out before proceeding to the next DB. Sometimes this causes outright timeouts. Here is the query:

use [MyDatabase]
SELECT
ISNULL((select top 1 1 from sys.filegroups FG where FG.[type] = 'FX'), 0) AS [HasMemoryOptimizedObjects]

To be sure, this is NOT a SQL Server performance issue. This server processes a rather heavy workload and has been doing so for over a month, and the workload completes within expected time limits or better. Even so I've done some basic performance measuring, and the server itself is quite all right.

Moreover, if I connect SSMS 2008 to it, I get an error message (Index out of bounds or somesuch), but SSMS 2008 does connect, and displays the Databases tree much faster than SSMS 2014.

I'd like to turn off the option to check for Memory Optimized Objects altogether, as I'm not using the feature.

View 3 Replies View Related

SQL Server Admin 2014 :: Logins With No Database Permissions

Nov 3, 2014

Query to show logins that don't have any permissions within the SQL instance? I'm tasked with doing some cleanup and have found some cases where the database was deleted or moved to another server but the logins that used it were not deleted. I'd like to identify them to research.

For instance a query to show logins that have no permissions in any of the existing databases would be handy. I'm thinking it would be complicated by the need to loop through all of the existing databases and then outer join it to the list of instance level logins. Going to try to write something like that but was hoping that a script already exists.

View 3 Replies View Related

SQL Server Admin 2014 :: Required Permissions To Enable Mirroring Session

Oct 29, 2015

I have a Windows NT group that is used to delegate certain database responsibilities to other members of staff and I am trying to grant permissions for the members of the group to be be able to establish database mirroring sessions, as in run the following:

ALTER DATABASE <database>
SET PARTNER = 'tcp://principal_server.domain.com:port';

Although the group has db_owner role membership to the user database which grants the ALTER permission on the database, the following is being generated in the error log when they get to this step on the intended Mirror instance after restoring the database correctly in preperation:

SqlDumpExceptionHandler: Process 59 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
* *******************************************************************************
*
* BEGIN STACK DUMP:
* 10/29/15 11:16:15 spid 59
*
*
* Exception Address = 00007FF9A6AF838C Module(sqlmin+000000000003838C)
* Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
* Access Violation occurred reading address 00000000000000D8
* Input Buffer 210 bytes -
* alter database <redacted> set partner = '<redacted>';

As you can see, the statement is denied to the user. There are no issues with the database as I am able to run the same query successfully using my own sysadmin account after the failed attempt. What other minimum permissions the group might need to successfully enable them to setup a mirroring session?

View 9 Replies View Related

SQL Server Admin 2014 :: Does Changing Service Account Update NTFS Permissions

Nov 22, 2014

If you were to do a fresh install it would set permissions on the disk so everything just works.

Now when changing the service account (e.g. to a domain user) use the configuration manager, does it do the same magic (possibly sans if the database data/log files are on another disk)? Or do you need to trawl through the dozens of folders and assign rights manually?

View 1 Replies View Related

SQL Server Admin 2014 :: How To Enforce Changes In Dependent Procedures

Feb 27, 2015

I have two procedures Sp1 and Sp2. The Sp1 is calling from Sp2. If there come new parameters or removed from the first procedure Sp1 then it will effect the Sp2 and its execution will break if required changes not done. So I want that when any changes making in SP1 then i need alert about the Sp2 changes.

View 3 Replies View Related

SQL Server Admin 2014 :: Cannot Connect To Named Instance (2nd Instance) From Local SSMS

Jul 22, 2015

I've two instances(Default, Named[dynamicsFINANCE]) running on SQL server 2014. However, when I try to connect to named instance say (dynamicsFINANCE) using SQL authentication from local SSMS, I get below error message:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

I assigned a static port number to the named instance [dynamicsFINANCE] 1450. I also setup the firewall rule to allow access to Port 1450.

View 5 Replies View Related

How To Debug Database Engine Stored Procedures On SQL Server 2005?

Mar 19, 2007

1). When you right click stored procedure in the Query Analyzer on 2000 you can select debug from the list of menues.

I can't find this functionality in the SQL Server Management studio.

2). By the way I also can't find where went the output of my print statement.

3). Does server cursor functionality is still working in 2k5?

View 3 Replies View Related

SQL Server 2014 :: Error Running Stored Procedure From SSIS Runs Fine In SSMS?

Mar 23, 2015

I have simple query which creates tables by passing database name as parameter from a parameter table .

SP1 --> creates databases and calls SP2--> which creates tables . I can run it fine via SSMS but when I run it using SSIS it fails with below error .The issue gets more interesting when it fails randomly on some database creation and some creates just fine .

Note** I am not passing any database of name '20'

Exception handler error :

ERROR :: 615 :: Could not find database ID 20, name '20'. The database may be offline. Wait a few minutes and try again. ---------------------------------------------------------------------------------------------------- SPID: 111 Origin: SQL Stored Procedure (SP1) ---------------------------------------------------------------------------------------------------- Could not find database ID 20, name '20'. The database may be offline. Wait a few minutes and try again. ----------------------------------------------------------------------------------------------------

Error in SSIS

[Execute SQL Task] Error: Executing the query "EXEC SP1" failed with the following error: "Error severity levels greater than 18 can only be specified by members of the sysadmin role, using the WITH LOG option.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.I have sysadmin permission .

View 6 Replies View Related

Cannot Debug Stored Procedures Because The SQL Server Database Is Not Setup Correctly Or User Does Not Have Permission To Execute Master.sp_sdidebug.

Aug 7, 2007

Hello All,I tried to set the access permissions for debugging stored procedure by reading the articlehttp://msdn2.microsoft.com/en-us/library/w1bhybwz(VS.80).aspxandhttp://technet.microsoft.com/en-us/library/ms164014.aspxI have tried to add the role to sysaminas follows1)SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_sdidebug'(to find the sp)Error:--The stored procedure not found2)sp_addsrvrolemember 'Developmentswati.jain', 'sysadmin' though this is executed successfuly . Error is still persisting 
Cannot debug stored procedures because the SQL Server database is not setup correctly or user does not have permission to execute master.sp_sdidebug.

View 3 Replies View Related

SQL Server Admin 2014 :: Stored Procedure - Find The Cause For Blocking

Sep 23, 2015

I was trying to create stored proc

[code="create procedure dbo.sp_table1
@idint
as
begin
updatetable1
setisarchived = 1,

[Code] ....

But the query was continuously blocking the query below

updatetable1
setisarchived = 1,
modtime = getdate()
whereid = @id
andisarchived = 0

I was not sure, why the create procedure statement is blocking the update statement.

View 1 Replies View Related

MS SQL Server Management Studio - Permissions And Stored Procedures

Nov 16, 2006

Hi

My website uses GET variables a lot and i'm trying to safe guard as much as possible against SQL injection attacks. I'm trying to create permissions which will deny a user to Delete/Insert/Update various tables.

I have managed this with the tables themselves, but when using a stored procedure, the tables do not take into account the user permissions which were set for that table!

Basically, how do i stop a stored procedure from Deleting/Inserting/Updating tables? :(

many thanks

View 3 Replies View Related

Debug Stored Procedures In Visual Studio.net

Dec 13, 2007

Hi everyone,
I dont know if I am posting this to the right area but here goes:  I know there is a way you can step into a stored procedure from VS.net, but I dind't know how.  I searched google and found this MS KB Article: http://support.microsoft.com/kb/316549
 However, on step two, "Under the Servers node in Server Explorer, expand the SQL Server Machine name, expand the SQL Servers Node, ..."
The first and only item I have in the tree is my local machine name.  If I expand that I do not have a SQL Servers node, all I have are: Crystal Reports Services, Event Logs Management Classes, Management Events, Message Queues, Performance Counters and Services. 
The instance of SQL Server I am using is on my local machine and I am able to communicate with it.  I am using TCP/IP
I figured to check the SQL Server Config Manager and see what protocols the db was using.  The client protocols are Shared Memory, TCP/IP and Named Pipes (these are enabled)
I then looked at the SQL Server 2005 Services.  The following are running: SQL Server Integration Services, SQL Server FullText, SQL Server, SQL Server Analysis Services, SQL Server Reporting and SQL Server Agent (This was stopped but I started it)  SQL Server Browser is NOT running and I can't start it.  I dont know if that has anything to do with it.
Am I missing somethign?
Thanks,
John

View 2 Replies View Related

How Do You Debug Stored Procedures In Visual Studio Again?

Feb 25, 2004

I've set my breakpoints - project property page is set to debug sql

What else do I have to do again?

View 1 Replies View Related

Unable To Debug SQL Server 2005 Stored Procedures From Another Workstation Running Visual Studio 2005

Sep 18, 2006

I'm having some problems debugging SQL Server stored procedures on a SQL Server 2005 server. I have installed Visual Studio 2005 on a workstation running Windows XP, now I'm trying to debug a ASP.Net web application that has some code that executes the stored procedures on a Windows 2003 Server running SQL Server 2005.

I opened VS2005 ... created a connection to the SQL Server 2005 instance ... open the Stored procedure ... right click the stored procedure name and selected Step into Stored Procedure and the following message is displayed:

Unable to start T-SQL debugging.Could not attach to SQL Server process on 'ServerName'.

Any ideas.



Thanks,

View 2 Replies View Related

Any Way To Debug Stored Procedures Without Buying Visual Studio?

Feb 2, 2007

Hi.I am under the understanding that having the sql server 2005 db is notenough (like 2000 was) to debug stored procedures.. that I need topurchase (costly) visual studio 2005.Can someone suggest a free or lower cost alternative?sorry to be so cheap.. its the times I think.

View 4 Replies View Related

SQL Server Admin 2014 :: Finding A Table Where Maintenance Clean Up Task Configuration Is Stored?

Jul 2, 2014

I am looking for a table where Maintenance Clean Up Task configuration is stored. For example, Delete file older than the following - which is 2 days. Which table can I retrieve the setting in msdb ?

View 5 Replies View Related

Is It Possible To Change Permissions Of SQL Server System Stored Procedures And DBCC Commands?

May 8, 2008

Hi all,

I would like to enable users that do not belong to groups (server roles) such as sysadmin, serveradmin and don't have db permissions such as ddl_admin or db_owner to run some of the system stored procedures (such as sp_addumpdevice sp_configure sp_serveroption ...) and DBCC commands (such as DBCC CHECKFILEGROUP - requires ob_owner or sysadmin permission).

Is it possible to change permissions of SQL Server system stored procedures?

Is it possible to change permissions of SQL Server DBCC commands?

Thanks,

Assaf

View 1 Replies View Related

SSMS-EE: Creating And Using Stored Procedures - Error Messages 111, 156, &&amp; 102

May 10, 2006

Hi all,

I tried to use the SSMS-EE Query to execute the following code statements:

--- SQLQuery.sql---

USE testDB
DECLARE @procID int
DECLARE @procName varchar(20)
DECLARE @procType varchar(20)
CREATE PROC sp_getRecords AS SELECT * FROM Inventory
CREATE PROC sp_insertRecord @procID int, @procName varchar(20), @procType
varchar(20) AS INSERT INTO Inventory VALUES (@procID, @procName, @procType)
CREATE PROC sp_deleteRecord @procID int AS DELETE FROM Inventory WHERE ID=@procID
CREATE PROC sp_updateRecord @procID int, @procName varchar(20), @procType
varchar(20) AS UPDATE Inventory SET name=@procName, type=@procType where ID=@procID
--- Insert records into the Inventory table
EXE sp_insertRecord 4, 'ER Vol 1', 'DVD'
EXE sp_insertRecord 5, 'ER', 'VHS'
EXE sp_insertRecord 6, 'Sixth Sense', 'DVD'
--- Delete record with ID=3
EXEC sp_deleteRecord 3
--- Update record with ID=5
EXEC sp-updateRecord 5 'ERVol1', 'VHS'
--- View the updated table
EXEC sp_getRecords
GO

//////////////////////////////////////////////////////////////////////////////////////////////////

I got the following error messages:
Msg 111, Level 15, State 1, Procedure sp_getRecords, Line 8
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 10
Incorrect syntax near the keyword 'PROC'.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 11
Incorrect syntax near the keyword 'PROC'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 14
Incorrect syntax near 'EXE'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 20
Incorrect syntax near 'updateRecord'.
/////////////////////////////////////////////////////////////////////////////////////////////////////
Please help, tell me what is wrong in my execution of the code and advise me how I can correct this problem.
Thanks,
Scott Chang

View 1 Replies View Related

SSMS-EE: Creating And Using Stored Procedures - Error Messages 111, 156, &&amp; 102

May 11, 2006



Hi all,

I tried to use the SQL Server Managemet Studio-Express Edition to execute the following code statements:

--- SQLQuery.sql---

USE testDB
DECLARE @procID int
DECLARE @procName varchar(20)
DECLARE @procType varchar(20)
CREATE PROC sp_getRecords AS SELECT * FROM Inventory
CREATE PROC sp_insertRecord @procID int, @procName varchar(20), @procType
varchar(20) AS INSERT INTO Inventory VALUES (@procID, @procName, @procType)
CREATE PROC sp_deleteRecord @procID int AS DELETE FROM Inventory WHERE ID=@procID
CREATE PROC sp_updateRecord @procID int, @procName varchar(20), @procType
varchar(20) AS UPDATE Inventory SET name=@procName, type=@procType where ID=@procID
--- Insert records into the Inventory table
EXE sp_insertRecord 4, 'ER Vol 1', 'DVD'
EXE sp_insertRecord 5, 'ER', 'VHS'
EXE sp_insertRecord 6, 'Sixth Sense', 'DVD'
--- Delete record with ID=3
EXEC sp_deleteRecord 3
--- Update record with ID=5
EXEC sp-updateRecord 5 'ERVol1', 'VHS'
--- View the updated table
EXEC sp_getRecords
GO

//////////////////////////////////////////////////////////////////////////////////////////////////

I got the following T-SQL error messages:
Msg 111, Level 15, State 1, Procedure sp_getRecords, Line 8
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 10
Incorrect syntax near the keyword 'PROC'.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 11
Incorrect syntax near the keyword 'PROC'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 14
Incorrect syntax near 'EXE'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 20
Incorrect syntax near 'updateRecord'.
/////////////////////////////////////////////////////////////////////////////////////////////////////
Please help, tell me what is wrong in my execution of the code and advise me how I can correct this problem.
Thanks,
Scott Chang

View 6 Replies View Related

SSMS-EE: Creating And Using Stored Procedures - Error Messages 111, 156, &&amp; 102

May 10, 2006

Hi all,

I tried to use the SSMS-EE Query to execute the following code statements:

--- SQLQuery.sql---

USE testDB
DECLARE @procID int
DECLARE @procName varchar(20)
DECLARE @procType varchar(20)
CREATE PROC sp_getRecords AS SELECT * FROM Inventory
CREATE PROC sp_insertRecord @procID int, @procName varchar(20), @procType
varchar(20) AS INSERT INTO Inventory VALUES (@procID, @procName, @procType)
CREATE PROC sp_deleteRecord @procID int AS DELETE FROM Inventory WHERE ID=@procID
CREATE PROC sp_updateRecord @procID int, @procName varchar(20), @procType
varchar(20) AS UPDATE Inventory SET name=@procName, type=@procType where ID=@procID
--- Insert records into the Inventory table
EXE sp_insertRecord 4, 'ER Vol 1', 'DVD'
EXE sp_insertRecord 5, 'ER', 'VHS'
EXE sp_insertRecord 6, 'Sixth Sense', 'DVD'
--- Delete record with ID=3
EXEC sp_deleteRecord 3
--- Update record with ID=5
EXEC sp-updateRecord 5 'ERVol1', 'VHS'
--- View the updated table
EXEC sp_getRecords
GO

//////////////////////////////////////////////////////////////////////////////////////////////////

I got the following error messages:
Msg 111, Level 15, State 1, Procedure sp_getRecords, Line 8
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 10
Incorrect syntax near the keyword 'PROC'.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 11
Incorrect syntax near the keyword 'PROC'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 14
Incorrect syntax near 'EXE'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 20
Incorrect syntax near 'updateRecord'.
/////////////////////////////////////////////////////////////////////////////////////////////////////
Please help, tell me what is wrong in my execution of the code and advise me how I can correct this problem.
Thanks,
Scott Chang

View 1 Replies View Related

SSMS-EE: Creating And Using Stored Procedures - Error Messages 111, 156, &&amp; 102

May 11, 2006



Hi all,

I tried to use the SQL Server Managemet Studio-Express Edition to execute the following code statements:

--- SQLQuery.sql---

USE testDB
DECLARE @procID int
DECLARE @procName varchar(20)
DECLARE @procType varchar(20)
CREATE PROC sp_getRecords AS SELECT * FROM Inventory
CREATE PROC sp_insertRecord @procID int, @procName varchar(20), @procType
varchar(20) AS INSERT INTO Inventory VALUES (@procID, @procName, @procType)
CREATE PROC sp_deleteRecord @procID int AS DELETE FROM Inventory WHERE ID=@procID
CREATE PROC sp_updateRecord @procID int, @procName varchar(20), @procType
varchar(20) AS UPDATE Inventory SET name=@procName, type=@procType where ID=@procID
--- Insert records into the Inventory table
EXE sp_insertRecord 4, 'ER Vol 1', 'DVD'
EXE sp_insertRecord 5, 'ER', 'VHS'
EXE sp_insertRecord 6, 'Sixth Sense', 'DVD'
--- Delete record with ID=3
EXEC sp_deleteRecord 3
--- Update record with ID=5
EXEC sp-updateRecord 5 'ERVol1', 'VHS'
--- View the updated table
EXEC sp_getRecords
GO

//////////////////////////////////////////////////////////////////////////////////////////////////

I got the following T-SQL error messages:
Msg 111, Level 15, State 1, Procedure sp_getRecords, Line 8
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 10
Incorrect syntax near the keyword 'PROC'.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 11
Incorrect syntax near the keyword 'PROC'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 14
Incorrect syntax near 'EXE'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 20
Incorrect syntax near 'updateRecord'.
/////////////////////////////////////////////////////////////////////////////////////////////////////
Please help, tell me what is wrong in my execution of the code and advise me how I can correct this problem.
Thanks,
Scott Chang

View 3 Replies View Related

SSMS-EE: Creating And Using Stored Procedures - T-SQL Error Messages 111, 156, &&amp; 102

May 10, 2006

Hi all,

I tried to use the SQL Server Management Studio-Express Edition to execute the following code statements:

--- SQLQuery.sql---

USE testDB
DECLARE @procID int
DECLARE @procName varchar(20)
DECLARE @procType varchar(20)
CREATE PROC sp_getRecords AS SELECT * FROM Inventory
CREATE PROC sp_insertRecord @procID int, @procName varchar(20), @procType
varchar(20) AS INSERT INTO Inventory VALUES (@procID, @procName, @procType)
CREATE PROC sp_deleteRecord @procID int AS DELETE FROM Inventory WHERE ID=@procID
CREATE PROC sp_updateRecord @procID int, @procName varchar(20), @procType
varchar(20) AS UPDATE Inventory SET name=@procName, type=@procType where ID=@procID
--- Insert records into the Inventory table
EXE sp_insertRecord 4, 'ER Vol 1', 'DVD'
EXE sp_insertRecord 5, 'ER', 'VHS'
EXE sp_insertRecord 6, 'Sixth Sense', 'DVD'
--- Delete record with ID=3
EXEC sp_deleteRecord 3
--- Update record with ID=5
EXEC sp-updateRecord 5 'ERVol1', 'VHS'
--- View the updated table
EXEC sp_getRecords
GO

//////////////////////////////////////////////////////////////////////////////////////////////////

I got the following T-SQL error messages:
Msg 111, Level 15, State 1, Procedure sp_getRecords, Line 8
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 10
Incorrect syntax near the keyword 'PROC'.
Msg 156, Level 15, State 1, Procedure sp_getRecords, Line 11
Incorrect syntax near the keyword 'PROC'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 14
Incorrect syntax near 'EXE'.
Msg 102, Level 15, State 1, Procedure sp_getRecords, Line 20
Incorrect syntax near 'updateRecord'.
/////////////////////////////////////////////////////////////////////////////////////////////////////
Please help, tell me what is wrong in my execution of the code and advise me how I can correct this problem.
Thanks,
Scott Chang

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved