Showing posts with label explain. Show all posts
Showing posts with label explain. Show all posts

Monday, March 12, 2012

Help! Debugging Stored Procedure from query analyser - "Step through disabled"

Can anybody explain how to do debug a stored procedure from SQL Query Analyser.

When i tried opening Query Analyser and pressing F8 i am able to see Object Browser on left side, i selected the d/b and expanded it then i selected a stored procdure by right click of mouse. I selected "Debug".

It shows me alert msg "SQL Debugging may not work properly if you log on as 'Local System Account' while SQl server is configured to run as a service. You can open Event Viewer to see details." DO U WISH TO CONTINUE- I selected "YES"

I am able to see 3 split windows on right side and GO, Toggle, Untoggle are enabled BUT Step Into, Step Over, Step Out...Stop debugging are disabled at menu bar.

The 1st right split window shows the proc code, 2nd split window shows Local-Global-Callstack none of them shows any values(blank), 3rd split window shows records(result) and
@.RETURN_VALUE = 0 message

I had Toggled at each and every line of the procedure in 1st split window still it doesnt respond anything.

What might be the problem, how to solve it do i need to give any permissions.

i tried logging from wind Authentication and also from Sql Authentication (sa/sa), still same problem occurs. By the way i am using SQL Server 2000.

Pls help me out

Thanks in advance
Murali Kumar

I have exactly the same problem too. Please someone tell me what the problem is, tq.

Monday, February 27, 2012

Help!

Can anyone explain me what i am doing wrong:
I have a script that creates a linked server to them exec
a cmd through it.. when i do this through a cursor i get
this error:
MSDTC on server XPTO is unavailable (whcih is not true)
The operation could not be performed because the OLE DB
provider was unable to begin a ditributed transaction.
However if i do it seperatley.. without cursor.. it works..
Can anyone help me?
P.S
I posted a previous question asking about how to insert
sp_space used in a table.. however either way suggest
doesnt work.. any other suggestions?First of all choose an appropriate subject for your
posting. We all need help here but obviously some are
expert in one domain and others in a different domain.
Your subject does not help your cause.
Second what verison of Sql are you using? Can you post the
actual error message and text. There are a few bugs with
Linked servers and i suspect you are encoutering one.
>--Original Message--
>Can anyone explain me what i am doing wrong:
>I have a script that creates a linked server to them exec
>a cmd through it.. when i do this through a cursor i get
>this error:
>MSDTC on server XPTO is unavailable (whcih is not true)
>The operation could not be performed because the OLE DB
>provider was unable to begin a ditributed transaction.
>However if i do it seperatley.. without cursor.. it
works..
>Can anyone help me?
>P.S
>I posted a previous question asking about how to insert
>sp_space used in a table.. however either way suggest
>doesnt work.. any other suggestions?
>.
>

Friday, February 24, 2012

help withe SQL inner and outer joins.

Hello-

I am confused with inner and outer joins. Can someone explain to me exactly what the differences are? The reason I am asking is I am trying to populate a datagrid from multiple tables. The SQL query currently pulls out all customers that have revenue only, When in fact I need it to pull out all customers regardless of revenue so that I can see which customers have "0" revenue.

Here is my sql query which sorts each day into a new datagrid column.

SQL = "SELECT revenue_forecast.oct_03 AS 'forecast', pb_customers.customer_name AS 'customer', sum(case when day(pb_report_shippers.shipper_date_time) = 1 then pb_report_shippers.total_ext_price + pb_report_shippers.setup_cost else 0 end) as day1, sum(case when day(pb_report_shippers.shipper_date_time) = 2 then pb_report_shippers.total_ext_price + pb_report_shippers.setup_cost else 0 end) as day2, FROM pb_report_shippers Left outer JOIN pb_jobs ON pb_report_shippers.job_id = pb_jobs.job_id left outer JOIN pb_customers ON pb_jobs.customer_id = pb_customers.customer_id left outer JOIN revenue_forecast ON pb_customers.customer_id = revenue_forecast.customer_id WHERE pb_report_shippers.shipper_date_time between cast('11/01/03' as datetime) and cast('11/2/03' as datetime) AND pb_report_shippers.job_completed IN('1','0') AND pb_customers.customer_deleted <> '1' GROUP by pb_customers.customer_name, revenue_forecast.oct_03 Order BY pb_customers.customer_name"

Any help would be appreciated. ThanksFrom the BOL:
----
Joins can be categorized as:

Inner joins (the typical join operation, which uses some comparison operator like = or <>). These include equi-joins and natural joins.
Inner joins use a comparison operator to match rows from two tables based on the values in common columns from each table. For example, retrieving all rows where the student identification number is the same in both the students and courses tables.

Outer joins. Outer joins can be a left, a right, or full outer join.
Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:

LEFT JOIN or LEFT OUTER JOIN
The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.

RIGHT JOIN or RIGHT OUTER JOIN.
A right outer join is the reverse of a left outer join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table.

FULL JOIN or FULL OUTER JOIN.
A full outer join returns all rows in both the left and right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.

Cross joins.
Cross joins return all rows from the left table, each row from the left table is combined with all rows from the right table. Cross joins are also called Cartesian products.

----

So I would put the customers table first, then outer join the other tables.


SQL = "SELECT .... FROM pb_customers left outer join ..."
|||Eric-

Thanks for the explanation.

I tried placing the pb_customers table first as you suggested, but I still get a list of customers who have revenue.

Here is the from part of the SQL Query

FROM pb_customers left Outer Join revenue_forecast ON pb_customers.customer_id = revenue_forecast.customer_id Left Outer Join pb_jobs ON pb_jobs.customer_id = pb_customers.customer_id Left Outer Join pb_report_shippers ON pb_report_shippers.job_id = pb_jobs.job_id WHERE pb_report_shippers.shipper_date_time between cast('11/01/03' as datetime) and cast('11/4/03' as datetime) AND pb_report_shippers.job_completed IN('1','0') AND pb_customers.customer_deleted <> '1' GROUP by pb_customers.customer_name, revenue_forecast.oct_03 Order BY pb_customers.customer_name "

Any ideas?|||Make sure you get the outer join working by taking it in small steps. Just create a query with your first left outer join, make sure it returns what you want, continue adding tables. So start with pb_customers and revenue_forecast. Then add pb_report_shippers and so forth. Tell us what happens there.