0
當我按在SQL Server Management Studio中(SSMS)新建查詢,根據下面的圖片:如何在SSMS中每次按「新查詢」時加載腳本?
我想在一個新的選項卡下面的腳本。 會這樣嗎?
USE AdventureWorks2012;
GO
-- SET XACT_ABORT ON will render the transaction uncommittable
-- when the constraint violation occurs.
SET XACT_ABORT ON;
BEGIN TRY
BEGIN TRANSACTION;
------------------------------------------------------
------------------------------------------------------
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
-- Test XACT_STATE for 0, 1, or -1.
-- If 1, the transaction is committable.
-- If -1, the transaction is uncommittable and should
-- be rolled back.
-- XACT_STATE = 0 means there is no transaction and
-- a commit or rollback operation would generate an error.
-- Test whether the transaction is uncommittable.
IF (XACT_STATE()) = -1
BEGIN
PRINT 'The transaction is in an uncommittable state.' +
' Rolling back transaction.'
ROLLBACK TRANSACTION;
END;
-- Test whether the transaction is active and valid.
IF (XACT_STATE()) = 1
BEGIN
PRINT 'The transaction is committable.' +
' Committing transaction.'
COMMIT TRANSACTION;
END;
END CATCH;
GO
在下面的鏈接上有一個非常類似的問題,但它不適用於我。 SSMS 2014
MSSQL Server Management Studio (SSMS) 2005 New Query Template
你確定該文件已保存?它可能受到保護。它爲我通過修改此文件(對於SSMS2014):C:\ Program Files文件(x86)\ Microsoft SQL Server \ 120 \ Tools \ Binn \ ManagementStudio \ SqlWorkbenchProjectItems \ Sql \ SQLFile.sql –
@PeterHenell斑點上它工作!問題是我將它保存在C:\ Program Files而不是C:\ Program Files(x86) –
我將把問題留作參考。 –