24 June 2011

Metodo rapido per creare una Primary Key con più campi

DECLARE @tab TABLE 
(
	  IDArgomento int NOT NULL
	, TipoPagina nvarchar(20) NOT NULL
	, Sezione nvarchar(10) NOT NULL
	, MaxBanner smallint NULL
	, Larghezza int NULL
	, Altezza int NULL
	, PosLeft int NULL
	, PosTop int NULL
	, PosRight int NULL
	, PosBottom int NULL
	, PRIMARY KEY (IDArgomento, TipoPagina, Sezione)
)
Questa sintassi è valida anche con:
  • variabili di tipo TABLE (quindi anche in funzioni che ritornano tabelle!)
  • tabelle temporanee