Tables Exist But Wont Drop
Dec 11, 1998
I have two tables that will not drop in a Database. I'm running SQL 6.5 on a Compaq Proliant.
Symptoms: Both tables show up in sysobjects, sysindexes, and syscolumns. Both allow SELECT, sp_rename, and truncate, but just hang ISQL or the Enterprise Manager when I try to drop them. I ran a DBCC CheckTable on them with no errors reported. Any ideas??
View 2 Replies
ADVERTISEMENT
Mar 14, 2008
When I am initializing a transactional replication from SQL 2005 to Oracle 10g, SQL tries to drop tables that don't exist. The properties option for the articles specifically states "if the name is in use:". The name is not in use, yet SQL still tries to drop non-existent tables, which causes the replication to halt. Anyone seen this before, or have any ideas what to do about it?
Thanks!
View 10 Replies
View Related
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
Jun 19, 2007
How can i delete a stored procedure if it exist
like "Drop stored procedure 'sp1' if exist"
View 4 Replies
View Related
Apr 8, 2008
I have a stored procedure that I am writing that is giving me trouble dropping a temp table in SQL Server 2005. I have to use the SQL in Query 1, marked below, to get the temp table. I can find the table but I get the error listed in this message's subject. If I try to run DROP TABLE #ZipLatLong I will get an error telling me that the table already exists but then I can run CREATE TABLE #ZipLatLong ( ZIP INT, Latitude DECIMAL(18,6), Longitude DECIMAL(18,6)) and that will work...
In short, SQL Server 2005 is not letting me drop temporary objects. I am getting return messages telling me that an object already exists in the database by the name I am trying to delete and then it will let me create a table with the same name...
Figure 1
USE TEMPDB
GO
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = 'tempdb'
AND TABLE_SCHEMA = USER
AND TABLE_NAME LIKE '#ZipLatLong%'
GO
DROP TABLE #ZipLatLong
GO
View 5 Replies
View Related
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
Jun 25, 2001
I am work on SQL Server 6.5
When I want to drop a view then appear error message :
"Msg 3701, Level 11, State 1 Cannot drop the view 'EUL_ODBC_SCHEMAS',
because it doesn't exist in the system catalogs."
Has anybody else experienced this, and do you know what is causing the warning?
Thanks in advance for any replies.
View 2 Replies
View Related
Mar 2, 2008
Does anyone have a script that can drop the Identity columns from all the tables in a database? Thanks
View 1 Replies
View Related
Jan 31, 2008
Hi,
Is thr any query to drop around 20 tables at a time????
or shud i need to drop them individually one at a time???
View 1 Replies
View Related
Apr 25, 2007
what is the sql query to drop all tables in a database in sql server 2000
View 5 Replies
View Related
Mar 7, 1999
Hi,
I want to write a script that will drop all tables in a database that begin with BACKUP.
Is there an easy way of doing this?
Thanks
Phil
View 1 Replies
View Related
Feb 1, 2007
I have a list of 35 tables that need to drop the primary key index from in my database.
My problem is as follows for these 35 tables:
1. How can I get a list of all the primary keys for this subset of tables in my database
2. How can I drop just the PK for each of these tables?
I want an easy quick way to do this without having to manually do this for each of the 35 tables in my database. I dont want to do this for all tables just the subset.
Thanks
View 9 Replies
View Related
May 30, 2008
I need to drop multiple tables in an SP... all the tables starts with a string that I can use... please suggest me the best way to drop all these tables in an SP that has more than just this.. Thanks!
View 2 Replies
View Related
Dec 6, 2006
I need to create a file that removes (drops) all of your database objects.
View 12 Replies
View Related
Jun 15, 2007
Hello all, im using visual web developer btw. Im using the excellent tutorial here at http://www.asp.net/learn/videos/view.aspx?tabid=63&id=49 Works a treat. For my catalogue/database. i have 2 tables using the drop down menu - one is a "Buyers guide" (a list of the product) and an "application list" (this one is a list of the motorbike).
So in essence they are the same tables, but of course moved around with slightly different ways. What i would like to, is to some how make a refferenced link to each - Once one of the drop down menus has been linked to a product, theres a column that tells u what bike is being used....i therefore want to have a link so the seconmdary drop down menu - but i do not know how i can do this. Any ideas guys/gals? thx.
View 1 Replies
View Related
Nov 23, 2005
Hi,
I want to get the results of a query between 2 tables that exist in the same server but in 2 different databases. I want this query to be executed in a stored procedure (use the reults in a cursor), or if it's possible to be used in an ado dataset or a simple dataset in Delphi. Can this be done also if the two datases (MSSQL) exist in different servers??
Can anyone show an example of how to accomplish these tasks??
Best Regards,
Manolis Perrakis
View 9 Replies
View Related
Aug 30, 2006
I have two SPs, call them Daily and Weekly. Weekly will always callDaily, but Daily can run on its own. I currently use a global temptable because certain things I do with it won't work with a local temptable or table variable.I have been trying to get code so that if the table already exists, itjust keeps going and uses it, but creates the temp table if it doesn'texist. Unfortunately, no matter how I try to do it, it always attemptsto create it, raising an error and breaking the code.create table ##load_file_log (id int identity(1,1),contentsvarchar(1000))insert into ##load_file_log (contents) values ('test record')IF object_id('tempdb..##load_file_log') IS not NULLprint 'exists'ELSEcreate table ##load_file_log (id int identity(1,1),contentsvarchar(1000))select * from ##load_file_logdrop table ##load_file_logIf I change it to IS NULL, the same error occurs (Server: Msg 2714,Level 16, State 1, Line 7There is already an object named '##load_file_log' in the database.)I have found one way to do it, but it seems a bit...clunky.IF object_id('tempdb..##load_file_log') IS NULLexec ('create table ##load_file_log (id int identity(1,1),contentsvarchar(1000))')I'll use that for now, but is there something I missed?Thanks.
View 4 Replies
View Related
Jun 2, 2015
I need to show maxInspectionDate in my result but I can't figure out how to do it.
SELECT E.equipmentID, E.assetNumber, E.T5Code , E.InspectionDuration, E.Description,
E.AssetType, E.WorkingLimits
FROM Equipment E
WHERE EXISTS
(SELECT t.equipmentID, r.maxInspectionDate
FROM (
SELECT equipmentID, MAX(nextInspectionDate) as maxInspectionDate
FROM equipmentInspection
GROUP BY equipmentID
) r
INNER JOIN equipmentInspection t
ON t.equipmentID = r.equipmentID AND t.nextInspectionDate = r.maxInspectionDate)
View 9 Replies
View Related
Jul 21, 2003
How to find out all the statistics from all the tables and drop them..any script anyone can help with?
When we are trying to make datatype changes in few related tables,it's giving error saying that some statistics are dependent onthe column blah blah...
Thanks,
Sheila.
View 1 Replies
View Related
Jul 20, 2005
SQL SERVER 2000System let's you alter the system tables and add indexes. However, it won'tlet you drop the index afterward.Anybody know how to drop an index on a system table?Thanks,Kevin
View 4 Replies
View Related
Oct 23, 2007
I have 1000's of tables. Some are of the form dbo.VT_2006-10-12. I'd like to drop all tables with the "VT" in the table name. How is the best done?
View 6 Replies
View Related
Apr 12, 2006
I have a package that i want to move between enviroments. Therefor i need to create a package that creates all my tables on the new server.
like
-- "if exists (select * from dbo.sysobjects where id = object_id(N'[table]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [table]
GO"
The case is that i have around 30 tables, and my question is therefore
I know that you can create the drop and create script for one table at the time in the SQL Server Management Studio, but is there an easier way to do this
View 1 Replies
View Related
Sep 10, 2007
Hello,
I have a query that's in development that uses several temp tables. In order to test the query repeatedly while it's being written I have the following code at the beginning to discard the temp tables. This allows the query can recreate the temp tables when called in the code.
if object_id('tempdb..#temp1') is not null drop table #temp1
if object_id('tempdb..#temp2') is not null drop table #temp2
if object_id('tempdb..#temp3') is not null drop table #temp3
if object_id('tempdb..#temp4') is not null drop table #temp4
if object_id('tempdb..#temp5') is not null drop table #temp5
Even though this works, it takes multiple lines of code. One of my queries has to drop 12 temp tables, thus 12 lines of code. I have been experimenting with looping the above as follows:
declare @n as nvarchar(3), @table as nvarchar(10)
set @n = 1
while @n <= 5 begin
set @table = '#temp'+@n
if object_id('tempdb..#temp'+@n) is not null drop table @table
set @n = @n + 1
end
Unfortunately, the above does not work. It gives this error message:
Server: Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near '@table'.
I have also tried:
declare @n as nvarchar(3), @dropstmt as nvarchar(25)
set @n = 1
while @n <= 5 begin
set @dropstmt = 'drop table #temp'+@n
if object_id('tempdb..#temp'+@n) is not null @dropstmt
set @n = @n + 1
end
This does not work either. It gives this error message:
Server: Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near '@dropstmt'.
Does anyone know how to get this to work?
Thanks.
View 8 Replies
View Related
Sep 28, 2007
Hi! Is there a way to delete a record from multiple tables at the same time? Thanks for the help!
View 6 Replies
View Related
Mar 31, 2008
Hello.
I need some help constructing a query i need to run on my database. I need to add 2 fields to every table in my databse. However, some of the tables already have1 or both these fields so i need to somehow do a check if the dield already exists. If it does not create the fields. Im using a MS SQL express 2005 server.
Could anyone help me construct this. Im pretty novice at SQL.
Thanks.
View 7 Replies
View Related
Mar 28, 2008
Hi everyone.
I am stuck on this for quite a while. Lets say i have 2 tables.
Table 1 with these columns:
Serial_Num
Product
Price
Table 2 with this column only:
Product
I need to create a VIEW that will show me all the the data in Table 1 but only for the column that exists in table 2. Example:
Something like this:
select (all the columns from table 2)
from table 1
I need it to be dynamic because columns could be added to both tables anytime.
Thanks.
View 5 Replies
View Related
Jan 16, 2014
I used code below to drop one temporary table. How to make code to drop all temporary tables?
IF OBJECT_ID('tempdb..#Temp') IS NOT NULL
BEGIN
DROP TABLE #Temp
END
View 9 Replies
View Related
Apr 17, 2008
Greetings
I am thinking of creating a script that generates another script for creating/dropping tables, indeces, FK, views, stored procedures..etc in the right order in a specific database. I accept the fact this script is dangerous (like if I ran it on production server). But it sure will be very helpful when moving our SQL objects from development to qa and then to production. Is this worth it? Haev you see anything that generates such a thing?
Thanks
View 1 Replies
View Related
Jul 20, 2005
Just a quicky about temporarary tables. If using QA, when you create atemporary table, it gets dropped if you close the query. Otherwise youneed to state 'DROP TABLE myTable' so that you can re-run the querywithout the table being there.Sometimes, you can have quite lengthy SQL statements (in a series)with various drop table sections throughout the query. Ideally youwould put these all at the end, but sometimes you will need to dropsome part way through (for ease of reading and max temp tables etc...)However, what I was wondering is :Is there any way to quickly drop the temporary tables for the currentconnection without specifying all of the tables individually ? Whentesting/checking, you have to work your way through and run each droptable section individually. This can be time consuming, so beingnaturally lazy, is there a quick way of doing this ? When workingthrough the SQL, it's possible to do this quite a lot.ExampleSQL Statement with several parts, each uses a series of temporarytables to create a result set. At the end of a section, these worktables are no longer needed, so drop table commands are used. Thefinal result set brings back the combined results from each sectionand then drops those at the end.TIARyan
View 2 Replies
View Related
Jul 31, 2015
what are the minimum permissions to allow a user to view, create, & drop tables within a DB (SQL 2008)?
View 4 Replies
View Related
Mar 24, 2008
What SQL statement can i run to return a list of new tables or columns that exist in the Sales Database on Server A, which do not exist in the Sales Database in Server B.
Server A and Server B are linked servers.
I am using SQL Server 2005. Thanks.
View 1 Replies
View Related
Aug 19, 2015
I need to get all distinct values from 10 different tables that exist in the field [favoritesport] And each table holds close to 50K records so I am looking at 500,000 records to get distinct values for. Would the fastest, less intrusive way of achieving this be to just create a UNION ALL so run
Select Distinct([favoritesport]) from table1
Union
Select Distinct([favoritesport]) from table2
Union
Select Distinct([favoritesport]) from table3
etc etc etc
View 2 Replies
View Related
Sep 7, 2000
Hello All,
Has any1 noticed that when they are transferring SQL tables from one server (or machine) to another that the primary keys drop from the table (or is it just me). If so, has someone figured out why? and how to rectify this (apparent) error.
Many thanks in advance for any and all help,
Gurmi
View 1 Replies
View Related