View Full Version : Esiste un comando per SQL Server2000 tipo, "CREATE TAB
Con VB .NET + SQL Server2000, vorrei creare una tabella solo se non esiste gia', con MySql si usa il comando cha ho scritoto qui' sotto, come si fa per SQL Server2000 ???
Dim sql As String = "CREATE TABLE IF NOT EXISTS clienti(nome varchar(30))"
if (exists (select * from sysobjects
where name = '<table>' and type = 'U '))
drop table <table>
o qualcosa di simile...
Originariamente inviato da badaze
[B]if (exists (select * from sysobjects
where name = '<table>' and type = 'U '))
drop table <table>
o qualcosa di simile...
Ho trovato:
-----------------------------------------------------------------------------------
Dim conn As New SqlConnection("Data Source=localhost;Initial Catalog=my_database;Integrated Security=SSPI;")
'crea la tabella clienti solo se non esiste
Dim sql As String = "if not exists (select * from dbo.sysobjects where xtype = 'U' and name = 'clienti') CREATE TABLE clienti (nome varchar(30)"
Dim Command As New SqlCommand(sql, conn)
Command.Connection.Open()
Command.ExecuteNonQuery()
Command.Connection.Close()
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.