Advertisement

02.21.2008 at 10:55AM PST, ID: 23182172
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

How To Grant Permissions For a Given SQL User Id To Use the 'dbo' Schema

Asked by Veriman in SQL Query Syntax

Tags: , , ,

Greetings;

I have a stored procedure which includes:

      IF OBJECT_ID('dbo.SelectedCompaniesInitial') IS NOT NULL
            DROP      TABLE dbo.SelectedCompaniesInitial

I believe I am receiving the message:

Msg 2760, Level 16, State 1, Line 1
The specified schema name "dbo" either does not exist or you do not have permission to use it.

when this part of the stored procedure attempts to execute.

How do I give permissions for the given user to 'use' the schema name 'dbo'?

Much thanks ... David

The entire stored procedure follows:

USE [ACCMACompanyRegistry]
GO
/****** Object:  StoredProcedure [dbo].[sp_SearchCompanyByCategory]    Script Date: 02/21/2008 13:45:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:            Bach & Bach Web Solutions, Inc.
-- Create date: 2/15/2008
-- Description:      Retrieve company rows for Company Registry search
--              matching 1 or more selected categories
-- =============================================
ALTER PROCEDURE [dbo].[sp_SearchCompanyByCategory]
      -- Add the parameters for the stored procedure here
      @strCompanyCategoryWHERE      varchar(1000)
AS
BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;

    -- Insert statements for procedure here
      IF OBJECT_ID('dbo.SelectedCompaniesInitial') IS NOT NULL
            DROP      TABLE dbo.SelectedCompaniesInitial

      EXEC
            ('SELECT            DISTINCT strCompany
                  INTO             dbo.SelectedCompaniesInitial
                  FROM            dbo.Specialty_MM_Company
                                          INNER JOIN dbo.Company
                                                INNER JOIN dbo.Contact
                                                      ON dbo.Company.lngID = dbo.Contact.fkCompany_lngId
                                                      ON dbo.Specialty_MM_Company.fkCompany_lngId = dbo.Company.lngID
                                                      INNER JOIN dbo.Specialty_Category
                                                            INNER JOIN dbo.Specialty
                                                                  ON dbo.Specialty_Category.strCategory = dbo.Specialty.fkSpecialty_Category_strCategory
                                                                  ON dbo.Specialty_MM_Company.fkSpecialty_lngId = dbo.Specialty.lngId
                  WHERE ' + @strCompanyCategoryWHERE)

            SELECT            Company.lngId,
                              Company.strCompany,
                              Company.strAddress_1,
                              Company.strAddress_2,
                              Company.strCity,
                              Company.strState,
                              Company.strZIp,
                              Company.blnDBE,
                              Company.blnLBE,
                              Company.blnSBE,
                              Company.dtmCreated,
                              Company.dtmUpdated
                  INTO            #SelectedCompaniesFinal
                  FROM            Company
                                          JOIN SelectedCompaniesInitial
                                                ON Company.strCompany = SelectedCompaniesInitial.strCompany

      DROP      TABLE dbo.SelectedCompaniesInitial

      SELECT            #SelectedCompaniesFinal.strCompany,
                        #SelectedCompaniesFinal.strAddress_1,
                        #SelectedCompaniesFinal.strAddress_2,
                        #SelectedCompaniesFinal.strCity,
                        #SelectedCompaniesFinal.strState,
                        #SelectedCompaniesFinal.strZIp,
                        #SelectedCompaniesFinal.blnDBE,
                        #SelectedCompaniesFinal.blnLBE,
                        #SelectedCompaniesFinal.blnSBE,
                        #SelectedCompaniesFinal.dtmCreated,
                        #SelectedCompaniesFinal.dtmUpdated,
                        Contact.strEmail
            FROM            #SelectedCompaniesFinal
                                    LEFT OUTER JOIN Contact
                                          ON #SelectedCompaniesFinal.lngID = Contact.fkCompany_lngId
            WHERE            Contact.blnEmailOk = 1 AND
                              Contact.blnCompany_Admin = 1
            ORDER BY      strCompany

END
Start Free Trial
[+][-]02.22.2008 at 02:37AM PST, ID: 20956061

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Query Syntax
Tags: Microsoft, SQL Server, 2005, Transact SQL
Sign Up Now!
Solution Provided By: rokov
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628