Sunday, 30 December 2012 17:45

how to create tables using scripts with databaseOwner and objectQualifier

Written by 
Rate this item
(0 votes)

It's a professional logic to use the databaseOwner
and objectQualifier values when creating tables
else you will not be able to identify the tables
in databases with ease and gain other benefits of it.

here is the example codes to do that when
creating tables from script in dotnetnuke modules or
others -

if not exists (select * from dbo.sysobjects where
id = object_id(N'{databaseOwner}[{objectQualifier}
MessageEncryption]') and OBJECTPROPERTY
(id, N'IsTable') = 1)
BEGIN
CREATE TABLE {databaseOwner}[{objectQualifier}
MessageEncryption]
(
[MessageId] [int] IDENTITY(1,1) NOT NULL,
[Message] [nvarchar](max) NOT NULL,
[ToAddress] [nvarchar](500) NOT NULL,
[CcAddress] [nvarchar](500) NULL,
[Subject] [nvarchar](500) NULL,
[PassCode] [nvarchar](500) NULL,
[SentDate] [datetime] NOT NULL,
CONSTRAINT [PK_data_MessageEncryption] PRIMARY KEY
CLUSTERED ([MessageId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE =
OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
END GO

Read 2709 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.