Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Template table procedure
Message
From
18/02/2002 12:44:53
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Template table procedure
Miscellaneous
Thread ID:
00621580
Message ID:
00621580
Views:
45
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.
Next
Reply
Map
View

Click here to load this message in the networking platform