if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_template_templateType]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[template] DROP CONSTRAINT FK_template_templateType
GO

ALTER TABLE [dbo].[template] ADD 
	CONSTRAINT [FK_template_templateType] FOREIGN KEY 
	(
		[typeId]
	) REFERENCES [dbo].[templateType] (
		[pkId]
	)
GO
