Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Template table procedure
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Template table procedure
Divers
Thread ID:
00621580
Message ID:
00621580
Vues:
39
Hello All.
I’d like to create a stored procedure which would create a template table. The procedure should do sort of a macro substitution, substituting MyTable with the name of a table i will supply as a parameter. Something like this:
CREATE TABLE [dbo].MyTable (
	[PK]  uniqueidentifier ROWGUIDCOL  NOT NULL ,
	[UID] [int] NULL ,
	[Changed] [datetime] NOT NULL 
)
ALTER TABLE [dbo]. MyTable WITH NOCHECK ADD 
	CONSTRAINT [DF_ MyTable _PK] DEFAULT (newid()) FOR [PK],
	CONSTRAINT [DF_ MyTable _Changed] DEFAULT (getdate()) FOR [Changed],
	CONSTRAINT [PK_ MyTable] PRIMARY KEY  CLUSTERED 
	(
		[PK]
	)  ON [PRIMARY]
Best wishes.
Kamil.
A moment of silence is our cosmic reset button.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform