I am trying to create replica of my database from SQL server to another.
For that I am generating script from original server and trying to run in another server. I've created database manually with the same name.
Here is the screenshot of original database
When I generate script, following script is created which I am trying in another server
USE [ContactsApp] GO /****** Object: Table [common].[BU] Script Date: 2/12/2016 3:02:29 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [common].[BU]( [ID] [int] IDENTITY(1,1) NOT NULL, [IndustryID] [int] NOT NULL, [BU] [varchar](50) NOT NULL, [Code] [varchar](2) NOT NULL, [Active] [bit] NOT NULL, [CreatedBy] [uniqueidentifier] NOT NULL, [CreateDate] [date] NOT NULL, [CreateTime] [time](3) NOT NULL, [ModifiedBy] [uniqueidentifier] NULL, [ModifyDate] [date] NULL, [ModifyTime] [time](3) NULL, CONSTRAINT [PK_BU] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], CONSTRAINT [UK_BU_Code] UNIQUE NONCLUSTERED ( [Code] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], CONSTRAINT [UK_BU_Name] UNIQUE NONCLUSTERED ( [BU] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO ALTER TABLE [common].[BU] ADD CONSTRAINT [DF_BU_CreateDate] DEFAULT (CONVERT([date],getdate())) FOR [CreateDate] GO ALTER TABLE [common].[BU] ADD CONSTRAINT [DF_BU_CreateTime] DEFAULT (CONVERT([time],getdate())) FOR [CreateTime] GO ALTER TABLE [common].[BU] WITH CHECK ADD CONSTRAINT [FK_BU_Industry] FOREIGN KEY([IndustryID]) REFERENCES [common].[Industry] ([ID]) ON DELETE CASCADE GO ALTER TABLE [common].[BU] CHECK CONSTRAINT [FK_BU_Industry] GO
When I try to run this script, I get following error
The specified schema name "common" either does not exist or you do not have permission to use it.
I don't know what is the meaning of common here.Thanks
Right-click the Security folder, point to New, and select Schema. In the Schema - New dialog box, on the General page, enter a name for the new schema in the Schema name box. In the Schema owner box, enter the name of a database user or role to own the schema.
What is Schema in SQL? In a SQL database, a schema is a list of logical structures of data. A database user owns the schema, which has the same name as the database manager. As of SQL Server 2005, a schema is an individual entity (container of objects) distinct from the user who constructs the object.
Your tables are 'grouped' (for want of better word) in schemas (google for it). You should run
CREATE SCHEMA common
And likewise for all other schemas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With