Here are a few Delphi (BDS) Live Templates I created for writting SQL Server script:

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

Comment:
(No HTML)

Name:
E-mail/Web site:
Your e-mail/web site will not be published on this site. It is optional and will only be used by me should I need to contact you directly.
 
By checking this option, this site will remember your name and e-mail/web site on future visits. Uncheck this option to have the site not remember who you are on future visits.
 
Enter the code shown above:
Copyright © 1999-2008 Kirby Turner.
Site software written by White Peak Software Inc, a provider of custom software and software development coaching.