alter PROCEDURE [dbo].[spsite]
@fromdate datetime,
@todate datetime
AS
BEGIN
select site as sitecode,
count(id) as t from an where mydate >=@fromdate and mydate<=@todate,
count(id) as p from an where p=1 and mydatestage1 >=@fromdate and mydatestage1<=@todate
i have one query: SELECT MAX(salesid) AS salesid, max(salestitle) as salestitle FROM saleshistory s where list = 'sales' GROUP BY DATEADD(dd, DATEDIFF(dd, 0, salesdate), 0) order by salestitle
i m getting more than 1000 rows.. in output some of them are :
when i m doing like: SELECT MAX(salesid) AS salesid, max(salestitle) as salestitle FROM saleshistory s where list = 'sales' GROUP BY substring([salestitle],1,charindex(' ',[salestitle])-1)
i m getting an error Msg 536, Level 16, State 3, Line 1 Invalid length parameter passed to the substring function.
Table Structrue: Table Name : Custom_Table_SPPR_Master Fields : Sno int pk SPPR_No int pk Revison_No int pk rev_Date date prop_amt decimal claim_amt decimal avail_amt decimal Status int
I want the record where max of the revision no is seen for each sppr that is the result should the rows of sno: 4,6,8,9
i tried the following but in vein
select max(revision_no) ,sppr_no from Custom_Table_SPPR_Master group by sppr_no -- in this i am getting records, but i want * datas
select distinct(sppr_no) from Custom_Table_SPPR_Master where revision_no in(select max(revision_no) from Custom_Table_SPPR_Master group by revision_no) group by sppr_no
select sppr_no,count(revision_no) from Custom_Table_SPPR_Master where revision_no in(select max(revision_no) from Custom_Table_SPPR_Master group by revision_no) group by sppr_no,revision_no
SELECT TOP 10 COUNT(*) AS ItemsSold, ProductName, order_details_product_id, SUM(order_details_price) AS order_details_price FROM tbl_Detail_Order_Product WHERE (OrderStatus NOT IN (14, 15)) GROUP BY order_details_product_id, ProductName, order_details_price ORDER BY ItemsSold DESC
which works fine and have these results: Purchased Returned Sold Part Number $ 598.29 37 16684 $ 200.29 33 16654 $ 300.29 25 16184 . . . my problem is I want to show the returned column wich is:
WHERE (OrderStatus IN (14, 15)) I dont know how can I do that. I tried to write another query but it didnt worked correctly. plz help me. thanks
Fred writes "How to retrieve rows for which sum of the qty field equals to a specified number - let's consider a basic table as with 3 fields : item (pk), qty, orderid (fk) : item qty orderid **** *** ******* itemA 1 ord-18/07/06 itemB 2 ord-01/01/05 itemC 2 ord-18/07/06 itemD 3 ord-18/07/06 itemE 1 ord-18/07/06
I want to know belong ord-18/07/06's items, which ones to pick up in order to reach a total qty of 5. Answer is itemC (2) + itemD (3). I tried with various combinations of SUM,MAX,HAVING.. Can't make it works. Help appreciated. Rgds."
Hi, I have a problem regarding this i have this statement where in i can count the number of data and display what category is that.... my problem is how can i sum itHere's the Statement
SELECT Count([PullOut].[SOType]) as Count, [SODescription].[SODescription] FROM PullOut INNER JOIN SODescription ON [PullOut].[SOType]=[SODescription].[SOType] WHERE PullOut.Area in ('Rizal','Cavite') GROUP BY [SODescription].[SODescription];
m.material_subtotal, m.cec_job_id,m.location FROM material m left outer join Other_Project op on m.project_id=op.other_proj_id left outer join Daily_Time_Entry dl on dl.project_id =op.other_proj_id inner join Employee_Mgmt emp on emp.emp_mgmt_id = dl.emp_mgmt_id inner join CEC_Job cec ON dl.cec_job_id = cec.cec_job_id where (dl.dt_date='3/14/2008'and m.material_date='3/14/2008') and (dl.project_type='Other Project' and m.project_type = 'Other Project') and (dl.cec_job_id=m.cec_job_id) and (dl.daily_type='Electrical') and (dl.project_id='18')
I'm trying to return an integer from the following table that returnsthe number of unique cities:tblEmployeesName CityJohn BostonFrank New YorkJim OmahaBetty New YorkThe answer should be 3.DECLARE @EmployeeCities intSELECT @EmployeeCities = SELECT ... ???How go I return one row/column into @EmployeeCities from a Count and aGroupBy?Headache already... Maybe it's too early...
I have a table (tblA) that records the RecordID, UserID andLastViewedDate (DateTime) of each record opened in tblB where RecordIDis the PK in tblB. I want to construct a query that groups all recordsin tblA by RecordID, filters by UserID and keeps only the most recent25 RecordIDs and deletes the rest.This gets me a recordset of all RecordIDs filtered by UserID in tblAbut I can't figure out how to sort it by LastViewedDate DESC and toeliminate those not in the Top25:SELECT RecordIDFROM dbo.tblAWHERE (UserID = 1234)GROUP BY RecordIDAny help is appreciated!lq
I have a data (txt) file which has the following structure
M_ID1: CID11,Date11 CID12,Date12
M_ID2: CID,Date21 CID,Date22
My problem now is it, to get that into a table (MID,CID,DATE) as the text file "groups" CID and DATE by MID and I have no idea how to read the file and transform it.
I have a query to get data group by High, Medium and Low so only three rows will be returned.
select sum(case .... ) then 1 else 0 end) as [Column1], sum(case .... ) then 1 else 0 end) as [Column2], sum(case .... ) then 1 else 0 end) as [Column3] from sometable Group by High, Medium, Low
I want to manually add High, Medium and Low to each row's first column. the final result should look like:
Column1 Column2 Column3 High 123 123 123 Medium 123 123 123 Low 123 123 123
(select count(*) from dto_initial_screening where (dto_initial_screening.facilityNo = ref_facility.facilityNo and dto_initial_screening.testDt between '2007-01-01' and '2008-01-01')) as 'TotalScreened',
(select count(*) from dto_initial_screening where (dto_initial_screening.testResult = 'POS' and dto_initial_screening.facilityNo = ref_facility.facilityNo and dto_initial_screening.testDt between '2007-01-01' and '2008-01-01')) as 'NoOfPositives'
from dto_initial_screening left join ref_facility on dto_initial_screening.facilityNo = ref_facility.facilityNo left join ref_region on ref_facility.adrRegionCd = ref_region.regionCd
where ('NoOfPositives') < (select Cast(paramVal as UNSIGNED) from ref_param where paramCd = 'minPositives')
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at HP.CUE.Video.PlaybackControl.UpdateProgressBar() at HP.CUE.Video.PlaybackControl._ProgressTimer_Tick(Object sender, EventArgs e) at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.Callback(IntPtr hWnd, Int32 msg, IntPtr idEvent, IntPtr dwTime)
************** JIT Debugging ************** To enable just in time (JIT) debugging, the config file for this application or machine (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled.
When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the machine rather than being handled by this dialog.
Hello guys! I am trying to debug a sql procedure inside Server Explorer but I can seem to step into each line. When I run the procedure it doesn't stop in the breakpoint I set.
How to test @au_lname's value sends to the following following sql command? Dim MyCommand As New SqlCommand("UPDATE [authors] SET [au_lname] = @au_lname", MyConnection)MyCommand.Parameters.Add(New SqlParameter("@au_lname", SqlDbType.NVarChar)).Value = me.au_lname.text I tried to print the "MyCommand.CommandText.ToString" but only get UPDATE [authors] SET [au_lname] = @au_lname with no value in the command text. Thanks!
Our SQL Servers is giving us a headache, after a certain period in time, either SQL Service automatically shuts down by itself or hangs. I've opened the logs and found hex dumps. Can you help me out with these?
I know there's a trick to this, that I can't figure out.
Have an SSIS package that I developed and deployed/saved(?) to a file on the SSIS server. Now I need to change the data flows. Did that, no issues, lets me resave the file, but I can't debug or execute the package so I can test what I did is right? Why is the debug drop down box greyed out? There's gotta be something I'm missing here.
Can someone help me with debugging store proc. I am usig VS 2003 and SQL Server 2005 and I have no clue as how to do that if it is possible. I would like to place a break point in my store proc if that is possible. I know if I was in VS 2005 it would be a charm but it's not my case. Thanks
hello,I want to know if it is possible to debug a stored procedure using visual studio 2003 and SQL server 2000.if yes can u help me how to do this?Thanks.
Say I have this query in my stored procedure. The problem I am facing is @OrgUID contains no value, so I put these 2 lines to debug. Am I using the right way to debug? I couldn't see the value of @OrgUID using this way. OrgUID is the PK in Organization. INSERT INTO Organization (OrgName) VALUES (@DealerName)SELECT @OrgUID = @@IDENTITYprint @OrgUIDreturn
Hi,I am using SQL Server Express bundled with Visual Studio 2008 on top of a ASP.NET/C# web application.I have written a stored procedure that appears to behave differently when stepping into the procedure than it does when called from my application, even though the parameter values are apparently identical. I need to debug the parameter values from within the stored procedure itself to see what the difference is. But how can I debug the stored procedure when it is called from the application?I followed the instructions at this page, but VS2008 does not stop within the procedure as expected. It seems I foolishly downloaded VS2008 Professional Edition, so these instructions apparently do not apply to that version (!!).So I thought I would try debugging the parameter values by writing them to a file. I used the procedure on this page to write to an arbitrary file, but every time I try to call it I get the following error: Error: SQL Server blocked access to procedure 'sys.sp_OACreate' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online. I opened the SQL Server Surface Area Configuration and enabled the "OLE Automation". I restarted the SQL Server service and VS2008, but I still got the same error, even though "OLE Automation" remains enabled for SQL Server 2005. So I tried issuing the following commands: sp_configure 'show advanced options', 1; GO RECONFIGURE;GOsp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE;GO But if I issue those commands from within a stored procedure, or even an SQL Query window, I get the following error:SQL Execution Error:Executed SQL Statement: sp_configure 'show advanced options', 1; GO RECONFIGURE;GOsp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE;GOError Source: .Net SqlClient Data ProviderError Message: Incorrect syntax near 'GO'.Please - I can't be the only person who is unable to debug his stored procedures. How can I either enable Application Debugging, or enable "OLE Automation"?I appreciate any help you can offer!
If I right-click on a stored procedure, I get the option to "step into stored procedure". However, no little yellow arrow appears that would show which line it's on. Debug/Continue is grayed out. Any ideas? NOTE: I tried to do this in SQL Query Analyzer. Same thing. Just seems like nothing is happening.