Heavily Fragmented Index - Incorrect Data Returned?
Dec 1, 2007
Hi everyone,
If I have a table with some indexes on the foriegn keys and these indexes are heavily fragmented (80%+), is it normal for queries to return incorrect results?
For example if I had a table called Customer( CustID, Name) and Orders (OrderID, CustID, Product, Date).
Lets say I have a non clustered index on CustID in Orders table, and the clustered indexes are Customer.CustID and Orders.OrderID
If the non clusterd index on Orders.CustID becomes heavily fragmented and I am querying the Orders table with TSQL "SELECT * FROM Orders where CustID = @CustID" I sometimes get missing data or incorrect results. In one case all orders for a particular year were missing, but if I queried using OderID they were returned. Rebuilding the index fixed the problem.
I know the index should be rebuilt or reorganized depending on the fragmentation but if one happened to become this fragmented should it start returning incorrect data?
- Using SQL Server Express 2005
View 3 Replies
ADVERTISEMENT
Apr 8, 2015
I just did index defragmentation for some databases include MSDB . I notice there are 3 indexes from MSDB database that fragmented quickly ( I did rebuild last nite at 10 PM - > fragmentation level becomes zero but today at 9 am it become 80 % ).The indexes are backupsetuuid, backup media family uuid, backupmediasetuuid. I am thinking to set the fill factor for those indexes = 80 respectively.
View 6 Replies
View Related
Dec 21, 2007
There are two tables Table_1:ProductID (Identity Increment) ProductDescription (nvarchar) Table_2:ProductID (int)I have a sql statement and it's like this. This SQL is probably incorrect - but hopefully gives you an idea of what I am trying to do: DECLARE @getTheNewProductID intINSERT INTO Table_1 (ProductDescription) VALUES ('SomeValue') ; SET @getTheNewProductID = SELECT SCOPE_IDENTITY() INSERT INTO Table_2 (ProductID) VALUES (@getTheNewProductID) What I need is: when inserting into Table_1 to get the Exact New Product Id from it that occurs from the identity increment - then insert that exact same product ID into table_2The problem is it is returning incorrect values on the scope identity. Such as values from two transaction ago.How do you do this? I did try using @@identity which may have stuffed things up?? Thanks for your help
View 1 Replies
View Related
Apr 21, 2008
Hi,I have a shopping cart and before each product is added to the cart it checks to see if the stock control is turned on if so then checks the quantity available.My problem is that when i run the query select [dbStatus] from InventoryControl where [ID]=1 to view the status it is returning the incorrect bit value for dbStatus.If "dbStatus" is 0 in the database it returns 0 which is correct, but if the "dbStatus" is 1 in the db it returns -1!! If i run the query in query analyser the correct values are returned. Any ideas???Thanks in Advance
View 2 Replies
View Related
Sep 26, 2006
I have an asp.net 1.1 website that uses sql server 2000 and vb.I have a bit of a dilema, when I run a stored procedure in a webpage it returns the wrong value, but if I run itin the query analyzer the correct value is returned. Dim orderHistory As nlb.OrdersDB = New nlb.OrdersDB
' Obtain Order ID from QueryString
Dim OrderID As Integer = CInt(Request.Params("ID"))
' Get the customer ID too
Dim myNewCustomerId As Integer = 0
myNewCustomerId = orderHistory.GetOrderCustomer(OrderID)
Public Function GetOrderCustomer(ByVal orderID As Integer) As Integer
' Create Instance of Connection and Command Object
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("nlbsp_OrdersCustomerID", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC
Dim parameterOrderID As New SqlParameter("@order_id", SqlDbType.Int, 4)
parameterOrderID.Value = orderID
myCommand.Parameters.Add(parameterOrderID)
Dim parameterOrderCustID As New SqlParameter("@customer_id", SqlDbType.Int, 4)
parameterOrderCustID.Value = ParameterDirection.Output
myCommand.Parameters.Add(parameterOrderCustID)
'Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
' Return the customer_id (obtained as out paramter of SPROC)
If parameterOrderCustID.Value <> 0 Then
Return CInt(parameterOrderCustID.Value)
Else
Return 0
End If
End Function
the stored procdure is
CREATE PROCEDURE [dbo].[nlbsp_OrdersCustomerID]
(
@order_id int,
@customer_id int OUTPUT
)
AS
/* Return the customer_id from the Orders. */
SELECT
@customer_id = customer_id
FROM
nlb_Orders
WHERE
order_id = @order_id
GO
I know a particular order_id returns a value of 1. But when I run it in the webpage it always comes back as 2. Any ideas would be appreciated ThanksPete
View 1 Replies
View Related
Mar 23, 2006
It's me again :)
So; if you read my earlier thread here (http://www.dbforums.com/showthread.php?t=1214353), you'll know that I'm trying to build stored procedures to deal with ticketing queries, and that it's all getting a bit complicated. I have, however, made a bit of progress and now have the following working:
CREATE PROCEDURE [dbo].[getAvailableTickets]
@eventId INT,
@standId INT,
@admissionDateId INT,
@concessionId INT,
@userId INT
AS
DECLARE @startyear DATETIME
DECLARE @endyear DATETIME
SELECT @startyear=CONVERT(datetime, '2006/01/01')
SELECT @endyear=CONVERT(datetime, '2006/12/31')
SELECT
[tblTickets].[id] AS ticketId,
[tblEvents].[id] AS eventId,
[tblStands].[id] AS standId,
[tblAdmissionDates].[id] AS admitDateId,
[tblEvents].[event_name],
[tblStands].[stand_name],
[tblTicketConcessions].[concession_name],
[tblMemberships].[membership_name],
[tblAdmissionDates].[admission_start_date],
[tblAdmissionDates].[admission_end_date],
[tblBookingMinQuantities]. AS minBookingQuantity,
[tblBookingMaxQuantities].[booking_quantity] AS maxBookingQuantity,
MIN([tblQuotas].[quota]) AS Quota,
[B]SUM([tblBasket].[ticket_quantity]) AS History,
[tblTickets].[price],
[tblTickets].[availability]
FROM [tblTickets]
LEFT JOIN [tblEvents]ON [tblEvents].[id] = [tblTickets].[event_id]
LEFT JOIN [tblStands]ON [tblStands].[id] = [tblTickets].[stand_id]
LEFT JOIN [tblBookingDates]ON [tblBookingDates].[id] = [tblTickets].
LEFT JOIN [tblTicketConcessions]ON [tblTicketConcessions].[id] = [tblTickets].[ticket_concession_id]
LEFT JOIN [tblBookingQuantities] AS tblBookingMinQuantities ON [tblBookingMinQuantities].[id] = [tblTickets].[booking_min_quantity_id]
LEFT JOIN [tblBookingQuantities] AS tblBookingMaxQuantitiesON [tblBookingMaxQuantities].[id] = [tblTickets].[booking_max_quantity_id]
LEFT JOIN [tblAdmissionDates]ON [tblAdmissionDates].[id] = [tblTickets].[admission_date_id]
LEFT JOIN [tblMemberships]ON [tblMemberships].[id] = [tblTickets].[membership_id]
LEFT JOIN [tblQuotas]ON
([tblQuotas].[event_id] = [tblTickets].[event_id] OR [tblQuotas].[event_id] IS NULL) AND
([tblQuotas].[stand_id] = [tblTickets].[stand_id] OR [tblQuotas].[stand_id] IS NULL) AND
([tblQuotas].[admission_date_id] = [tblTickets].[admission_date_id] OR [tblQuotas].[admission_date_id] IS NULL) AND
([tblQuotas].[concession_id] = [tblTickets].[ticket_concession_id] OR [tblQuotas].[concession_id] IS NULL) AND
([tblQuotas].[membership_id] = [tblTickets].[membership_id] OR [tblQuotas].[membership_id] IS NULL) AND
([tblQuotas].[ticket_id] = [tblTickets].[id] OR [tblQuotas].[ticket_id] IS NULL)
[B]LEFT JOIN [tblBasket] ON [tblBasket].[ticket_id] = [tblTickets].[id]
LEFT JOIN [tblOrders] ON [tblOrders].[id] = [tblBasket].[order_id]
WHERE 1=1
AND ([tblTickets].[ticket_open] = 1)
AND (([tblEvents].[id] = @eventId OR @eventId = 0)AND ([tblEvents].[event_open] = 1))
AND (([tblStands].[id] = @standId OR @standId = 0)AND ([tblStands].[stand_open] = 1))
AND (([tblAdmissionDates].[id] = @admissionDateId OR @admissionDateId = 0)AND ([tblAdmissionDates].[date_open] = 1))
AND ([tblTicketConcessions].[id] = @concessionId OR @concessionId = 0)
AND ((getdate() BETWEEN [tblBookingDates]. AND [tblBookingDates].[booking_end_date]) OR ([tblBookingDates].[booking_start_date] IS NULL AND [tblBookingDates].[booking_end_date] IS NULL))
AND (([tblMemberships].[id] IN (SELECT [membership_id] FROM [tblUsers_Memberships] WHERE [user_id]=@userId)) OR [tblMemberships].[id] IS NULL)
[B]AND ([tblOrders].[user_id] = @userId OR @userId=0)
GROUP BY
[tblTickets].[id],
[tblEvents].[id],
[tblStands].[id],
[tblAdmissionDates].[id],
[tblEvents].[event_name],
[tblStands].[stand_name],
[tblTicketConcessions].[concession_name],
[tblMemberships].[membership_name],
[tblAdmissionDates].[admission_start_date],
[tblAdmissionDates].[admission_end_date],
[tblBookingMinQuantities].[booking_quantity],
[tblBookingMaxQuantities].[booking_quantity],
[tblTickets].[price],
[tblTickets].[availability]
GO
Except... there's two problems with it. One is that it only returns tickets that you've already bought, the other is that it doens't work out correctly how many of those tickets you've bought in past orders.
This is what's in tblBasket:
idticket_idquantityorder_iddate
152321/03/2006
262321/03/2006
3144421/03/2006
4154421/03/2006
551421/03/2006
Both the orders in there are for the same user id: "1". All the tickets in there are tied to event "2".
When I run Exec dbo.getAvailableTickets 2,0,0,0,1, it tells me it's found 6 of ticket 5, 4 of ticket 6 and 12 of ticket 14. And I can't for the life of me figure out how it's calculating it. Any ideas?
And how do i get it to return all tickets regardless of whether you've bought them previously or not?
View 4 Replies
View Related
Jun 20, 2006
I have a strange problem. I have some code that executes a sql query. If I run the query in SQL server query analyzer, I get a set of data returned for me as expected. This is the query listed on lines 3 and 4. I just manually type it into query analyzer.
Yet when I run the same query in my code, the result set is slightly different because it is missing some data. I am confused as to what is going on here. Basically to examine the sql result set returned, I write it out to an XML file. (See line 16).
Why the data returned is different, I have no idea. Also writing it out to an XML file is the only way I can look at the data. Otherwise looking at it in the debugger is impossible, with the hundreds of tree nodes returned.
If someone is able to help me figure this out, I would appreciate it.
1. public DataSet GetMarketList(string region, string marketRegion)2. {3. string sql = @"SELECT a.RealEstMarket FROM MarketMap a, RegionMap b " + 4."WHERE a.RegionCode = b.RegionCode"; 5. DataSet dsMarketList = new DataSet();6. SqlConnection sqlConn = new SqlConnection(intranetConnStr); 7. SqlCommand cmd = new SqlCommand(sql,sqlConn);8. sqlConn.Open();9. SqlDataAdapter adapter = new SqlDataAdapter(cmd); 10. try11. {12. adapter.Fill(dsMarketList);
13. String bling = adapter.SelectCommand.CommandText;//BRG 14. dsMarketList.DataSetName="RegionMarket"; 15. dsMarketList.Tables[0].TableName = "MarketList"; 16. dsMarketList.WriteXml(Server.MapPath ("myXMLFile.xml" )); // The data written to 17. myXMLFile.xml is not the same data that is returned when I run the query on line 3&4 18. // from the SQL query 19. } 20. catch(Exception e) 21. { 22. // Handle the exception (Code not shown)
View 2 Replies
View Related
Nov 26, 2007
Hi All,I have one question about many "or" operation make system chooseincorrect indexThere is one table TT (C1 VARCHAR(15) NOT NULL,C2 VARCHAR(15) NOT NULL,C3 VARCHAR(15) NOT NULL,C4 VARCHAR(15) NOT NULLC5 VARCHAR2(200),)Primary Key TT_PK (C1, C2, C3, C4)SELECT C1, C2, C3, C4 FROM TT WHERE C1 = 'TEST' AND ((C2 ='07RES' AND C3 = '00000' AND C4 = '02383') OR (C2 = '07RES' ANDC3 = '00000' AND C4 = '02382') OR (C2 = '07RES' AND C3 = '00000'AND C4 = '02381') OR (C2 = '07RES' AND C3 = '00000' AND C4 ='02380') OR (C2 = '07RES' AND C3 = '00000' AND C4 = '02379') OR(C2 = '07RES' AND C3 = '00000' AND C4 = '02378') OR (C2 = '07RES'AND C3 = '00000' AND C4 = '02377') OR (C2 = '07RES' AND C3 ='00000' AND C4 = '02376') OR (C2 = '07RES' AND C3 = '00000' ANDC4 = '02375') OR (C2 = '07RES' AND C3 = '00000' AND C4 ='02374') OR (C2 = '07RES' AND C3 = '00000' AND C4 = '02373') OR(C2 = '07RES' AND C3 = '00000' AND C4 = '02372').... about 100 or operationsOR (C2 = '07COM' AND C3 = '00000' AND C4 = '00618') OR (C2 ='07COM' AND C3 = '00000' AND C4 = '00617') OR (C2 = '07COM' ANDC3 = '00000' AND C4 = '00616') OR (C2 = '07COM' AND C3 = '00000'AND C4 = '00608') )The system choose index prefix, and query all index leaf withC1='TEST'Prefix: [dbo].[TT].C1 = 'TEST'After I reduce the OR operators to 50, it use choosePrefix: [dbo].[TT].C1, [dbo].[TT].C2,[dbo].[TT].C3,[dbo].[TT].C4='TEST, '07RES', '00000', '02383'Then Merge Join, it is very quick,Can anyone help on this, do I have to reduce the OR operator to 50?Thanks in advance!
View 5 Replies
View Related
Feb 27, 2004
Hi,
I have a database and application that are running slowly at the moment. My investigations so far have led me to HD issues. After an analysis of the data drives (RAID 5 on 5x36Gb drives) it shows that they are 99% fragmented.
Can i run a defrag on this drive?
Will i have to stop the SQL services?
tia
fatherjack
View 4 Replies
View Related
Jul 23, 2005
kalpesh.s...@gmail.com Feb 1, 6:50 am show optionsNewsgroups: comp.databases.informixFrom: kalpesh.s...@gmail.com - Find messages by this authorDate: 1 Feb 2005 06:50:21 -0800Local: Tues, Feb 1 2005 6:50 amSubject: how do you know indexes have been fragmentedReply | Reply to Author | Forward | Print | Individual Message | Showoriginal | Remove | Report Abusei ran dbcc showcontig on my sql server db and it returned fo*llowingTable: 'Table1' (1621580815); index ID: 1, database ID: 7TABLE level scan performed.- Pages Scanned................................: 4982- Extents Scanned..............................: 628- Extent Switches..............................: 627- Avg. Pages per Extent........................: 7.9- Scan Density [Best Count:Actual Count].......: 99.20% [623*:628]- Logical Scan Fragmentation ..................: 0.00%- Extent Scan Fragmentation ...................: 99.52%- Avg. Bytes Free per Page.....................: 38.3- Avg. Page Density (full).....................: 99.53%Based on searching for info on index defrag it seems my Exte*nt ScanFragmentation percentage is not what it should be (0%) . Is *it trueandif yes how can you be sure that your indexes have been fragm*ented.If indexes are really fragmented what is the best way withou*treindexing(or is that the best way) to defrag the indexes.Thank you Kalpesh
View 3 Replies
View Related
May 26, 2008
Last week i found on my database that almost all indexes had more than 70% of fragmentation. I rebuilt the indexes to fix the "problem" but today i found out that in one particular table (one with little more than 1 million records") the indexes are again 99,80% fragmented.
Did I do somethin wrong? If you ask me if there are a lot of transactions running over that table, the answer is NO. There is one procces that could append (insert) between 500 and 1000 records but this happens just once a month.
View 3 Replies
View Related
Oct 1, 2007
Have a 1TB of heaped tables being used 24/7 and performance is degrading over time, and the vendors dynamic SQL won't include clustered indexes! (and they won't let me add them)
I can reorganise the heap with an ALTER TABLE statement, add a column,
clustered index, drop column etc. However this is intrusive and I would require an entire day to perform this piece-meal, and a blanket script for 2000+ tables would kill performance all together.
Would a back-up, then remove the 1TB DB followed by a restore placing the data back onto disk unfragmented. (with LS this would only require a 3 hour down-time window) In theory it should work?
View 4 Replies
View Related
Mar 7, 2005
Hi all,
i have a very general question about databases. What is the advantage and disadvantage of using a heavily indexed database?
The advantage i could think is that search operations will be fast. The disadvantage (according to me who is a newbie) is that the size of the database will increase.
My teacher however is not very happy with this answer and wants me to research more. Any help will be greatly appreciated.
Thanks
View 1 Replies
View Related
Jun 2, 2008
What are my options to find heavily accessed DBs on a server? I know I can do this by profiler and some counters. Is there any tool which gives me this information easily?
------------------------
I think, therefore I am - Rene Descartes
View 10 Replies
View Related
Feb 26, 2007
Hi, I'm rather new here, but I would like to add the question here
since this project encompasses a lot of areas of ASP.NET (Visual Studio
2005).
My project is about a site which is heavily based on Search Option. So
basically, users will just have to fill in the forms, click search and
it will search throughout the database. For
example...
The website is about a property listing. The database (based on SQL
Server, can be created right through the Visual Studio 2005) consists
of these attributes: ID, Property Name, Property Location, Property
Cost. The user may search based on Name, Location and Cost. For the
cost, there are two forms to fill: the lowest cost allowed and the
highest cost allowed.All
these are put on the Master Page (Located on the top). When the button
Search is clicked, it will display the records that match the forms
filled, in the main page located below the Master Page.If anyone can help me with this, I'll be very grateful. Thank you very much.
View 4 Replies
View Related
Feb 20, 2002
Scenario:
We run a multiple database environment, with two of the databases receiving most of the user activity. (both write and read). These databases are roughly 25gb each and receive roughly the same amount of activity. Currently both of the .mdf files sit on the same drive shelf. Their log files are located on a separate drive shelf.
Debate: We have an extra fiber channel shelf available for us to use. We are not having too many problems related to performance, but we are always seeking for different ways to increase application/server performance. The debate centers on what to do with the extra shelf. There are two different suggestions on how best to use the shelf. They are:
1)Separate the .mdf files for two most utilized databases. This would separate the databases and the I/O associated with each across two different shelves
2)Break off the indexes for all 5 databases on to the extra shelf. This would leave all the .mdf files on the same shelf, but it would move the I/O associated with the indexes to a different shelf.
Can anyone provide the pros and cons of either suggestion?
I would like to see arguements for either side.
Dave
View 2 Replies
View Related
Oct 11, 2007
This is my first post, so if i have not posted things in the best manner please lemme know how to be more informative,clear, so that i can learn.
So i have made a view with the following command
GO
/****** Object: View [dbo].[AppraisalView_C] Script Date: 10/11/2007 12:10:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[AppraisalView_C]
AS
SELECT a.Counter
,a.DateCreated
,a.DateModified
,a.UserCreated
,a.UserModified
,a.AppraisalDate_C
,a.TypeID_C
,a.Customer_C
,a.Employee_C
,b.Notes_C
,b.Value_C
,b.AppraisalLineItemID_C
,b.AppraisalID_C
FROM dbo.Appraisal_C AS a
INNER JOIN dbo.AppraisalLineItem_C AS b ON a.AppraisalID_C = b.AppraisalID_C
---------------------------------------------------------------------------------------
the program im working on creates the SQL call to read from this view and creates
the following query
SELECT A.[AppraisalDate_C], A.[AppraisalID_C], A.[AppraisalLineItemID_C], A.[Customer_C], A.[Employee_C], A.[Notes_C], A.[TypeID_C], A.[Value_C]
FROM AppraisalView_C A
WHERE [AppraisalView_C].[AppraisalID_C] = 'APP-000006'
but I end up getting the dreaded "Msg 4104, Level 16, State 1, Line 1 The multi-part identifier "AppraisalView_C.AppraisalID_C" could not be bound." error....
I cant change the Query that is called, but i can change the view, what is wrong?
View 4 Replies
View Related
Jul 20, 2005
I am working on a personal project and am drawing a complete blank(too much celebrating last night?) on the SQL term that is used toeliminate multiples of like data when it is returned from thedatabase.ie, instead of ....redblueredgreenit would return ...redbluegreenSorry for the trouble and thanks.
View 2 Replies
View Related
Jan 6, 2008
In the following procedure i write the results to a temp table called #temp1I now want to count the results of #temp1, if the count of #temp1 = 0
I want to insert 'No Records Found' into #temp.ERRORMSG else return what is in the table
any idea on how to do this?
ALTER PROC [dbo].[SPU_RPT_Savings_AnomalyDispatches] 40,'04/01/07|06/30/07'
@PropertyID varchar(4000),
@DropDown varchar(50)
AS
SELECT Client.CLIENT, Client.CLIENTID, ErrorEmailLog.ID, ErrorEmailLog.SITEID, ErrorEmailLog.PROPID, ErrorEmailLog.DISTINCTERRORS,
ErrorEmailLog.ERRORMSG, ErrorEmailLog.ERRORDATETIME, ErrorEmailLog.EMAILRECIPIENTS, Property.PROPERTY, Property.STREET,
Property.CITY, Property.STATE, Property.ZIP, Property.PHONE
INTO #TEMP1
FROM ErrorEmailLog INNER JOIN
Property ON ErrorEmailLog.PROPID = Property.PROPID INNER JOIN
Client ON Property.CLIENTID = Client.CLIENTID
WHERE (ErrorEmailLog.ERRORDATETIME BETWEEN SUBSTRING(CONVERT(VARCHAR(12), @DropDown), 0, 9)
View 3 Replies
View Related
Apr 27, 2007
Hi,
I have a very weird and frustrating problem at a customer. Since two months we are busy developing a report model, so users are able to create their own reports using the reportbuilder.
Suddenly the 1:n relations seem to be screwed! If I have a simple relation between entities, like a customer can have optional multiple invoices and a invoice has always one customer..
When in reportbuilder I select the customername, invoicenumber and #Invoices, then I expect there is only one invoice per invoicenumber. (When I select this in a query myself it is the truth...) But, the reportbuilder gives 2 as a result. This suddenly happens to all my 1:n roles.
It's not only in the #invoices fields, even when i select invoice amount this amount is being multiplied by 2.
I opened a backup of my project from one month ago, with the same relation in it and try to make the same report and it gave me the right results. But ofcourse I don't want to waste a month works, so I need to get this model working!
HELP!!!!
Thanks in advance
Julian
View 1 Replies
View Related
Jan 24, 2004
HI all.
I have a web service that does an SQL select against a database that contains international data, however when this is displayed from the web service the text such as "Rue Emile Féron 168" is not shown correctly and the 'é' is shown as a comma. Can someone advise what changes I need to make to the coding. Also our own tables have varchar fields and I'm assuming the "é" data will be saved correctly ???
Thanks
View 4 Replies
View Related
Mar 20, 2006
I have a subreport within the details section of my main report. This is enclosed by a single group. When I preview the subreport alone, it diplays the subreport correctly with no data (meaning it still displays the header and footer without a detail section). When the subreport is run within the main report and no subreport data is returned the subreport does not show.
Based on other threads I understand that the default functionality is to display headers and footers when no data is returned. This appears accurate except on a subreport.
View 4 Replies
View Related
Oct 4, 2006
In my SSIS package, I connect to an external SQL server database. This external database supports a stored procedure that I need to execute to "retrieve data". So in my package, I set the DataAccess Mode property of my OLEDB datasource to "SQL Command" and I provide the command EXEC <proc_name> <Param>,<output_param>. (The proc has an output parameter). The preview shows all the columns and data, but somehow no columns are returned....so when I try to link this data source to a copy column task, I get an error saying the source does not have any columns...any idea why this could be happening. Thanks - Manmeet
View 6 Replies
View Related
Feb 7, 2008
Hi All,
Is there a way to hide a column if there is no data for that column? Suppose that I have a SP (lets call it wrapper) which will call multiple SP's. But for any one run, there'll be only one SP which is called. But the columns returned by these SP's is obviously different. So, in order to accomodate the output, can I create a table, add all the possible columns to it, and set the properties of the individual columns such that they will be hidden if there is no data in them? Example, SP 1 returns - ServerName, Location, OS ; SP 2 returns ServerName and location only. Now if the wrapper SP calls only the second SP (SP 2) can I configure in such a way that the third column (OS) is not displayed at all? (In normal cases, it would appear but without any data in it)...
Hope the question is clear... Thanks a lot..
Manoj.
View 8 Replies
View Related
Apr 25, 2007
I am reposting this to a different forum, becasue I got not response...
Using VS05 SP1 Pro SQL Express€¦
Take a simple stored procedure like the following to return a specific column from a specific row in a data table ....
SELECT fld_IX_UserID
FROM UserIDs
WHERE (fld_UserID_Table_ID = @USERID_TABLE_ID)
It works fine in Store Procedure, and if you create at table adapter to reference it, that works fine as well.
Here is the issue. In the store procedure (i.e. under Server Explorer), when you execute the command to test it, it gives you the correct results. In Edit with Dataset Designer, Table Adapater, if you highlight it, right click preview data, it gives you incorrect results. In code, the table adapter gives you the correct resutls.
In every case, Preview Results for a table adapter built on a stored procedure will give you the wrong results. This is clearly a bug and can result in a log of wasted time.
Am I missing something? FYI, I realize I don't need to use the Table Adapater to execute the above stored procedure, but we are using table adapters for everything to be consistent.
Thanks,
Bob
View 3 Replies
View Related
Apr 23, 2007
How can i group the data returned by statement below by "Dept" field. I have already tried to group it like shown below but that doesn't seem to work for me. Any help.
cmd_select = New SqlCommand("SELECT Incident_id,Dept From Report_Incident Group By Dept,Incident_id", myconnection_string)
View 3 Replies
View Related
May 31, 2007
I need help in sorting data return from database. For example, I have the following data:ID field1 1 Computer 2 Cell Phone 3 iPod 4 Car I know that a select statement will look something like this: SELECT field1 FROM table ORDER BY field1. However, I want the data to be display this way in the gridview: ID field1
3 iPod
1 Computer
2 Cell Phone
4 Car Any idea of how I can make this happen. Any idea is appreciated.
View 11 Replies
View Related
Apr 3, 2014
I am working with extracting data from a SAP database, and I would like to perform some 'visual formatting' on the returned data. Because the SQL code that I am writing will be used in a custom Report it is not possible for me to use '3rd Party' formatting tools. Furthermore because the database is hosted on an MS SQL 2008 R2 RDBMS it is not possible to use the IIF() function.
Here is a sample of the data that I am getting back at the moment. URL...Here is how I would like the data to be returned (with the exception that the blue lines will ideally be blank cells). URL...
I have come to believe that I should be using the ROW_NUMBER() function, along with the OVER() function and possibly the 'partition by' keywords.Here is my original code -
Code:
select
td.ItemCode as 'Item Code'
, td.Dscription as 'Item Description', td.Quantity as 'Order Qty'
, titm.OnOrder as 'PO Qty'
, th.CardCode as 'BP Code', th.CardName as 'BP Name'
, th.DocNum as 'Sales Order Number'
, tsp.SlpName as 'Sales Person'
, twhs.WhsCode as 'Whs Code'
, isnull(tbloc.BINLABEL, '') as 'BIN Label', isnull(cast(tbloc.QUANTITY as nvarchar(20)), '') as 'BIN Qty'
code]...
Notice above that I only see the 'Seq' and no other data. How can I go about modifying this code so that I see all of the data columns I desire? If I further 'refine' the above, by adding case statements and the individual columns that I want to see (as opposed to using the * wildcard) I get a long list of error messages.
View 9 Replies
View Related
Oct 9, 2014
I need to return a single column (Name.company) but I want the data returned to be viewed in multiple columns.
First is that possible? Second if so how?
My data looks like this:
University X
University X - 1
University X - 2
University X - 3
College X
College X - 1
College X - 2
College X - 3
Cmty College X
Cmty College X - 1
Cmty College X - 2
etc.
How can I get it to return only:
University X
College X
Cmty College X
View 20 Replies
View Related
Oct 22, 2007
Hi,
I'm trying to use the XML Task XPath operation for the first time but having some problems. I'm using the following settings:
Source type: File connection
SaveOperationResult: True (file destination)
SecondOperandType: Direct Input
PutResultInOneNode: False
XPathOperation: Values
The XML file I'm testing has the following stucture:
<?xml version="1.0" standalone="yes"?>
<BackupDataSet xmlns="http://tempuri.org/BackupDataSet.xsd">
<Device>
<DeviceID>6356452a-e7a6-42e1-895a-d4ade62210d5</DeviceID>
<UserID>1533c44f-c263-db11-9db3-000e9bd9f98d</UserID>
</Device>
</BackupDataSet>
When I set the SecondOperand to /* the output is a concatenated text string of DeviceID and UserID values. I'm trying to get just the DeviceID but perhaps my understanding of XPath syntax is wrong. I've tried setting the SecondOperand to the following:
//Device/DeviceID
/BackupDataSet/Device/DeviceID
//DeviceID
All of these return no results. What am I doing wrong?
Regards,
Greg
View 3 Replies
View Related
Apr 12, 2006
i am writing a sproc that calls another sproc. this 2nd sproc returns 3 or 4 rows. i want to be able to insert these rows into a table. this sproc is inside a cursor, as i have to call it many times.
how do i insert the rows that it returns into another table??
View 10 Replies
View Related
May 24, 2001
I'm working with PivotTable on Excel 2000 which is connected to an OLAP server (from SQL Server 7 installation). The pivot is intended to analyze Sales during April 2001. Yesterday I found out that OLAP/Excel returned/displayed inconsistent data. The 'April Total' value is NOT equal to the 'Quarter 2 Total' (I already inspected the underlying database and sure that there is absolutely NO data for months after April 2001). The value for 'April Total' is the correct one. I'm not sure whether the problem resides on the OLAP Server or Excel (pivot) itself. For ones who like to help me I would be glad to supply you with the screenshots (just email me).
Please help.
Regards
Dave
View 1 Replies
View Related
Mar 11, 1999
Thanks for anybody that can help me with this.
When I double click on a database in the Enterprise Manager and the "Database Space Available" (in the Database tab) always shows 0.00 MB even though there is space available. This only happens to one of our database. The data device is 1.8GB and log device is 360MB and I've allocated all the space from device to database.
We're using SQL Server 6.5 sp3 in NT 4.0 sp3.
Anybody knows why is SQL Server reporting 0.00MB when you know there is space avaialble. I need to know the data space available and log space available so that I can expand it when the space runs low. Please help.
Thank you,
Jimmy Jen
View 3 Replies
View Related