Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
olibara
Yak Posting Veteran
94 Posts |
Posted - 2012-02-22 : 07:03:37
|
| Hello In mysql there is a very simple way to test if a table exists before to drop it DROP Table IF EXISTS 'MaTable'I do not found any equivallent in Sql ServerHow can I do that on a simple way ?Thanks for your help |
|
|
Mahdi Eftekhari Moghaddam
Starting Member
3 Posts |
Posted - 2012-02-22 : 07:07:00
|
| [code]IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[YourTableName]') AND type in (N'U'))DROP TABLE [dbo].[YourTableName][/code]If it does not help please let me knowRegardsMahdi Eftekhari |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2012-02-22 : 07:31:45
|
| if (OBJECT_ID('YourTableName') >0 )Drop table 'YourTableName'Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
 |
|
|
olibara
Yak Posting Veteran
94 Posts |
Posted - 2012-02-22 : 12:10:10
|
| Thank YouIt is not so easy as in MySql but Ok ! |
 |
|
|
|
|
|