Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:12:02+00:00 2026-06-04T00:12:02+00:00

I have the following T-SQL: USE [MYDB] GO SET XACT_ABORT, NOCOUNT ON GO BEGIN

  • 0

I have the following T-SQL:

USE [MYDB]
GO
SET XACT_ABORT, NOCOUNT ON
GO
BEGIN TRANSACTION;
BEGIN TRY
        ALTER TABLE [dbo].[ContactRole] 
        DROP CONSTRAINT [FK_8bff7074914bc29885004c0a323] 
        GO
END TRY
BEGIN CATCH
    SELECT 
        ERROR_NUMBER() AS ErrorNumber ,ERROR_SEVERITY() AS ErrorSeverity
        ,ERROR_STATE() AS ErrorState ,ERROR_PROCEDURE() AS ErrorProcedure
        ,ERROR_LINE() AS ErrorLine ,ERROR_MESSAGE() AS ErrorMessage;

    IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION;
END CATCH

IF @@TRANCOUNT > 0
    COMMIT TRANSACTION;

Which gives me this error when parsed:

Msg 102, Level 15, State 1, Line 9
Incorrect syntax near ‘FK_8bff7074914bc29885004c0a323’.

When alone, or just within a transaction, there is no parse error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:12:04+00:00Added an answer on June 4, 2026 at 12:12 am

    Drop the GO after the ALTER TABLE ... DROP CONSTRAINT .. line

    ....
    BEGIN TRANSACTION;
    BEGIN TRY
        ALTER TABLE [dbo].[ContactRole] 
        DROP CONSTRAINT [FK_8bff7074914bc29885004c0a323] 
    
        COMMIT TRANSACTION;
    END TRY
    BEGIN CATCH
        SELECT 
            ERROR_NUMBER() AS ErrorNumber ,ERROR_SEVERITY() AS ErrorSeverity
            ,ERROR_STATE() AS ErrorState ,ERROR_PROCEDURE() AS ErrorProcedure
            ,ERROR_LINE() AS ErrorLine ,ERROR_MESSAGE() AS ErrorMessage;
    
        IF @@TRANCOUNT > 0
            ROLLBACK TRANSACTION;
    END CATCH
    

    GO is not a SQL keyword – it’s only understood by SQL Server Management Studio as a “batch separator”.

    Also: put your COMMIT TRANSACTION statement right after the ALTER TABLE command – after all, if something does go wrong – the code execution will jump into the catch block right away, so that line is only executed if everything went OK

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQL script: USE MyDatabase ALTER DATABASE MyDatabase SET SINGLE_USER WITH
I have the following SQL Server stored procedure : BEGIN TRAN CREATE TABLE #TempTable
I have the following links in a sql dump file(.sql). I need to use
I have the following SQL statement: USE ws_results_db_2011_09_11_09_06_24;SELECT table_name FROM INFORMATION_SCHEMA.Tables WHERE table_name like
I have the following SQL (SQL Server 2005) that I use to calculate the
I have the following sql table schema: procudtId productPrice Color ================================== 1 3 $
I have the the following SQL query Declare @tempcalctbl Table ( ItemId varchar(50), ItemLocation
I have the following SQL: UPDATE TableA SET first_name = 'AAA', last_name = 'BBB',
I have following query in sql server 2005 with a table select t1.id, CONVERT(VARCHAR,t1.dt,103)
I have the following SQL set @ID = '323232' select tt.ItemOrder, tt.DisplayVal, ActualDate =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.