Link to home
Start Free TrialLog in
Avatar of BlearyEye
BlearyEyeFlag for United States of America

asked on

Debugging complex SQL query

I have a fairly complex INSERT INTO query in SQL Server 2008. The query fails on violation of a foreign key constraint. However, I have no insight into what exactly is happening.

I'm using Management Studio Express. Is there some way to debug this? Query Analyzer seems a likely tool but apparently is not included with the Express version.
Avatar of LCSandman8301
LCSandman8301
Flag of United States of America image

you can get the management studio download from here:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b

it looks a little different from Query analyzer in Sql 2000 but it is rather simple after you get used to it.
Avatar of DataField
DataField

Also, it sounds like you the table you are inserting into has a foriegn key constraint setup on it.
(Go to managment studio -> expand the table that you are trying to insert into under Constraints)
Make sure the value you are inserting is also included in the table that you have a contraint setup on
Avatar of BlearyEye

ASKER

LCSandman8301: I have Management Studio already; see below.


DataField:I know what the problem is--trying to insert a value in one table whose constraint is that it must exist in another table--but I don't know what the actual value is. I need some way to step thru the execution of the query and check the values being used; just like I would in a language debugger.

Microsoft SQL Server Management Studio						10.0.1600.22 ((SQL_PreRelease).080709-1414 )
Microsoft Data Access Components (MDAC)						6.0.6002.18005 (lh_sp2rtm.090410-1830)
Microsoft MSXML						3.0 4.0 5.0 6.0 
Microsoft Internet Explorer						8.0.6001.18999
Microsoft .NET Framework						2.0.50727.4206
Operating System						6.0.6002

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Altova  and other 3party tool has debugger.
So, other than buying a 3rd party debugger, the answer is "no, it can't be done". Right?
I've requested that this question be deleted for the following reason:

haven't received useful feedback  ...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
will reconsider cancellation ...
acperkins: this would have been simpler (and more pleasant) if you'd just answered my last post in May.
>>this would have been simpler (and more pleasant) if you'd just answered my last post in May. <<
What difference would it have made?  I had already explained that "is not how SQL Server operates" and you agreed with me.  What else could have been said?
I asked a question to make sure I understood the situation. You could have just said, "Yes, that's right".

Anyway, since we do seem to have an answer, I'll go ahead and assign points.