Paging Query Bugs Out When Adding A Where Clause
Oct 10, 2007
I am getting incorrect results from my paging query, where the same results are being returned multiple times.
Here are two queries I have found to bring the same results:
select top 20 * from lookupdocuments_dbv where catname_cst='MyCategoryName' and (docid_cin not in (select top 620 docid_cin from lookupdocuments_dbv where catname_cst='MyCategoryName'))
select top 20 * from lookupdocuments_dbv where catname_cst='MyCategoryName' and (docid_cin not in (select top 640 docid_cin from lookupdocuments_dbv where catname_cst='MyCategoryName'))
When I remove the catname_cst where clause it brings back results properly (i.e. records 622-642 and 643-663).
What is wrong with my where clause that is causing identical data to be returned?
View 8 Replies
ADVERTISEMENT
Jun 5, 2008
I have the following query where I select records from Active_Activities_temp which do not match on cde_actv in the table ACTIVITY_CORE_LISTING:
SELECT Active_Activities_temp.*
FROM Active_Activities_temp LEFT JOIN
ACTIVITY_CORE_LISTING ON
Active_Activities_temp.cde_actv=ACTIVITY_CORE_LISTING.cde_actv
WHEREACTIVITY_CORE_LISTING.cde_actv is null
ORDER BY prtcpnt_id
So for example, if a participant has a cde_actv=38 (which doesn't exist in ACTIVITY_CORE_LISTING), that record would appear as the query is currently.
The issue is that participants can have multiple records in Active_Activities_temp and if a participant has a record that does exist in ACTIVITY_CORE_LISTING, no records for that participant should appear in this query result. For example, if a participant has two records in Active_Activities_temp, one with a cde_actv 38 (which does not appear in ACTIVITY_CORE_LISTING) and one with a cde_actv 33 (which does appear in ACTIVITY_CORE_LISTING), no records for that participant should appear in the result. Currently the record with cde_actv=38 does appear.
What code can I implement to do what I need to do? Thanks so much.
View 5 Replies
View Related
Feb 12, 2008
Hi Faculties,I have two queries which give me the same output.-- Query 1SELECT prod.name, cat.nameFROM products prod INNER JOIN categories catON prod.category_id = cat.idWHERE cat.id = 1;-- Query 2SELECT prod.name, cat.nameFROM products prod INNER JOIN categories catON prod.category_id = cat.id AND cat.id = 1;The first query uses the WHERE clause and the second one has all theconditions in the ON clause. Is there anthing wrong with the secondapproach in terms of performance? Please suggest.Thanks in advanceJackal
View 6 Replies
View Related
Aug 2, 2006
I have created a stored proc for paging on a datalist which uses a objectDataSource.
I have a output param itemCount which should return the total rows. Them I am creating a temp table to fetch the records for each page request. My output param works fine if I comment out all the other select statements. But returns null with them. Any help would be appreciated.
CREATE PROCEDURE [dbo].[CMRC_PRODUCTS_GetListByCategory]( @categoryID int, @pageIndex INT, @numRows INT, @itemCount INT OUTPUT )AS
SELECT @itemCount= COUNT(*) FROM CMRC_Products where CMRC_Products.CategoryID=@categoryID Declare @startRowIndex INT; Declare @finishRowIndex INT; set @startRowIndex = ((@pageIndex -1) * @numRows) + 1; set @finishRowIndex = @pageIndex * @numRows
DECLARE @tCat TABLE (TID int identity(1,1),ProductID int, CategoryID int, SellerUserName varchar(100), ModelName varchar(100), Medium varchar(50),ProductImage varchar(100),UnitCost money,Description varchar(1500), CategoryName varchar(100), isActive bit,weight money)
INSERT INTO @tCat(ProductID, CategoryID,SellerUserName,ModelName,Medium,ProductImage,UnitCost,Description,CategoryName, isActive,weight)SELECT CMRC_Products.ProductID, CMRC_Products.CategoryID, CMRC_Products.SellerUserName, CMRC_Products.ModelName, CMRC_Products.Medium,CMRC_Products.ProductImage, CMRC_Products.UnitCost, CMRC_Products.Description, CMRC_Categories.CategoryName, CMRC_Products.isActive,CMRC_Products.weightFROM CMRC_Products INNER JOIN CMRC_Categories ON CMRC_Products.CategoryID = CMRC_Categories.CategoryIDWHERE (CMRC_Products.CategoryID = @categoryID) AND (CMRC_Products.isActive = 1)
SELECT ProductID, CategoryID,SellerUserName,ModelName,Medium,ProductImage,UnitCost,Description,CategoryName, isActive,weightFROM @tCat WHERE TID >= @startRowIndex AND TID <= @finishRowIndexGO
View 12 Replies
View Related
Apr 29, 2006
let's suppose that we have a table entitled "tab1" which has more than 1000 rows and about 10 columns
so in SQL 2000, if I do this query:
SELECT * FROM tab1
the result will be displaying all the rows from the begining.
and my teacher told me that there's a new option in SQL 2005 which is you can display the result of the query in a page mode.
so can anyone tell me how can I do so for this query:
SELECT * FROM tab1
so that I can see the results in pages.
thanks
View 7 Replies
View Related
May 31, 2006
hello, I have this project that I can't find it.
let's say we have more than 100 000 rows in a table called table 1, so if we do: SELECT * FROM TABLE1
the result will be dispalying all the rows with a large scrollbar.
But there's a new TSQL in SQL 2005 "ROW_COUNT" which will help to do the paging. so I have found the procedure but all I need now is to display NEXT and PREVIOUS button in the results in order to switch between the pages. So please any help, Thank you
View 1 Replies
View Related
Dec 1, 2006
Hello, my table is clustered according to the date. Has anyone found an efficient way to page through 16 million rows of data? The query that I have takes waaaay too long. It is really fast when I page through information at the beginning but when someone tries to access the 9,000th page sometimes it has a timeout error. I am using sql server 2005 let me know if you have any ideas. Thanks
I am also thinking about switch datavase software to something that can handle that many rows. Let me know if you have a suggestion on a particular software that can handle paging through 16 million rows of data.
View 1 Replies
View Related
May 23, 2007
Hi,I
am working on this select query for a report on website users. The
resulting rows will be displayed in a datagrid with custom paging. I
want to fetch 100 rows each time. This is the simplified query,
@currpage is passed as a parameter. ________________________________________________________________________________DECLARE @table TABLE (rowid INT IDENTITY(1,1), userid INT)INSERT INTO @table (userid) SELECT userid FROM UsersSELECT T.rowid, T.userid, ISNULL(O.userid, 0)FROM @table TLEFT OUTER JOIN ( SELECT DISTINCT(userid) FROM orders)AS OON O.userid = T.useridAND T.rowid > ((@currpage-1) * 100) AND T.rowid <= (@currpage * 100)ORDER BY T.rowid________________________________________________________________________________If
I run this query it returns all the rows, not just the 100 rows
corresponding to the @currpage value. What am I doing wrong? (The
second table with left outer join is there as I need one field to
indicate whether the user has placed an order with us or not. If the
value is 0, the user has not placed any orders) Thanks.
View 2 Replies
View Related
Aug 13, 2007
How do I write a query (using a union) suitable for paging
I currently have a query which results from two queries combined by a union. It returns 3000 rows. I want to replace that query with one which returns only 50 rows from the relevant page [using ROW_NUMBER()].
Is there a way to do this with only 1 CTE or will I need to use two consecutive CTEs [the first get a union on the queries and the second to apply ROW_NUMBER()]. I can't see a way of doing it with only 1 CTE table.
Alternatively is there a very efficient way to do it using derived tables?
View 1 Replies
View Related
Jul 26, 2007
Hi,
I want to write query to implement paging in sql server ce 3.0. But it seems it does not support TOP or LIMIT keyword.
Can someone suggest alternative way to write a custom paging query in sql server ce 3.0.
Thanks,
van_03
View 3 Replies
View Related
Jun 28, 2002
Message:
Hi,
Suppose i execute a query,
Select * from emp,
I get 100 rows of result, i want to write a sql query similar to the one available in MySql database where in i can specify the starting row and number of rows of records i want,
something like,
select * from emp LIMIT 10,20
I want all the records from the 10th row to the 20th row.
This would be helpful for me to do paging in the front end , where is i can navigate to the next previous buttons and fetch the corresponding records.
I want to do something like in google, previous next screens.
So I am trying to limit the number of rows fetched from a query.
somethin like,
select * from emp where startRowNum=10 and NoOfRecords = 20
so that i can get rows from 10 to 30.
Has any1 done this, plz let me know.
Cheers,
Prashant.
View 1 Replies
View Related
Jan 28, 2000
I just recently ran into the problem of a memory leak using xp_sendmail with certain parameters. After going online with microsoft I found out this is a known bug. Is there anywhere that they list all the bugs currently known for SQL 7 after applying SP1
View 1 Replies
View Related
Jun 16, 2006
[url=http://www.arcon5.com/modules.php?name=News&file=article&sid=280]excel bugs[/url]
hey guys,
i thought this arcle may be of interest to you all... with office suite being very popular and all that
View 2 Replies
View Related
Aug 17, 2007
Does anyone know if there is there a published list of outstanding SQL Server bugs? I keep coming across bugs and I would love to have link to where I can proactively review them.
View 4 Replies
View Related
Jun 27, 2007
I have a table contain a sub report . when I run on preview (visual studio), no problem . but when I run from my application , the report viewer just show "Report been generated" , never show the report .
after try and error I discover that when the query from main report return no records , plus the table contain a sub report , the problem occur only if you run it from your application using report viewer . not from visual studio . is this a bugs? anyway to resolve this or work around?
thks
View 1 Replies
View Related
Aug 13, 2007
Here is another one thats been bothering me for quite some time and I believe for user with regional and language settings to non-US English.
I have my regional settings set to Canadian English. I am using Calender controls to pick up Start, End dates in my report. When I pick a date from calender it automatically converts it behind the scenes to US English I believe. Therefore when I run the report, I get the result set, say from Oct 8 instead of Aug 10. Further, if I select the date as 13 Aug, the following error gets thrown (as a result that the SSRS is not able to identify 13 being any month of course)
"An error occured during local report processing. The value provided for the report parameter 'StartDate' is not valid for its type".
Is there a solution to this problem? The underlying date type is DateTime, so why should it matter which regional setting I use?
Comments anyone?
View 9 Replies
View Related
Jul 11, 2007
try copying a connection manager from one package to another
it does not work
e.g. excel connection manager
it loses the name of the connection manager and also the file you are pointing to
so it is basically no different to 'add new connection manager'
also
try copying the name of the connection manager to another connection
select connection, hit F2 (edit) ctrl C,
try pasting!
in order to paste you have to right click on the selected text and select copy from the context menu
this is not a bug
this sloppy, poorly tested software
View 1 Replies
View Related
Mar 20, 2008
I tried SQL mirroring in beta 1 , then it was gone, until SP1.
Now I can not setup mirror, it is fine if it is just hard to setup, but it seems it is full of bug! The mirroring has to be stable, since I am trying to mirror product db, what a diaster if something goes wrong.
I am trying two servers, both has 9.0.3042. First I tried to setup on my home machine, I VPN to my network, After I config security, I see two connection strings:
TCP://sql8.mydomain.netsql2005:5022
TCP://sql5.mydomain.netsql2005:5022
and I click start mirroring, then I got error - Alter failed due to invalid connection string. Hard to figure it out, right?
Then I tried the same thing on a server in the network, this time I get
TCP://sql8.mydomain.net:5022
TCP://sql5.mydomain.net:5022
and it doesn't show that error anymore, I am not sure why the connection should be like the latter format, but in anyway, how come SMO can not make it right?
then I get another error, SQL server doesn't exist or can not access, I search on the Internet, it seems that error could mean anything, include that the mirror db is not in restore mode.
But I did set the mirror db in restore mode and both sql5 and sql8 are under same domain, pysically close.
So what else I can check?
Any suggestion?
thanks
View 5 Replies
View Related
Apr 6, 2006
There are four limitations or apparent bugs I have experienced in 2005MS. Two I know are for real.Two real limitations/bugs --1. Can't edit table-valued function.2. Can't get nulls to be missing (blank) in text output paneTwo more I just encountered, and am wondering about --3. DB->All Tasks->Import Data->Load CSV file (exported from Excel) ->garbled table as some rows end up being extra columns. The samespreadsheets load okay from XLS format.Table should have shape A, instead has shape B:A B|...| |...||...| |...||...| |......||...| |......||...| |...||...||...|4. SET NOCOUNT OFF has no effect after SET NOCOUNT ONIs there a way to work around these, or are they real bugs?
View 4 Replies
View Related
Dec 21, 2006
Where can a person go to report SSRS 2005 bugs? I didn't see any area for error reporting.
These are the few bugs I've recorded, but I've seen so much more :(
On 2005sp1, and mainly using ssas 2005 for source data:
When you have an existing report parameter that was created by the graphical query designer area for dataset1, and then you go to make another dataset and add the same hierarchy and choose for it to be a parameter, it will overwrite what parameter settings you just had (ie, not multivalue and a special default value I desired).
When adding subsequent series or category fields to a chart, the default series/category grouping name remains the same and causes a error when attempting to run the report. IE: chart2_CategoryGroup1, chart2_CategoryGroup1, chart2_CategoryGroup1 - all names are the same for all of the 3 groupings that I've added.
View 3 Replies
View Related
Dec 8, 2006
I was creating an SSIS package, seemingly simple. One of the tasks I needed to do involved copying our production database to a seperate DB instance for staging. I wanted an SSIS package that would stage production so we could push and test changes.
My first problem is that I tried to create a simple Transfer Database task. When I tried to run the task, I got an error stating that our Stored Procedure, DtsRun, could not be scripted. It's an encrypted stored procedure.
A little annoyed, I decided that I'd do a transfer SQL objects instead. Now I don't want to hard-code my objects to xfer based on the current schema and edit this SSIS script every time we make a DB change; I just want it to copy ALL objects except for my encrypted proc. I'll just build a list with with another task.
I decided that I'll write a script that generates a list of proc names, and I'll pass that to the Copy SQL Server Objects task. Well apparantly I can't assign a collection value with a script. I have to create ANOTHER package that modifies THIS package because (1) The entire package isn't exposed to the script task and (2) object variables can't be used in expressions.
Am I missing something? So because I use a single encrypted stored procedure, I have to write 2 fairly complex packages to copy my database? That's just stupid. I can understand if SQL can't move the encrypted package while the database is online. I could deal with that. But the extremes I have to go to JUST to copy my database are truly rediculous.
I was really excited about SSIS, but I've been really dissapointed. The performance of the designer on my machine is really poor (I have a Core T2700 with 2GB RAM). Just about every error message I've gotten, both design-time and run-time, I've had to google because they're so obscure. And if you can only store blittable types and strings in variables, that severely limits the functionality of a package (without going to programmatic extremes).
Most of all, I'm really dissapointed in the expression system, If the CLR is loaded into the SSQL/SSIS runtime, then why am I coding it using ANOTHER proprietary coding syntax???? I thought .NET was meant to keep people from having to redesign the wheel???
Microsoft is constantly pushing C#, yet I can only script in VB.NET, which means I now have code-bases in different languages.
Overall, I'm really dissapointed with SSIS. The usefulness of the added functionality in SSIS packages is shrowded by the massive list of nuances.
View 8 Replies
View Related
Feb 21, 2007
Hello guys,
We have customers that are using web synchronization. Could you, please tell us when service pack for the bugs, discussed in thread http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=689428&SiteID=1 will be reliazed?
What replication participants should apply the service pack in a configuration where Subscriber (MS SQL 2005 Express) gets synchronized with Publisher/Diustributor (MS SQL 2005 Standard)?
Thanks.
Alexander.
View 3 Replies
View Related
Jan 22, 2004
Hey!
Has anybody here had any issues with the MS03-031 security patch and SQL 2000 on Windows 2003?
We recently installed this patch on one of our test SQL 2000 machines, and the performance of queries running on this machine have gone up (gotten worse) by at least 10X.
We use indexed views and all queries are run with WITH(NOEXPAND) to force the indexed view to be used.
Anyway, after the patch was installed, the queries on the indexed view will ONLY use the clustered index, and not any of the other indexes, causing a Clustered Index Scan.
I removed the patch (well, re-installed SQL) patched it up to SP3a, and performance is back to normal.
Anybody experience anything similar?
Paul
View 4 Replies
View Related
Aug 5, 2014
I have the following code.
SELECT _bvSerialMasterFull.SerialNumber, _bvSerialMasterFull.SNStockLink, _bvSerialMasterFull.SNDateLMove, _bvSerialMasterFull.CurrentLoc,
_bvSerialMasterFull.CurrentAccLink, _bvSerialMasterFull.StockCode, _bvSerialMasterFull.CurrentAccount, _bvSerialMasterFull.CurrentLocationDesc,
_bvSerialNumbersFull.SNTxDate, _bvSerialNumbersFull.SNTxReference, _bvSerialNumbersFull.SNTrCodeID, _bvSerialNumbersFull.SNTransType,
_bvSerialNumbersFull.SNWarehouseID, _bvSerialNumbersFull.TransAccount, _bvSerialNumbersFull.TransTypeDesc,
[code]...
However, as you can see, the original select query is run twice and joined together.What I was hoping for is this to be done in the original query without the need to duplicate the original query.
View 2 Replies
View Related
Jul 30, 2015
For each customer, I want to add all of their telephone numbers to a different column. That is, multiple columns (depending on the number of telephone numbers) for each customer/row. How can I achieve that?
I want my output to be
CUSTOMER ID, FIRST NAME, LAST NAME, TEL1, TEL2, TEL3, ... etc
Each 'Tel' will relate to a one or more records in the PHONES table that is linked back to the customer.
I want to do it using SELECT. Is it possible?
View 13 Replies
View Related
Feb 6, 2008
HiI am new to SQL and am having a problem. I need to fix my query to do the following...2) get a total of the number of rows returned.
DECLARE @StartDate varchar(12)DECLARE @EndDate varchar(12)DECLARE @Region varchar(20)
SET @StartDate = '01/01/2002'SET @EndDate = '12/31/2008'SET @Region = 'Central'
SELECTA.createdon,A.casetypecodename,A.subjectidname,A.title,A.accountid,A.customerid,A.customeridname,B.new_Region,B.new_RegionName
FROM dbo.FilteredIncident AINNER JOIN dbo.FilteredAccount B ON A.customerid = B.accountid
WHERE (A.createdon >=@StartDate AND A.createdon <= @EndDate)AND (B.new_RegionName = @Region)AND (A.casetypecode = 2)
View 1 Replies
View Related
Jul 13, 2007
I am building a search application that has several fields in it - I want to be able to allow the user to put in specific search criteria or all them to say "All" and then pull back any records with anything in that row.
Example
Select *From mytableWHERE (SDate >= 1-1-2007) AND (EDate <= 1-25-2007) AND (Location = "ALL" or In ALL) this is where I am cloudy.. What/How would I write in the query to pull back everything, I know I could just leave the Location out of the query all together, but then that does not allow them to select just one the next time they run the application.
Thoughts?
Thanks,Ad.
View 4 Replies
View Related
Oct 14, 2005
Hi everyone, I am trying to run this query and it is not returning a single row. Although I can see one row with this 10/14/2005 date in the table.SELECT iSourceId, UserId,FROM tblEmployeeWHERE dtInsertDate >= '10/14/2005' and dtInsertDate <='10/14/2005'I also tried to rewrite the query this waySELECT iSourceId, UserId,FROM tblEmployeeWHERE dtInsertDate = '10/14/2005' but still it is not returning a single row.Please let me know what am I doing wrong.Thanks.
View 2 Replies
View Related
Aug 30, 2004
Question..
In a MSSQL SELECT Statement e.g
SELECT t1.fname, t1.lname, t2.district_name, t2.district_number FROM t1 AS table1, t2 AS table2 WHERE t2.district_name LIKE 'S%'
i have these values in the table
table1
fname lname
mike jackson
roy mires
table2
district_name district_number
South 123
Daggerty 7845
duffel 7224
rubble 7545
Now the query is dynamic (the letter is that the like clause is run against)
When the letter D is searched for i get the 2 colums duffel, daggerty BUT when S is searched against I get nothing..
I am confused as to why, It doesn't seem to be case sensitive, as the 2 colums duffel and Daggerty 1 is d is in lowercase and the other is in uppercase. andive tries both lowercase s and uppercase S and still got nothing.
Is tehre a better way to use the LIKE clause? Ive looked and looked for documentation about the LIKE clause but I cannot find anything
Am i doing something wrong?
any help would be greatly appreciated
View 1 Replies
View Related
Jun 17, 2004
Hi all,
In Oracle 'ROWNUM' can be used with any variables.
eg : select sno from test1 where rownum < variable1 ( say variable1 is a local variable )
Is there any equivalent for the above in SQL Server ?
Hint :
If 'select sno from test where rownum < 10' in Oracle, then SQL Server equivalent is 'select top 9 sno from test'.
The same way I need the equivalent for the above.
Thanks,
Sam
View 1 Replies
View Related
Mar 13, 2007
Hi folks,
How can I get all names that start with "sci" or "eng" without using the OR clause. In other words, how can I modify the following statement so I don't use the OR clause:
select * from course where (name like 'sci%' or name like 'eng%')
Can I use regular expressions to achieve that?
Thanks!
-Parul
View 14 Replies
View Related
Feb 1, 2007
Hi,
I am writing MDX query to retrive a set of data based on selected range of date.
I have written a MDX query but it is not filtering .
My code:
SELECT NON EMPTY { [Measures].[Fact Table Count] } ON COLUMNS, NON EMPTY topcount({ ([Date Time1].[Date Time1].[Date Time1].ALLMEMBERS ) } ,1000)DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Date Time1].[Date Time1].&[2006-01-25T05:53:07] : [Date Time1].[Date Time1].&[2006-02-25T15:53:56] ) ON COLUMNS FROM [Cube Analysis]) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
This code should display only data with selected range of date but it displaying all data.
Can any one give a solution to filter the data based on Date using WHERE clause.
Thank you.
View 2 Replies
View Related
Aug 25, 2007
I am trying to insert a value numeric + 1 in to db table but i get error when i do this
this is the code
Const SQL As String = "INSERT INTO [PageHits] ([DefaultPage]) VALUES (@defaultP)"Dim myCommand As New Data.SqlClient.SqlCommand(SQL, myConnection)myCommand.Parameters.AddWithValue("@DefaultP" + "1", DefaultP.Text.Trim())
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
The Error:
Must declare the variable '@defaultP'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Must declare the variable '@defaultP'.
View 1 Replies
View Related