Monday, March 19, 2012

Dump database objects without owners

Dear Friends,
Sql Server 2000
While creating the database script using EM
right-click the database to script, point to All
Tasks, and then click Generate SQL Scripts.
This creates a script with owner of the objects, like
CREATE TABLE [usera].[tbl_wi_lookup] (
[wi_lookup_id] [int] IDENTITY (1, 1) NOT NULL ,
[wi_lookup_type] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[wi_lookup_value] [varchar] (100) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
But i want to create a script without the user of the
object.
In the development machine the user 'A' owns all the
tables and scripts. I want to give the script file to
the client who may use user 'A' or User 'B' or user
'sa'.
So i want to dump the database objects without owner
information. Is there anyway to get such ddl ?
Please shed some light.
Kumar
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!I would simply open the file in a text editor and replace lit...
Unsophisticated , but done!...
As an aside, it is generally a bad idea to allow any individuals, other than
the DBO to own objects inthe database... It leads to performance issues,
code maintenance issues, etc - the first of which you see here... If DBO
owned all of the tables, you could merely generate the script and run it...
The DBO in each database could be different, and there would be no impact on
the scripting..\\\\\
Hope this helps.
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"kumar ss" <sgnerd@.yahoo.com.sg> wrote in message
news:Ou9judkFEHA.3188@.TK2MSFTNGP09.phx.gbl...
> Dear Friends,
> Sql Server 2000
> While creating the database script using EM
> right-click the database to script, point to All
> Tasks, and then click Generate SQL Scripts.
> This creates a script with owner of the objects, like
> CREATE TABLE [usera].[tbl_wi_lookup] (
> [wi_lookup_id] [int] IDENTITY (1, 1) NOT NULL ,
> [wi_lookup_type] [varchar] (50) COLLATE
> SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [wi_lookup_value] [varchar] (100) COLLATE
> SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> GO
> But i want to create a script without the user of the
> object.
> In the development machine the user 'A' owns all the
> tables and scripts. I want to give the script file to
> the client who may use user 'A' or User 'B' or user
> 'sa'.
> So i want to dump the database objects without owner
> information. Is there anyway to get such ddl ?
> Please shed some light.
> Kumar
>
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||Hi,
There is a stored procedure in the below link using SQL DMO, which will be
suit your requirement.
http://www.mssqlcity.com/Scripts/T-...erateScript.sql
Thanks
Hari
MCDBA
"kumar ss" <sgnerd@.yahoo.com.sg> wrote in message
news:Ou9judkFEHA.3188@.TK2MSFTNGP09.phx.gbl...
> Dear Friends,
> Sql Server 2000
> While creating the database script using EM
> right-click the database to script, point to All
> Tasks, and then click Generate SQL Scripts.
> This creates a script with owner of the objects, like
> CREATE TABLE [usera].[tbl_wi_lookup] (
> [wi_lookup_id] [int] IDENTITY (1, 1) NOT NULL ,
> [wi_lookup_type] [varchar] (50) COLLATE
> SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [wi_lookup_value] [varchar] (100) COLLATE
> SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> GO
> But i want to create a script without the user of the
> object.
> In the development machine the user 'A' owns all the
> tables and scripts. I want to give the script file to
> the client who may use user 'A' or User 'B' or user
> 'sa'.
> So i want to dump the database objects without owner
> information. Is there anyway to get such ddl ?
> Please shed some light.
> Kumar
>
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||EM scripting is not very customizable, I'm afraid. Query Analyzer has that o
ption, though (but you can only
script one object at a time in QA). I imagine that some of below tools also
has that option:
http://www.karaszi.com/sqlserver/in...rate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"kumar ss" <sgnerd@.yahoo.com.sg> wrote in message news:Ou9judkFEHA.3188@.TK2MSFTNGP09.phx.gb
l...
> Dear Friends,
> Sql Server 2000
> While creating the database script using EM
> right-click the database to script, point to All
> Tasks, and then click Generate SQL Scripts.
> This creates a script with owner of the objects, like
> CREATE TABLE [usera].[tbl_wi_lookup] (
> [wi_lookup_id] [int] IDENTITY (1, 1) NOT NULL ,
> [wi_lookup_type] [varchar] (50) COLLATE
> SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [wi_lookup_value] [varchar] (100) COLLATE
> SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> GO
> But i want to create a script without the user of the
> object.
> In the development machine the user 'A' owns all the
> tables and scripts. I want to give the script file to
> the client who may use user 'A' or User 'B' or user
> 'sa'.
> So i want to dump the database objects without owner
> information. Is there anyway to get such ddl ?
> Please shed some light.
> Kumar
>
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!

No comments:

Post a Comment