martes, 12 de julio de 2016

SQL SERVER: crear o reemplazar tabla

IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'mitabla')
DROP TABLE mitabla
GO
CREATE TABLE [dbo].[mitabla](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Fecha] [datetime] NOT NULL,
[Aplicacion] [nvarchar](200) NOT NULL,
[Version] [nvarchar](50) NOT NULL,
[Titulo] [nvarchar](200) NOT NULL,
[Modulo] [nvarchar](200) NOT NULL,
[Usuario] [nvarchar](200) NULL,
[Detalle] [nvarchar](max) NULL,
[Severidad] [nvarchar](50) NULL,
CONSTRAINT [PK_mitabla] PRIMARY KEY
(
[ID]
)