Sql 2000 database role

Hi ,
I want to grant execute permission to all SP's in SQL 2000  database, when I tried to create a db_execprocs role it is throwing an error near ROLE, and when I googled  I have found a script as 
CREATE PROCEDURE dbo.spGrantExectoAllStoredProcs @user ABC\venkat
AS
-- Object Name: spGrantExectoAllStoredProcs
-- Author: Edgewood Solutions
-- Development Date: 03.19.2007
-- Called By: TBD
-- Description: Issue GRANT EXEC statement for all stored procedures 
-- based on the user name that is passed in to this stored procedure
-- Project: SQL Server Security
-- Database: User defined databases 
-- Business Process: SQL Server Security
-- Num | CRF ID | Date Modified | Developer | Description
-- 001  | N\A     | 03.15.2007    | Edgewood | Original code for the GRANT 
-- EXEC process
SET NOCOUNT ON
-- 1 - Variable declarations
DECLARE @CMD1 varchar(8000)
DECLARE @MAXOID int
DECLARE @OwnerName varchar(128)
DECLARE @ObjectName varchar(128)
-- 2 - Create temporary table
CREATE TABLE #StoredProcedures
(OID int IDENTITY (1,1),
StoredProcOwner varchar(128) NOT NULL,
StoredProcName varchar(128) NOT NULL)
-- 3 - Populate temporary table
INSERT INTO #StoredProcedures (StoredProcOwner, StoredProcName)
SELECT u.[Name], o.[Name]
FROM dbo.sysobjects o
INNER JOIN dbo.sysusers u
ON o.uid = u.uid
WHERE o.Type = 'P'
AND o.[Name] NOT LIKE 'dt_%'
-- 4 - Capture the @MAXOID value
SELECT @MAXOID = MAX(OID) FROM #StoredProcedures
-- 5 - WHILE loop
WHILE @MAXOID > 0
BEGIN 
 -- 6 - Initialize the variables
 SELECT @OwnerName = StoredProcOwner,
 @ObjectName = StoredProcName
 FROM #StoredProcedures
 WHERE OID = @MAXOID
 -- 7 - Build the string
 SELECT @CMD1 = 'GRANT EXEC ON ' + '[' + @OwnerName + ']' + '.' 
 + '[' + @ObjectName + ']' + ' TO ' + '[' + ABC\venkat + ']'
 -- 8 - Execute the string
 -- SELECT @CMD1
 EXEC(@CMD1)
-- 9 - Decrement @MAXOID
SET @MAXOID = @MAXOID - 1
END
-- 10 - Drop the temporary table
DROP TABLE #StoredProcedures
SET NOCOUNT OFF
GO
this too is throwin an error as:
Msg 170, Level 15, State 1, Procedure spGrantExectoAllStoredProcs, Line 1
Line 1: Incorrect syntax near '\'.
Msg 170, Level 15, State 1, Procedure spGrantExectoAllStoredProcs, Line 52
Line 52: Incorrect syntax near '\'.
Can someone help me with this.
I just need to grant execute permission on all SP's  to 1 database only.
Thanks.

First create the procedure and then call the procedure with parameter.
Try this 
CREATE PROCEDURE dbo.spGrantExectoAllStoredProcs @user varchar(20)
AS
-- Object Name: spGrantExectoAllStoredProcs
-- Author: Edgewood Solutions
-- Development Date: 03.19.2007
-- Called By: TBD
-- Description: Issue GRANT EXEC statement for all stored procedures
-- based on the user name that is passed in to this stored procedure
-- Project: SQL Server Security
-- Database: User defined databases
-- Business Process: SQL Server Security
-- Num | CRF ID | Date Modified | Developer | Description
-- 001 | N\A | 03.15.2007 | Edgewood | Original code for the GRANT
-- EXEC process
SET NOCOUNT ON
-- 1 - Variable declarations
DECLARE @CMD1 varchar(8000)
DECLARE @MAXOID int
DECLARE @OwnerName varchar(128)
DECLARE @ObjectName varchar(128)
-- 2 - Create temporary table
CREATE TABLE #StoredProcedures
(OID int IDENTITY (1,1),
StoredProcOwner varchar(128) NOT NULL,
StoredProcName varchar(128) NOT NULL)
-- 3 - Populate temporary table
INSERT INTO #StoredProcedures (StoredProcOwner, StoredProcName)
SELECT u.[Name], o.[Name]
FROM dbo.sysobjects o
INNER JOIN dbo.sysusers u
ON o.uid = u.uid
WHERE o.Type = 'P'
AND o.[Name] NOT LIKE 'dt_%'
-- 4 - Capture the @MAXOID value
SELECT @MAXOID = MAX(OID) FROM #StoredProcedures
-- 5 - WHILE loop
WHILE @MAXOID > 0
BEGIN
-- 6 - Initialize the variables
SELECT @OwnerName = StoredProcOwner,
@ObjectName = StoredProcName
FROM #StoredProcedures
WHERE OID = @MAXOID
-- 7 - Build the string
SELECT @CMD1 = 'GRANT EXEC ON ' + '[' + @OwnerName + ']' + '.'
+ '[' + @ObjectName + ']' + ' TO ' + '[' + @user + ']'
-- 8 - Execute the string
-- SELECT @CMD1
EXEC(@CMD1)
-- 9 - Decrement @MAXOID
SET @MAXOID = @MAXOID - 1
END
-- 10 - Drop the temporary table
DROP TABLE #StoredProcedures
SET NOCOUNT OFF
GO
dbo.spGrantExectoAllStoredProcs 'abc\venkat'
OR
directly execute the below script
Change the @user parameter with valid account
DECLARE @User Varchar(20)
DECLARE @CMD1 varchar(8000)
DECLARE @MAXOID int
DECLARE @OwnerName varchar(128)
DECLARE @ObjectName varchar(128)
SET @user='abc\venkat'
-- 2 - Create temporary table
CREATE TABLE #StoredProcedures
(OID int IDENTITY (1,1),
StoredProcOwner varchar(128) NOT NULL,
StoredProcName varchar(128) NOT NULL)
-- 3 - Populate temporary table
INSERT INTO #StoredProcedures (StoredProcOwner, StoredProcName)
SELECT u.[Name], o.[Name]
FROM dbo.sysobjects o
INNER JOIN dbo.sysusers u
ON o.uid = u.uid
WHERE o.Type = 'P'
AND o.[Name] NOT LIKE 'dt_%'
-- 4 - Capture the @MAXOID value
SELECT @MAXOID = MAX(OID) FROM #StoredProcedures
-- 5 - WHILE loop
WHILE @MAXOID > 0
BEGIN
-- 6 - Initialize the variables
SELECT @OwnerName = StoredProcOwner,
@ObjectName = StoredProcName
FROM #StoredProcedures
WHERE OID = @MAXOID
-- 7 - Build the string
SELECT @CMD1 = 'GRANT EXEC ON ' + '[' + @OwnerName + ']' + '.'
+ '[' + @ObjectName + ']' + ' TO ' + '[' + @user + ']'
-- 8 - Execute the string
-- SELECT @CMD1
EXEC(@CMD1)
-- 9 - Decrement @MAXOID
SET @MAXOID = @MAXOID - 1
END
-- 10 - Drop the temporary table
DROP TABLE #StoredProcedures
--Prashanth

Similar Messages

  • Hi Pls help me, How to work with SQL 2000 Database

    I have database using SQL 2000, How to connect and work with SQL 2000 Database. thanks

    Log on to www.SQLite.org that may help you.
    Using the Sqlite3.dll and after customizing your code with SQLite3.h you can read and write on to that DB.

  • How to Connect Microsoft SQL 2000 database using JDBC

    Hi all..
    I want to connect Microsoft SQL 2000 database using JDBC. I want from initial steps also. (about JDBC driver & its installation)
    Thankz

    Just checkout the SQL Server JDBC Driver Documentation at the manfacturer's site: http://msdn2.microsoft.com/en-us/data/aa937724.aspx

  • SQL 2000 Database Maintenance Plan drop downs for days, weeks, months, not displaying

    When setting up a SQL 2000 Database Maintenance Plan the drop down for Remove files older than is not populating with hours, days, weeks, or months. It is just blank. The version is  Microsoft SQL Server  2000 - 8.00.2039 (Intel X86)  
    May  3 2005 23:18:38   Copyright (c) 1988-2003 Microsoft Corporation  Desktop Engine on Windows NT 5.2 (Build 3790: Service Pack 2). Is there a fix for this issue?

    This also works. All the credit goes to a user named eyechart.  Great directions provided as well.
    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47575
    sqlmaint.exe
    was missing from MSDE 2000, but that was fixed in SP1 I think. Since this is SP3
    you probably have a missing registry value for the backup directory.
    I
    had to fix a similar problem last year on a bunch of laptops. They were all
    missing a registry value. Anyway, here is the fix:
    1. Fire up regedit and
    look under HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer
    2. Ensure you have
    a string value called BackupDirectory. The value for this should be the path to
    your backup dir. The default value is C:\Program Files\Microsoft SQL
    Server\MSSQL\BACKUP
    btw, this fix assumes you have a default instance
    installed. A named instance will have slightly different registry location and
    filesystem path.
    -ec
    Edited by -
    eyechart on 03/25/2005 21:04:27

  • SQL 2000 public role

    Hi~ When we create a new login on SQL 2000 server. It will DEFAULT group into 'public' role on Database master, msdb,.......
    is it possible to take out the new login from the role 'public' of msdb ??

    Thats a default role, you can revoke access it.
    Also, if you want to check assigned permissions to public role than use below query:
    SELECT o.name AS
    [Object], p.permission_name
    AS [Type]
    FROM sys.all_objects o
    INNER JOIN sys.database_permissions p
    ON o.object_id = p.major_id
    INNER JOIN sys.database_principals u
    ON u.principal_ID = p.grantee_principal_id
    WHERE u.name =
    'public'
    Refer below article:
    http://www.sqlservercentral.com/blogs/basits-sql-server-tips/2013/04/04/the-public-role-do-not-use-it-for-database-access/

  • Sql 2000 Database upgrade to 2005

    Hello,
    Our active SAP system works on MS SQL Server 2000 Databases. Will
    there be a trouble if we set up Solution Manager 4.0 directly on MS SQL
    Server 2005 whose SQL servers versions are different? Can I learn your
    suggestions?
    Secondly, we are planning to upgrade SQL Server 2000 system to MS SQL
    Server 2005 in 2 weeks. I would be glad if you could advise me any
    document about this upgrading process.
    Note: All systems are working Windows Server 2003 x64 platform.
    Best regards
    ismail Karayaka

    <i>I would be glad if you could advise me any document about this upgrading process.</i>
    Hello,
    there is a document available called <i>Upgrade to and Installation of SQL
    Server 2005 in an SAP Environment</i>
    To get it go to
    -> http://service.sap.com/instguides
    -> on the left <i>Other Documentation</i>
    -> <i>Database Upgrades</i>
    -> <i>MS SQL Server</i>
    -> <i>Upgrade to and Installation of SQL Server 2005 for SAP</i>
    Hope it helps.
    Regards,
    Norman

  • Importing a MS SQL 2000 Database

    Hi I am looking to transfer a Database that was made in SQL 2000.  I am having difficulties importing this file in Sql Server 2014.  The database works with my door intercom system.   Which used Sql 2000, IIs, Dotnet 2.0,  program
    called Building intercom system management center.  I have upgraded to Windows 7 Pro from SQL Server, SQL server 2014 express from Sql 2000, and .net framework 4.  I am stuck at importing the database to 2014 Sql Express.   Help...  

    Hi joekapala,
    If we want to copy databases from SQL Server 2000 to SQL Server 2014, we should create a SQL Server 2008 instance, backup the SQL Server 2000 database and restore to the SQL Server 2008. Then backup the 2008 database and restore it to SQL Server 2014. For
    more details, please see:
    http://blogs.technet.com/b/mdegre/archive/2012/06/15/migration-sql-server-2000-to-sql-server-2012.aspx
    Another approach is to script out all the objects (tables, views, procedures, etc) from your SQL Server 2000 database. Then execute the generated script on your 2014 server. (Fixing any problems that you find.) For more details, please refer to the following
    blog:
    http://blogs.msdn.com/b/zxue/archive/2010/05/10/moving-data-from-sql-server-2000-to-sql-server-2008.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Which is the best way to migrate the SQL SERVER 2000 Database to SQL SERVER 2003 Database?

    Hi,
        I  need to migrate the Production database sql server 2000 to Sql server 2003, Please give me the best idea to migrate the database without any loss data, credentials and  Objects. 
    Nandha Kumar

    SQL server does not have any version named SQL server 2003 please check the version correctly it should be either SQL 2005,2008,2008 R2,2012
    You can use the backup/restore to upgrade the SQL 2000 database to till SQL 2005,2008,2008R2
    For SQL Server 2000 to 2012
    First upgrade from SQL 2000 database to either SQL 2005, 2008 or 2008R2 and than upgrade it to SQL 2012.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/eaa1eb44-729f-466b-8233-cb768fbb4208/upgrading-to-sql-server-2008-from-sql-server-2000?forum=sqlsetupandupgrade
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/4fac7511-2c75-46a0-802b-807dd26b12bf/sql-2012-will-not-convert-a-sql-2000-database?forum=sqlservermigration
    And after migration to SQL 2005 or 2008, if you want to script the database than can generate scripts pick DB and check off "script all objects in the selected database".
    http://blog.sqlauthority.com/2011/05/07/sql-server-2008-2008-r2-create-script-to-copy-database-schema-and-all-the-objects-data-schema-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/
    You can upgrade from SQL Server 2005, SQL Server 2008, and SQL Server 2008 R2 to SQL Server 2012.
    http://msdn.microsoft.com/en-us/library/ms143393(v=sql.110).aspx
    Please click the Mark as answer button and vote as helpful if this reply solves your problem

  • SQL 2000 LINKED SERVER ERROR 7303 WITH SQL 2012 ON WINDOWS SERVER 2012 R2

    Hi all,
    I have a problem with SQL Server 2012 and a linked server for SQL 2000 database.
    System specification:
    Windows server 2012 64 bit
    SQL SERVER 2012 64 bit
    REMOTE SERVER SQL 2000 32 bit
    I've installed sql native client 32bit,create a SYSTEM DSN odbc connection with "SQL Server" driver named "MYSERVER".
    Create a linked server with the query below in SQL 2012:
    EXEC master.dbo.sp_addlinkedserver @server =N'MYSERVER', @srvproduct=N'MYSERVER', @provider=N'MSDASQL', @datasrc =N'MYSERVER', @location=N'System';
    EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'MySERVER',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
    GO
    but when i browse the linked server i receved error 7303.

    You need 64-bit MSDASQL. It is the bitness of the server you are connecting from that matters. 64-bit executables cannot hook into 32-bit DLL.
    However, I suspect that you will not get things to work anyway. At least I have not seen anyone this far who has been able to set up a linked server from SQL 2012 to SQL 2000. I know that when I tried this, the following providers had this result:
    SQLNCLI11 - does not support connections to SQL 2000.
    SQLNCLI10 - failed with some obscure message that I don't recall.
    SQLNCLI - Don't recall that the problem was here.
    SQLOLEDB - SQLOLEDB is always replaced with the most recent version of SQLNCLI, so this fails because of lack of support.
    I don't think I got through all version of the ODBC drivers, though.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Can SQL 2000 and SQL 2005 drivers co-exist in PI?

    Hi,
    Currently in our PI environment, we have JDBC Adapter connections to SQL 2000 database servers for which the Driver has already been installed.
    For connecting to new SQL 2005 database servers, I understand that we have to install the SQL 2005 drivers. I also came to know that SQL 2005 Driver is backward compatible and supports JDBC connection to SQL 2000 server.
    But the question I have is whether both the SQL 2000 and SQL 2005 drivers can be installed together in a way that connection to SQL 2000 use the 2000 driver and the connection to 2005 uses 2005 Driver.
    (They have different connection strings)
    Many thanks in advance,
    Regards,
    Rosie Sasidharan

    The SQL Server 2005 JDBC driver is far better than the SQL Server 2000 JDBC driver.  The 2005 JDBC driver primarily consists for one file, sqljdbc.jar.  ( if you want to use windows authentication there is another file you would need based on your platform x64 vs x86 called sqljdbc_auth.dll. If in the connect string you list ;integratedSecurity=true which means integrated security would be used and this second file would be required.  The 2000 driver did not support integrated security.
    The SQL 2000 JDBC driver was made up of the 3 jar files:
    msbase.jar,mssqlserver.jar and msutil.jar.
    If you want to use a Microsoft JDBC driver to connect to SQL Server 2005, than you should use the 2005 driver, sqljdbc.jar.
    Follow the instructions in point 1 of the note #831162 - FAQ: XI 3.0 / PI 7.0 / PI 7.1 JDBC Adapter questions 1 and 13.
    Since the jar are different I assume you can use the both drivers, but it doesnt make sense.

  • SQL 2000 to Oracle 8i migration...Urgent

    Can anyone help me in converting SQL 2000 database to Oracle 8i version(8.1.7).
    I have installed OMWB 9.2 on a windows 2000 machine, but it failed to convert even after many tries. It creates the SQL model perfectly with errors but while converting to Oracle model , it creates no. of errors and also it doesnt convert the oracle model to oracle database perfectly. After migration i do not see migration taken place on the oracle sie.
    If someone is ready to help me, let me send you the SQL 2000 database which you please convert it to oracle and send it to me as scripts. Then i will do the manual conversion wherever required and use it.
    Many thanks in advance,
    Please help me at the earliest...
    Thiru

    Sorry please. discard the above message...
    Turloch,
    I have tried that too but cannot see any table & stored procedure creation scripts. Dont know what i am doing wrong but started migrating it manually. If any one can help in generating the scripts for me, it will be of great help. Anyway, i'm going to disturb this forumn a lot in migrating my database to oracle!!!
    Cheers
    Thiru

  • Data convertion for VARBINARY of SQL 2000?

    I have a VARBINARY data in my SQL 2000 database. I need to know what will be the
    conversion for VARBINARY. I used byte{}, unfortunately it gives SQL EXCEPTION:
    Unsupported data type. I also tried String, this time it does not give me SQL
    exception Unsupported data type but the data is not the same. All I can do it
    check the length. the length is not the same as that in the database..
    NEED HELP!!!

    Bhawna wrote:
    I have a VARBINARY data in my SQL 2000 database. I need to know what will be the
    conversion for VARBINARY. I used byte{}, unfortunately it gives SQL EXCEPTION:
    Unsupported data type. I also tried String, this time it does not give me SQL
    exception Unsupported data type but the data is not the same. All I can do it
    check the length. the length is not the same as that in the database..
    NEED HELP!!! Hi. A verbinary column should be accessible fromm JDBC, via ResultSet.getBytes(),
    getBinaryStream(), or getObject(). Let me know...
    Joe

  • SQL 2000 XML Support

    I have a simple SQL from which i get XML data from the SQL 2000 Database.
    SQL :
    select * from customer for xml auto
    I would like to execute the SQL thru JDBC, but i am getting the following error
    java.sql.SQLException: [MERANT][SequeLink JDBC Driver][SQL Server]The FOR XML clause is not allowed in a CURSOR statement.
    Note : I am using merant driver.
    Any info on this is greatly appreciated.
    Thanks in advance

    Get rid of the selectMethod=cursor from your connection Url
    eg. if you have a Connection String like
    jdbc:microsoft:sqlserver://yourserver:portnum;database=mydatabae;selectMethod=cursor;

  • Restoration at sql 2005 from sql 2000 backup.

    Hi experts,
    Is it possible to restore a backup taken from sql 2000 database to sql 2005 database?
    And how about attaching datafiles of sql2000 into sql 2005 server?
    Thanks and Regards,
    Amit Jana.

    > Is it possible to restore a backup taken from sql 2000 database to sql 2005 database?
    Yes its possible.
    > And how about attaching datafiles of sql2000 into sql 2005 server?
    Same method of attach/deattach.
    But recommanded you first install 2000 instance restore database and do inplace sql 2005 upgrade.
    Why you can't follow recommanded mothed ?
    Regards,
    Nikunj Thaker

  • Localhost sql 2000

    Iam trying to get data from a table in a sql 2000 database on my computer as a localhost in a JSP page which have the following code:
    <%@page import="java.sql.*"%> <html> <head> <title>My First JDBC</title> </head> <body> <% try { try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); }catch(java.lang.ClassNotFoundException e){ System.err.println(e.getMessage()); } Connection conn = DriverManager.getConnection ("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Trysh","sa","sapassword"); System.out.println("gogogogo"); Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery("select * from Objects"); rs.next(); String ss=rs.getString(0); %> <% System.out.println(ss);%> <% } catch(SQLException ex) {System.err.println(ex.getMessage()); } catch(Exception ee) {%> <% System.out.println("good"); System.err.println(ee.getMessage()+"ok"); %> <% } %> </body> </html>
    But I am getting the error :
    No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Trysh
    Could any one help me to solve this problem?.

    Thank you for responding...
    I do as you told me and I got the following long stack trace text.I don't know what does it mean?.
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
    at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
    at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
    at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
    at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
    at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.apache.jsp.MyFirstJDBC_jsp._jspService(MyFirstJDBC_jsp.java:70)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
    at java.lang.Thread.run(Thread.java:619)

Maybe you are looking for