
CREATE TABLE tblEstadosSalesOrders (fcreado ,
id int NOT NULL PRIMARY KEY ,
borrado ,
Descripcion ,
intOrder ,
strIdEnvironment FOREIGN KEY REFERENCES tblSucursales(id) ,
win ,
lost)


CREATE TABLE expedientes (idinstalador FOREIGN KEY REFERENCES empresas(id) ,
idingenieria FOREIGN KEY REFERENCES empresas(id) ,
idconstructora FOREIGN KEY REFERENCES empresas(id) ,
direccion ,
direccion2 ,
dblvalor ,
idsucursal FOREIGN KEY REFERENCES tblSucursales(id) ,
strpoblacion ,
fechacierre ,
dtprevfechaventa ,
observaciones ,
idcountry FOREIGN KEY REFERENCES tblCountries(id) ,
extid ,
geocodelat ,
geocodelon ,
blngeocoded ,
intgeoaccuracy ,
nivel ,
cp ,
ratio ,
strprovincia ,
idcomercial FOREIGN KEY REFERENCES tblUsuarios(id) ,
idestadoobra FOREIGN KEY REFERENCES tblEstadoExpediente(id) ,
referencia ,
blnreadonly ,
fechaganada ,
fechaperdida ,
UserBorrado ,
id int NOT NULL PRIMARY KEY ,
borrado ,
idtipo FOREIGN KEY REFERENCES tblTiposExpediente(id) ,
fGeocoded ,
fModificadoidEstadoObra ,
userModificadoidEstadoObra)




CREATE TABLE empresas (idtipo FOREIGN KEY REFERENCES tblTiposEmpresa(id) ,
direccion ,
direccion2 ,
idsucursal FOREIGN KEY REFERENCES tblSucursales(id) ,
strpoblacion ,
observaciones ,
idcountry FOREIGN KEY REFERENCES tblCountries(id) ,
email ,
extid ,
fax ,
geocodelon ,
geocodelat ,
blngeocoded ,
intgeoaccuracy ,
strmovil ,
nombre ,
nivel ,
tel ,
tel2 ,
cp ,
strprovincia ,
idComercial FOREIGN KEY REFERENCES tblUsuarios(id) ,
idcalificacion FOREIGN KEY REFERENCES tblTiposCalificacionEmpresa(id) ,
nif ,
showall ,
web ,
id int NOT NULL PRIMARY KEY ,
borrado ,
blnEnviarPublicidad ,
fGeocoded)


CREATE TABLE tblsalesorders (reference ,
comments ,
internalComments ,
idEmpresa FOREIGN KEY REFERENCES empresas(id) ,
idContacto FOREIGN KEY REFERENCES contactos(id) ,
idEstadoSalesOrder FOREIGN KEY REFERENCES tblEstadosSalesOrders(id) ,
idTarifa FOREIGN KEY REFERENCES tbltarifas(id) ,
discount1 ,
discount2 ,
discount3 ,
discount4 ,
idComercial FOREIGN KEY REFERENCES tblUsuarios(id) ,
expectedCloseDate ,
CloseDate ,
totalAmount ,
readOnly ,
fModificadoInternalComments ,
userModificadoInternalComments FOREIGN KEY REFERENCES tblUsuarios(id) ,
archived ,
year ,
number ,
idExpediente FOREIGN KEY REFERENCES expedientes(id) ,
idCurrency FOREIGN KEY REFERENCES tblCurrency(id) ,
extID ,
idSucursal FOREIGN KEY REFERENCES tblSucursales(id) ,
idCompanyAddress FOREIGN KEY REFERENCES EmpresasAddresses(id) ,
blnPrincipal ,
id int NOT NULL PRIMARY KEY ,
borrado ,
blocked ,
salesOrderType)


Podrias sacarme la consulta SQL de "muestrame t Make sure to only use capital letters in your entire response.
user