Schema in server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssrajpal2001
    New Member
    • Oct 2007
    • 4

    Schema in server

    the procedure goes like this
    CREATE PROCEDURE createschema

    @schema_name varchar(30)

    AS

    declare @Schema_Tables nvarchar(300);

    BEGIN


    SET @Schema_Tables= N'Create schema '+ @Schema_Name

    EXEC sp_executesql @Schema_Tables

    SET @Schema_Tables= N'CREATE TABLE '+@Schema_Name+ '.UserGroup('



    SET @Schema_Tables= @Schema_Tables+ N'Group_id int IDENTITY(1,1) primary key NOT NULL,'



    SET @Schema_Tables= @Schema_Tables+ N'GroupName varchar(50),'



    SET @Schema_Tables= @Schema_Tables+ N'FileName varchar(70))'



    EXEC sp_executesql @Schema_Tables



    END

    GO

    this will be called from UI(asp.net ) which will send name of schema as parameter and this will execute.
    this works well when i am using in local computer but when i do the same in server i.e

    exec createschema 'schema1'

    it says
    Specified owner name 'schema1' either does not exist or you do not have permission to use it.

    i also tried
    SET @Schema_Tables= N'Create schema '+ @Schema_Name +' authorization '+ @Schema_Name

    but same error

    Help
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to SQL Server Forum.

    Comment

    Working...