In SQL Server 2008 R2 error occurred while start debugging, Error HRESULT E_FAIL has been returned from a call to a COM component. (mscorlib)

I am not sure if disabling firewall is enough. if the user has sysadmin permissions and still getting this error means client is not able to connect to server in debugging mode. check this TCP and UDP ports are correctly open.

SQL remote debugging configuration

EDIT:1

I am sure you must have also googled a lot and tried to find out about the error messages. What I have found so far is the Error in the OP you mentioned is misleading and from that error, we cannot tell what exactly is wrong or what to look next. But as you replied in the comments, after making changes to enable Remote Debugger; the mentioned error is more clear and I feel that proper permission is still an issue. Plenty of other suggestion you also might have tried so far, but if you haven’t done this, let's try one more time:

In one of the comments I mentioned you to try login using the windows user.

Now Keep the settings you already did for TCP ports, Firewall Exception, etc… explained in the above link. you have windows 2012 server where you installed DB server. and windows 8 Prof where you have DB client and you connecting through SSMS. Now I believe both machines are in the same domain. Let’s say domain XYZ. You must have windows login on server, let’s say it is “XYZ\HALI” using which you can login to the Windows Server. log in and make sure that login also exists in SQL SERVER with sysadmin permission. Because client machine is also in same domain make sure you have logged in into the client machine using same user “XYZ\HALI”. Now start SSMS and choose windows authentication instead of SQL SERVER authentication. Try to start Debugging T-SQL code now.

if client and server machines are not in the same domain then we have to register server name on client machine as Linked Server, impersonate the login/user as local and then try the debugging.

Edit:2

Login to SSMS using Windows Authentication


I encountered this problem after generating a SQL 2012 script and running it in a SQL 2008 R2 database.

After some research, I found out that my target SQL 2008 R2 was running on a 32-bit OS which supports a file of up to 2GB in size. So I saved the script as C:\myScript.sql and successfully executed it in a command prompt with these steps:

  1. Open a command prompt window.

  2. In the command prompt window, type:

    sqlcmd -S myServer\instanceName –U yourUserName –P yourPassword -i C:\myScript.sql
    

    where myServer\instanceName is the instance name. Supply the user name and password for SQL server login, and finally the path of the file as indicated.

  3. Press Enter.

References:

  • sqlcmd Utility | Microsoft Docs

  • Use the sqlcmd Utility | Microsoft Docs