Debugging Stored Procedure in SQL Server 2008

后端 未结 5 2001
有刺的猬
有刺的猬 2020-12-05 04:21

Is there any way to debug a stored procedure on SQL Server 2008?

I have access to use SQL Server Management Studio 2008 and Visual Studio 2008 (not sure whether eit

5条回答
  •  情书的邮戳
    2020-12-05 05:05

    • Yes, although it can be tricky to get debugging working, especially if trying to debug SQL on a remote SQL server from your own development machine.
    • In the first instance I'd recommend getting this working by debugging directly on the server first, if possible.
    • Log to the SQL server using an account that has sysadmin rights, or ask your DBA to to do this.
    • Then, for your own Windows account, create a 'login' in SQL Server, if it isn't already there:

    enter image description here

    • Right-click the account > properties - ensure that the login is a member of the 'sysadmin' role:

    enter image description here

    • (also ensure that the account is 'owner' of any databases that you want to debug scripts (e.g. stored procs) for:

    enter image description here

    • Then, login directly onto the SQL server using your Windows account.
    • Login to SQL server using Windows Authentication (using the account you've just used to log into the server)
    • Now 'Debug' the query in SQL management studio, setting breakpoints as necessary. You can step into stored procs using F11:

    enter image description here

    • Here's a useful guide to debugging:

    http://blogs.msdn.com/b/billramo/archive/2009/04/11/transact-sql-debugger-for-sql-server-2008-part-1.aspx

    • If you need to remotely debug, then once you've got this part working, you can try setting up remote debugging:

    http://blogs.msdn.com/b/billramo/archive/2009/04/11/transact-sql-debugger-for-sql-server-2008-part-2.aspx

提交回复
热议问题