Drop All Objects

Jul 18, 2007

HI,



Been poking around in sysobjects and information_schema.routines trying to work out how to best write scripts that will drop all specific objects from a database.



That is, scripts to drop all tables, views, stored procs, functions ( FN, IF, TF ) but can't seem to figure out appropriate way to do it.



A pointer on how to drop all of any one of the above object types would be greatly appreciated and I should be able to work out the others.



Further, when executing multiple scripts I am writing scripts like this...



ddl_batch.sql


Code Snippet

:R table1.sql

:R table2.sql

:R ufn_func1.sql

:R ufn_func2.sql

:R view_table1

:R view_table2

:R usp_proc1.sql

:R usp_proc2.sql



And executing via:

sqlcmd -S serverinstance -i ddl_batch.sql



This is to maintain individual object type scripts, and then to execute them together in dependency order, rather than executing one monolithic batch script. Is this a reasonable way to go about it or is there a better way?



Many thanks in advance for your help.





View 3 Replies


ADVERTISEMENT

Drop All Objects In Database?

Feb 14, 2006

I'd like to write a stored procedure to drop all objects in a SQL Server 2000 database owned by a particular uid. Originally I'd hoped to use these two stored proc built-ins for the task: sp_MScheck_uid_owns_anything (to get a list of all objects owned by a uid) and sp_MSdrop_object (to drop the objects). I've run into a few problems along the way:

1. If I run this command

EXEC sp_MScheck_uid_owns_anything 5

I get this weird error message:

"The user owns objects in the database and cannot be dropped."

Not sure why that is since I'm just trying to list the objects, not drop them.

2. I tried running a simple query to get the objects from the system table instead:

SELECT * from [dbo].[sysobjects] where uid = 5

This returns a resultSet as you'd expect. When I wrote a stored procedure to loop through these and use sp_MSdrop_object it seemed to fail whenever it encountered a foreign key object. Here is the error message:

The request for procedure 'name of foreign key' failed because 'name of foreign key' is a unknown type object.

Can anyone give advice as to the best way to go about doing this? I'd really prefer not to have to drop the entire database and recreate it. Thanks!


-Cliff

View 7 Replies View Related

Drop All Database Objects

Feb 3, 2006

Does anyone happen to have a script that will drop all database objects?

I'm looking for something generic that will work with any SQL Server 2000 database. I can write one myself, but I thought I would check here first.

Thanks in advance

John

View 2 Replies View Related

Drop Schema And Its Objects

May 9, 2007



I want to be able to drop a schema and all its objects if they exist. Can someone help me with such a stored procedure. I see the sql server does not allow dropping schema directly if it contains some objects.

View 10 Replies View Related

How To Get Information About Create/drop Objects?

Oct 2, 2000

How to SQL server save information about create/drop objects action. How can I get this? Example for, a lot of objects(sp) in my database has been dropped, how I know who was dropped them (user login & time)?

View 1 Replies View Related

ALTER TABLE DROP COLUMN LastUpdated Failed Because One Or More Objects Access This Column.

Mar 7, 2008

Hi I’m trying to alter a table and delete a column I get the following error. The object 'DF__Morningst__LastU__19EB91BA' is dependent on column 'LastUpdated'.
ALTER TABLE DROP COLUMN LastUpdated failed because one or more objects access this column. I tried deleting the concerned constraint. But the next time I get the same error with a different constraint name. I want to find out if I can dynamically check the constraint name and delete it and then drop the column. Can anyone help.IF EXISTS(SELECT 1FROM sysobjects,syscolumnsWHERE sysobjects.id = syscolumns.idAND sysobjects.name = TablenameAND syscolumns.name = column name)BEGIN EXECUTE ('ALTER TABLE tablename DROP CONSTRAINT DF__SecurityM__DsegL__08C105B8')EXECUTE ('ALTER TABLE tablenameDrop column columnname)ENDGO
 

View 1 Replies View Related

Putting Names Of Objects To Control-flow Loop Creating Objects

Dec 27, 2006

please help newbieI need to create a lot of objects the same type (let's say: schemas)I wish to use paramerized block in loop to do so.- how to put names of my objects to such control-flow?belss you for help

View 5 Replies View Related

SQL Server 2012 :: Select Data From XML - Objects Within Objects?

Nov 20, 2013

passing serialised objects to a stored procedure for the purpose of data inserts. I see this as being a way to handle multiple row inserts efficiently.

However, in my limited use of XML data I am not so sure how to link the data when I have a dependency on another "object" within the serialised XML.

Below is a code snippet showing what I have so far.

The first insert statement works fine - but how to retrieve the identifier created by the DB - I want to use an SQL statement that finds the record in the table based on the XML representation (of the PluginInfo), allowing me to insert the ConfigurationInfo with the correct reference to the PluginInfo

DECLARE @Config NVARCHAR(MAX)
DECLARE @Handle AS INT
DECLARE @TransactionCount AS INT
SELECT @Config = '
<ConfigurationDirectory >
<ConfigurationInfo groupKey="Notifications" sectionKey="App.Customization.PluginInfo"

[code]....

View 1 Replies View Related

Drop All Indexes In A Table, How To Drop All For User Tables In Database

Oct 9, 2006

Hi,I found this SQL in the news group to drop indexs in a table. I need ascript that will drop all indexes in all user tables of a givendatabase:DECLARE @indexName NVARCHAR(128)DECLARE @dropIndexSql NVARCHAR(4000)DECLARE tableIndexes CURSOR FORSELECT name FROM sysindexesWHERE id = OBJECT_ID(N'F_BI_Registration_Tracking_Summary')AND indid 0AND indid < 255AND INDEXPROPERTY(id, name, 'IsStatistics') = 0OPEN tableIndexesFETCH NEXT FROM tableIndexes INTO @indexNameWHILE @@fetch_status = 0BEGINSET @dropIndexSql = N' DROP INDEXF_BI_Registration_Tracking_Summary.' + @indexNameEXEC sp_executesql @dropIndexSqlFETCH NEXT FROM tableIndexes INTO @indexNameENDCLOSE tableIndexesDEALLOCATE tableIndexesTIARob

View 2 Replies View Related

Rollback Will Drop Created Tables And Drop Created Tables In Transaction..?

Dec 28, 1999

Hi folks.

Here i have small problem in transactions.I don't know how it is happaning.
Up to my knowldge if you start a transaction in side the transaction if you have DML statements
Those statements only will be effected by rollback or commit but in MS SQL SERVER 7.0 and 6.5
It is rolling back all the commands including DDL witch it shouldn't please let me know on that
If any one can help this please tell me ...........Please............
For Example
begin transaction t1
create table t1
drop table t2

then execute bellow statements
select * from t1
this query gives you table with out data

select * from t2
you will recieve an error that there is no object

but if you rollback
T1 willn't be there in the database

droped table t2 will come back please explain how it can happand.....................

Email Address:
myself@ramkistuff.8m.com

View 1 Replies View Related

OLE Objects

Aug 27, 2001

Hi, there,

I use VB to make an dll file and register on my local PC, then use sp_OACreate to create OLE object on local SQL server, it works fine. But when I register that dll on other SQL server, it dosen't work, anybody have idea about this? Thank you.

Tony

View 1 Replies View Related

How To Use Objects??

Jul 17, 2000

I see these type of objects in Books on Online. I was just wondering
if anyone knows how to use these objects, seems to have lot of good
information. Could these objects be called in VB?

--------------------------------
CreateDate Property (SQL-DMO)
The CreateDate property indicates the date and time the referenced SQLServer object was created.

Applies To
Database Object Table Object
DBObject Object TransactionLog Object
Default Object Trigger Object
Rule Object View Object
StoredProcedure Object


Syntax
object.CreateDate

Part Description
object Expression that evaluates to an object in the Applies To list


Remarks
The string returned is formatted by using the locale setting of the workstation.

Data Type
String

Modifiable
Read-only

Prototype (C/C++)
HRESULT GetCreateDate(SQLDMO_LPBSTR pRetVal);
--------------------------------------------------------

View 1 Replies View Related

Sys.objects

Sep 21, 2007



Anyone know how to grant a user to see all data in sys.objects view?

Thanks.

View 1 Replies View Related

Sys.objects

Sep 21, 2007



Anyone know how to grant a user (who is not a sa) to see all data in sys.objects view?

Thanks.

View 1 Replies View Related

COM Objects Under 64-bit?

Jan 25, 2007

Hi everyone,
 
Primary platform is Framework 2.0 under 32-bit
Production platform will be Framework 2.0 under 64-bit.
 
I'm concerned about what object should I use in order to launch DTS 2000/7.0 from our .Net service.
 
Currently it tested fine from a 32-bit environment (sql server 2005 as backend).
 
Reference: "Microsoft DTSPackage Object Library"
Physical file:  dtspkg.dll
 
My wonder,  is there any limitation when it's gonna to work on 64-bit?
 
Generally speaking, any limitation/issue/drawback for COM objects under 64 bit??
In my project properties appears Any CPU, x86, x64. I've got now Any CPU.
 
Thanks for your advices,
 
 

View 13 Replies View Related

Closing ADO Objects

Apr 4, 2007

I know it's "best practice" to dispose ado.net objects, but does it make a big difference if just the connection is closed? In other words, is the code below good enough or should the DataAdapter & Command be explicitly closed?using (SqlConneciton  cn = new SqlConnection(connstr)){ SqlDataAdapter da = new SqlDataAdapter(sql,cn);DataSet ds = new DataSet();da.Fill(ds); SqlCommand cmd = new SqlCommand(someOtherSql,cn);cmd.ExecuteNonQuery();  } 

View 2 Replies View Related

Objects In SQL Server

Jun 16, 2008

Hi,
I am a Database called "Cache"  user and in it and when creating a new table I can create a column of type Object.
So basically, I can create an object eg. Address that have the following items StreetNo, StreetName, PCode somewhere in my database; then create a table called eg. Employees that have a column called EmployeeAddress of type Address (as my Address Object). Can this be done in SQL Server!?
 
 
Thanks. 

View 4 Replies View Related

Managed Objects

Mar 21, 2006

Hello people :-)I'm doing some development work with Visual Studio 2005 and SQLServer 2000. My SQL DB is running on a Windows 2000 Server box in the office, and I'm doing the development on my XPPro workstation. Now I've been trying to connect to the Win2000 box though VS and although I can see the server and the DB when I hit ok I get this error"The SQL server specified by these connection propertise does not support managed objects"What the heck does that mean?any help would be great :-)

View 1 Replies View Related

Protecting Objects From Even The SA

Feb 22, 2001

I am currently writing a VB app based around a SQLserver2000 database. I have used stored procedures wherever possible to select/update/delete data. I am planning to distribute this app and wonder whether there are any tricks out there for encrypting/setting security so that even the SA account would be unable to read my stored procedures, but obviously be able to execute them?

There are two scenarios - one is where I want to let someone borrow a laptop just for a few days for a demo. Presumably I just give them an unprivileged user account without interactive logon possibilities, by which I mean Enterprise Manager and the other SQLserver Client tools [can I do this?] and control all access from the app.

The other scenario is when the app is purchased and I no longer have control of the SQL Server nor the SA account.

Any pointers would certainly be very useful indeed. Thanks.

View 1 Replies View Related

Export Objects

Jan 2, 2002

Hi all, I know we can use DTS package to export or import objects from one db to another. Now I need to write a procedure that will perform similar functionality. Any thoughts on this? Thank you!

View 2 Replies View Related

Transfer/Objects

Jul 26, 2000

Hi,
I am in the process of upgrading database in sql server 6.5 to 7.0.
For that i am following one computer upgrade.
For creating dev environment in my computer i am using Transfer/Objects in 6.5
for transferring database from remote(production) computer to my computer.

Do i need only to transfer Userdatabase alone or do i need to Transfer Master and other ?
Or Is it better to restore dump ?


Thanks

View 4 Replies View Related

Hiding Particular Objects

Aug 1, 2000

Hey guys,
Is there any way to hide a particular object(table,sp,tr etc) from
a particular user?

we are developing softwares for the clients..and Once we install our product we dont want the clients site guys to go and delibrately view the data from sql server but through the front end. Is there anyway that i can do that...?

For Eg..the front end codes are capsulated as DLLs so that no can view the code.. Like that for SQL Server..can we do that kinda stuffs to prevent them?

View 5 Replies View Related

Script Objects

Aug 14, 2000

Is there a way to schedule the creation of script to create database objects?
I am using DTS to transfer data between two 6.5 servers, but I need a way to
sync the stored procs. I thought I could schedule the creation of a script to create all the
procs and then run it every day.
Thanks

View 1 Replies View Related

Script Objects

Aug 14, 2000

Is there a way to schedule the creation of script to create database objects?
I am using DTS to transfer data between two 6.5 servers, but I need a way to
sync the stored procs. I thought I could schedule the creation of a script to create all the
procs and then run it every day before everyone needs the systems.
Thanks

View 1 Replies View Related

Open Objects Value

Jul 31, 2000

SQL server 6.5 stopped responding. The last error messages in the SQL Server Error Log / NT Event log suggested that I increase the Open Objects / Open Databases values. I rebooted the server, increase the configuration values, and rebooted the server again for the new configuration to take affect. I suspect that the front-end application does not release the objects properly when it should; therefore increasing Open Objects / Databases configuration values will only be a temporary fix until they reach the new maximum in some time. However to prove that I need to be able to determine how many open objects / databases are on the server at a point of time. Is there a procedure or a method to determine how many open objects / dtabases are on server?

Any comments or suggestions are greatly appreciated.

Thank you
Marina Somers

View 1 Replies View Related

CHanged Objects

Dec 7, 1999

Is there a way to produce a query to look at when and who changed database objects last?

View 1 Replies View Related

Copying Objects

Mar 5, 2003

Is it possible to copy tables/indexes/data from one db to another (on the same server) while specifying a new owner & w/o logging?

View 11 Replies View Related

Transfer Of Objects

Aug 3, 1998

This should be simple. I am transfering one database from box A to the same database structure on box B. Straight transfer with the transfer utility. All objects, all defaults. The problem is that now, not all the objects are transfering. There are about 20 tables that are not being populated. The table gets dropped and recreated, but not populated. There is plenty of disk space and the log is empty. (or so reported) Why are not all the tables going over. I can manually repopulate the tables and no problems. ANY hints are greatly appreciated.

Thanks,
Peter Cwik

View 3 Replies View Related

No SQL Objects In Perfmon

Mar 17, 1999

I am not showing any sql objects when trying to monitor my sql server through perfmon. This is the situation when running NT perfmon or SQL perfmon locally on the server or from a workstation through the network. I have found some tech net articles but they all say that the ojects should exist locally on the server. Any ideas?

Thanks David

View 1 Replies View Related

No SQL Objects In Perfom

Mar 12, 1999

I have a strange situation occuring. Our SQL server (BDC on resource domain) loses rpc connectivity after 90 minutes. After that time we cannot log on to the server. Get "System Cannot Log You on C0000017 error. Technet says this is due to a memory leak. THe only thing running on this server is SQL. Recently I changed security from mixed to standard and back to mixed as a test, bumped user connections from 500 to 1000 and moved two new databases to this server. THe strange thing is that after rebooting and ablitly to log on I see the sqlservr.exe process take up 64 mbs of data. But there does not seem to be any other memory indications.
Any ideas?

View 1 Replies View Related

Copy Db And All Its Objects

Sep 3, 2001

how can i copy a data base created in sql server2000 to another server (sqlserver2000)without replication because they're distant and not connected i have tried the DTS but it does'nt copy stored proc ,views,triggers,diagram,...
help please

View 1 Replies View Related

Sizing Db Objects

Dec 28, 2004

Hello, I'm looking for a sizing Excel (or any other format) file, that permits me evaluate the size of my sql server database, actually I have one excel file for Oracle, where I only put the expected # of rows, the average size of the columns, and other few data, and I can get the size (in Megabytes) of a table or an Index.

Could you provide me something similar??

Thanks !

View 1 Replies View Related

How To Transfer All Objects

Mar 30, 2015

I have an upgrade to do from Sql-Server 2005 to Sql Server 2014. how I would do the upgrade! Should I install 2014 on another box or the same box (or do I just upgrade over the 2005 version - which seems risky)? How do I transfer all of the objects from 2005 to 2014? I'm referring to the tables/ sprocs/ views/ etc already on 2005?

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved