Create SQL Server Table
<?xml version="1.0" encoding="utf-8" ?>
<codetemplate xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
version="1.0.0">
<template name="table" invoke="manual">
<description>
Create table for SQL Server.
</description>
<author>
Kirby Turner
</author>
<point name="TableName">
<text>
TableName
</text>
<hint>
</hint>
</point>
<code language="SQL" delimiter="|"><![CDATA[/***
Create |TableName| table.
***/
PRINT 'Create |TableName| table'
GO
IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'|TableName|') AND (type = 'U')))
BEGIN
DROP TABLE [dbo].[|TableName|]
END
GO
CREATE TABLE [dbo].[|TableName|] (
|*||end|
|*|CONSTRAINT [PK_|TableName|_1] PRIMARY KEY CLUSTERED
|*|(
|*|)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
GRANT SELECT ON [dbo].[|TableName|] TO [public]
GO]]>
</code>
</template>
</codetemplate>
Create Foreign Key Reference
<?xml version="1.0" encoding="utf-8" ?>
<codetemplate xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
version="1.0.0">
<template name="fk" invoke="manual">
<description>
Create foreign key constraint for SQL Server.
</description>
<author>
Kirby Turner
</author>
<point name="PrimaryTableName">
<text>
PrimaryTableName
</text>
<hint>
</hint>
</point>
<point name="SecondaryTableName">
<text>
SecondaryTableName
</text>
<hint>
</hint>
</point>
<point name="ColumnName">
<text>
ColumnName
</text>
<hint>
</hint>
</point>
<code language="SQL" delimiter="|"><![CDATA[ALTER TABLE [dbo].[|PrimaryTableName|] WITH CHECK ADD
CONSTRAINT [FK_|PrimaryTableName|_|SecondaryTableName|] FOREIGN KEY([|ColumnName|])
REFERENCES [dbo].[|SecondaryTableName|] ([|ColumnName|])
GO]]>
</code>
</template>
</codetemplate>
Enjoy. posted by Kirby | 06-Dec-2006 9:35 AM | comments (0)
Add Your Comment
