All, please note the following image: I'm trying to change this BANKING schema to Banking instead and do not know the proper SQL syntax to do so... can someone please provide it to where I can run the script in SQL Server?
I'm concerned if I have to delete it first and if so, do I need to delete this table also?
Thank you for any help. It is much appreciated!
USE [UniversalDB]
GO
/****** Object: Table [Banking].[BadSSN] Script Date: 12/6/2021 5:59:10 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Banking].[BadSSN](
[ContactID] [nvarchar](20) NULL,
[PayrollID] [nvarchar](20) NULL,
[VerifiedSSN] [nchar](9) NULL,
[Name] [nvarchar](60) NULL,
[SSNStatus] [char](1) NULL,
[UserName] [nvarchar](60) NULL,
[Notes] [nvarchar](3000) NULL,
[LastAccessedDate] [datetime] NULL,
[FollowUpDate] [datetime] NULL,
[DateInserted] [datetime] NOT NULL,
[BADSSNID] [int] IDENTITY(1,1) NOT NULL,
[Amount] [money] NULL,
PRIMARY KEY CLUSTERED
(
[BADSSNID] 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
ALTER TABLE [Banking].[BadSSN] ADD DEFAULT (getdate()) FOR [DateInserted]
GO
You can't rename a schema. You'll have to create a new schema and move all objects owned by the old schema to the new schema. But, unless your instance is case sensitive, and they aren't be default, you won't be able to create a new schema name "Banking" while "BANKING" still exists, because those names are the same on a case insensitive instance (as they are by default).
So, you'll have to do this whole thing *twice*. Create a new schema, say "Banking#'. Move all objects from BANKING to BANKING#. DROP the BANKING schema. Create a new schema named 'Banking'. Move all objects from Banking# to Banking. DROP the Banking# schema.