更新存储过程中的SQL表

时间:2016-02-12 01:15:27

标签: sql sql-server stored-procedures updating

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE [dbo].[myDB_UpdateThreadComments]
    @ID bigint, 
    @HasBeenChecked Char,
    @View Char
AS
    /***** Make the thread not view'able, but checked *****/
    UPDATE myDB_Posts
    SET [HasBeenChecked] = 'True',
        [View] = 'False'
    WHERE [ID] = @ID

    /***** Make the thread's comments all view'able, but checked *****/
    UPDATE myDB_Comments
    SET [HasBeenChecked] = 'True',
        [View] = 'True'
    WHERE [ID] = @ID

在存储过程中,我正在更新2个表。表一是论坛帖子。表二是线程的评论。两者的线程ID相同。我会遇到任何不可预见的错误,因为它们共享相同的ID吗?这2个表也共享2个类似的列。

代码有效,我即将开始使用它。只是想让别人看到它。

0 个答案:

没有答案