0

我有一个表 MstAttributes 另一个作为 TrnIndexAttributes。我想在 TrnIndexAttributes 表中创建这么多列,因为 MstAttributes 中有很多行。意味着在 MstAttributesone 列中插入值后,应在 TrnIndexAttribute 表中创建 ID1、ID2、ID3 ....

4

1 回答 1

0

如果您真的想这样做(尽管 Philip Kelley 提出了正确的警告),您将不得不使用动态查询。

DECLARE @Query NVARCJAR(MAX) = N'ALTER TABLE TableOfInfiniteDoom ADD COLUMN' + [your logic for a name] + [your ligic for a type]
EXEC sp_executesql @Query

在您的 trugger 中(如果您处理多行 DML,请不要忘记循环)。

于 2013-05-03T14:18:57.190 回答