谁能告诉我是否有可能有一个有效的存储过程:
USE [dbname]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [Schema].[CreateColumn]
@Table varchar(255),
@ColumnName varchar(255)
AS
BEGIN
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
ALTER TABLE [Schema].@Table ADD @ColumnName varchar(255) NULL
ALTER TABLE [Schema].@Table SET (LOCK_ESCALATION = TABLE)
COMMIT
END
GO
基本上,我可以传入一个表名和列名,它会使用适当的事务在该表上创建它。