Question : how can I check if a table exist and if exist I drop it?


Hello guys

I need to drop a temporary table, but before doing it, I need to check if the table exists.

How can I do this?

thanks

Answer : how can I check if a table exist and if exist I drop it?

Sorry
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
IF object_id('tempdb..#MyTempTable') IS NOT NULL
BEGIN
   DROP TABLE #MyTempTable
END

CREATE TABLE #MyTempTable
(
   ID int IDENTITY(1,1),
   SomeValue varchar(100)
)
GO
Random Solutions  
 
programming4us programming4us