Ben bir tablo oluşturmak istiyorum. Eğer o tablo varsa o kod çalışmayacak yoksa çalışacak şekildeki kodu nasıl yazabilirim ?
If NOT exists ile kontrol edebilirsin:
if NOT exists ( select * from sys.tables where [name] = 'TabloAdi' and is_ms_shipped = 0 ) begin CREATE TABLE [dbo].[TabloAdi] ( --... ) ; --... end
Sql EXIST kullanabilirsin.
IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'TheSchema' AND TABLE_NAME = 'TheTable')) BEGIN --Do Stuff END
Mail Blog Web Site