Delphi (BDS) Live Templates for SQL Server

Posted by Kirby Turner on December 6, 2006

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

Create SQL Server Table
<pre>


version=”1.0.0”>


Create table for SQL Server.


Kirby Turner




TableName





<![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]]>



</pre>

Create Foreign Key Reference
<pre>


version=”1.0.0”>


Create foreign key constraint for SQL Server.


Kirby Turner



PrimaryTableName






SecondaryTableName






ColumnName




<![CDATA[ALTER TABLE [dbo].[|PrimaryTableName|] WITH CHECK ADD
CONSTRAINT [FK_|PrimaryTableName|_|SecondaryTableName|] FOREIGN KEY([|ColumnName|])
REFERENCES [dbo].[|SecondaryTableName|] ([|ColumnName|])
GO]]>



</pre>

Enjoy.


Posted in programming. Tagged in delphi, windows.


Related Articles