--- Seleccionamos la db donde crear
--- nuestras tablas
use TK432
go
--- Creamos un esquema para tal fin
if not exists
( select 1
from information_schema.schemata
where schema_name='Test' )
exec('create schema Test AUTHORIZATION dbo')
go
-- Primer ejemplo
-- Creamos una tabla donde probamos
-- Identity y Sparse
if object_id('test.Clientes') is not null
drop table test.Clientes
create table test.Clientes
(
ClienteId int identity(1,1),
Apellido varchar(50) not null,
Nombre varchar(50) not null,
LineaCredito money sparse null,
FechaCreacion date not null
)
go
-- Segundo ejemplo
-- Creamos una tabla donde probamos
-- compresion a nivel de fila
-- campo calculado
if object_id('test.OrdenesCabecera') is not null
drop table test.OrdenesCabecera
create table test.OrdenesCabecera
(
OrdenId int identity(1,1),
ClienteId int not null,
OrdenFecha date not null,
OrdenHora time not null,
Subtotal money not null,
ImporteFlete money not null,
Total as ( Subtotal + ImporteFlete)
)
with (DATA_COMPRESSION = row)
go
Comentarios recientes