Why would this query return an error that mentions an entirely different database being offline?

Trying to get a list of fragmented indexes based on a database name.  However, 
SELECT COUNT(*) AS TableFragOver80PctCount
FROM sys.dm_db_index_physical_stats (null, null, null, null, null )as ts
INNER JOIN sys.tables t on t.[object_id] = ts.[object_id]
INNER JOIN sys.indexes i on i.[object_id] = ts.[object_id]
INNER JOIN sys.databases db ON ts.database_id = db.database_id
WHERE db.name = 'MY DB NAME'
AND ts.avg_fragmentation_in_percent > 80.00
The error I get back 
Msg 942, Level 14, State 4, Line 1
Database 'VERY DIFFERENT DB' cannot be opened because it is offline.
I know there is a database on this server that is offline, actually 2 or 3, but not the one Im trying to get information about.  What could cause the above query to have trouble getting index info that is caused by an entirely different database being
offline?

FROM sys.dm_db_index_physical_stats (null, null, null, null, null )as ts
See MSDN sys.dm_db_index_physical_stats
;  the first parameter is the database id; if you pass NULL as here, then all databases will be scanned, also your offline one.
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • Why would this query return three rows?

        select pc.tour_id,
                                pcp.project_id,
                                pc.contr_num,
                                pc.current_contr_status,
                                pc.current_contr_substat
                         from p_contract_lead  pcl
                         left join   p_contract                  pc on pc.contr_num = '2385108'--pcl.contr_num
                         left join   p_contract_purchase         pcp on pcp.contr_num ='2385108'-- pc.contr_num
                         where pcl.lead_id = '179772978'
    in this query it returns me 3 rows,
    in p_contract there is only 1 row with contr_num = '2385108'
    and p_contract_purchase also has 1 row with contr_num = '2385108'
    in p_contract_lead the lead_id = '179772978' has 3 records but they dont have contr_num=2385108
    im just wondering why is giving me these results?
    shouldnt it give me zero results since the pcl.lead_id = '179772978' does not equal contr_num=2385108?
    i have version 12.0.0.6, maybe is the way i dont understand the left join works, or could be something else?
    sorry for not creating a example , because i really dont know how.
    thanks for your help

    Hi,
    FROM             l
    LEFT OUTER JOIN  r  ON ...
    means include all rows from l whether or not they have a match in r.
    If you have 3 rows in l, then there will always be at least 3 rows in the result set, regardless of what's in r (if anything).
    natpidgeon wrote:
    in p_contract there is only 1 row with contr_num = '2385108'
    and p_contract_purchase also has 1 row with contr_num = '2385108'
    in p_contract_lead the lead_id = '179772978' has 3 records but they dont have contr_num=2385108
    im just wondering why is giving me these results?
    shouldnt it give me zero results since the pcl.lead_id = '179772978' does not equal contr_num=2385108?  ...
    What you just described is basically how an inner join works.
    In this case, it doesn't matter in the least whether pcl.lead_id equals anything in pc or not.  The join condition between pcl and pc is
    pc.contr_num = '2385108'
    That is, a row from pcl will match a row in pc if (and only if) pc.contr_num='2385108'.  The join condition makes no mention of pcl.lead_id (or any other column in pcl, for that matter), so what's in pcl.lead_id (or any other column of pcl) doesn't play any role in deciding if rows match.
    sorry for not creating a example , because i really dont know how.
    Post CREATE TABLE statements for all 3 tables.  You only need to include the columns that are used in this query.
    Post 1 INSERT statement  for p_contract, with contr_num = '2385108'.  It wouldn't hurt to post an additional row that you know shouldn't appear in the results.
    Post 1 INSERT statement  for p_contract_purchase, also with contr_num = '2385108'.  Again, it wouldn't hurt to post a 2nd row that does not meet the join condition.
    Post 3 INSERT statements p_contract_lead with lead_id = '179772978' , but NOT contr_num='2385108'.  Again, having another row with a different lead_id would make a better example.

  • HT201263 My iPad 1 can only be updated to iOS 5 yet most apps run on iOS 7. Why can't I make the update on my iPad 1? Is this so I buy another iPad 2+? Now why would I want to buy something that will be obsolete in a few years?

    My iPad 1 can only be updated to iOS 5 yet most apps run on iOS 7. Why can't I make the update on my iPad 1? Is this so I buy another iPad 2+? Now why would I want to buy something that will be obsolete in a few years?  I really want to purchase an Live TV plan yet I need iOS 7 to run most TV apps.
    Can Apple tell me why my iPad 1 is obsolete?
    g

    It's not obsolete as much as the first gen simply lacks the power to run the newer operating systems. IT doesn't have enough RAM. If someone managed to hack it to get iOS 6 or 7 on there they'd just have a slow, boggy and unresponsive device. (think putting windows 7 on an old laptop.
    Unfortunately software moves faster than hardware. Every thing goes obsolete. I've had my ipad 2 for two and a half years now and I know it only has so much longer left to it too. Just the 'joys' of advancing technology.

  • I need that this query return only one value

    Hi, please. I need your help. I have this query:
    SELECT c.charvalue "Comentario", max(pi.id) as "id" --into :gcpe_last_comment
    FROM twflprocessinstances pi, twfliprocessparameters c
    WHERE pi.id = c.iprocess_id
    AND c.param_id = 1002286
    AND c.charvalue IS NOT NULL
    AND pi.processdef_id = 1600
    AND to_number(pi.id) <> 3817940
    AND to_number(pi.seeparameter1) =80137377
    group by c.charvalue
    having max(pi.id)
    This query return 3 rows, but I need that this query return only one row. The row that this query should return is the row before at the max id. Thanks

    Mmmm...I don't get it.
    You might need to post some sample data and expected results.

  • Why can't I download digital copies? Every single digial copy I attempt to download returns an error that the code is no longer valid.

    Why can't I download digital copies? Every time I attempt to download a movie, iTunes returns an error that the code is no longer valid. Thx.

    Hi,
    I have seen users reporting on the forum that there download is not working anf stucking up at 99% but when they try it out again say after a day or two then the issue gets resolved, I believe in the mean time the store team/web team fixed that issue. Did you tried it again? Any success?
    Regards,
    Ankush

  • Despite adding more storage = 20GB my devices tell me that I can not take any photos/video, why would this be?

    Despite adding more storage = 20GB my devices tell me that I can not take any photos/video, why would this be?

    Because the issue is that you don't have sufficient available space on your phone, not that you don't have enough space in your iCloud account.  Adding storage in iCloud does not give you more space on your phone.
    You can check your available space by going to Settings>General>Usage.  You'll need to delete or sync some data off your phone to freee up more space.

  • Why is this query not using the index?

    check out this query:-
    SELECT CUST_PO_NUMBER, HEADER_ID, ORDER_TYPE, PO_DATE
    FROM TABLE1
    WHERE STATUS = 'N'
    and here's the explain plan:-
    1     
    2     -------------------------------------------------------------------------------------
    3     | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    4     -------------------------------------------------------------------------------------
    5     | 0 | SELECT STATEMENT | | 2735K| 140M| 81036 (2)|
    6     |* 1 | TABLE ACCESS FULL| TABLE1 | 2735K| 140M| 81036 (2)|
    7     -------------------------------------------------------------------------------------
    8     
    9     Predicate Information (identified by operation id):
    10     ---------------------------------------------------
    11     
    12     1 - filter("STATUS"='N')
    There is already an index on this column, as is shown below:-
         INDEX_NAME INDEX_TYPE     UNIQUENESS     TABLE_NAME     COLUMN_NAME     COLUMN_POSITION
    1     TABLE1_IDX2 NORMAL     NONUNIQUE     TABLE1      STATUS     1
    2     TABLE1_IDX NORMAL     NONUNIQUE     TABLE1     HEADER_ID     1
    So why is this query not using the index on the 'STATUS' Column?
    I've already tried using optimizer hints and regathering the stats on the table, but the execution plan still remains the same, i.e. it still uses a FTS.
    I have tried this command also:-
    exec dbms_stats.gather_table_stats('GECS','GEPS_CS_SALES_ORDER_HEADER',method_opt=>'for all indexed columns size auto',cascade=>true,degree=>4);
    inspite of this, the query is still using a full table scan.
    The table has around 55 Lakh records, across 60 columns. And because of the FTS, the query is taking a long time to execute. How do i make it use the index?
    Please help.
    Edited by: user10047779 on Mar 16, 2010 6:55 AM

    If the cardinality is really as skewed as that, you may want to look at putting a histogram on the column (sounds like it would be in order, and that you don't have one).
    create table skewed_a_lot
    as
       select
          case when mod(level, 1000) = 0 then 'N' else 'Y' end as Flag,
          level as col1
       from dual connect by level <= 1000000;
    create index skewed_a_lot_i01 on skewed_a_lot (flag);
    exec dbms_stats.gather_table_stats(user, 'SKEWED_A_LOT', cascade => true, method_opt => 'for all indexed columns size auto');Is an example.

  • All my excel files were converted to pdf. Why would this happen and how do i stop it from doing so?

    All my excel files were converted to pdf. Why would this happen and how do i stop it from doing so?

    shloimypt wrote:
    All my excel files were converted to pdf. Why would this happen and how do i stop it from doing so?
    Relax, they weren't converted to PDF.
    You can tell by right clicking ANY of them and choosing "Properties". You'll see there that they're STILL .xls or .xlsx files. The "association" has changed and Windows now indicates that they open with Reader, which isn't right.
    Where it says "Open With" under the General tab, you can click "Change" and re-select Excel as the default app to open thim.
    See: http://helpx.adobe.com/acrobat/kb/application-file-icons-change-acrobat.html

  • When I attempt to sign up for the Samsung website using Firefox on my macbook, it returns an error that the random question answer is wrong

    I was attempting to create a user at this site:
    http://www.samsunggalaxys3forum.com/forum/register.php?do=addmember
    It asks a "random" questions "Floors are horizontal, walls are ___?" When I hit submit, it returns an error that the answer was wrong. I tried several times using my macbook running firefox.
    I get to work, where I am using an intel based machine running Windows 7, IE 9 and am able to register on the site and answer the question with no problem.
    I have had the same problem on sites that use captcha - I cannot get past inputting the captcha phrase, as it returns an error every time, while using IE9 is problem free.
    Is there something wrong with my setup of Firefox?

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • HT201317 My photos are syncing from my iPhone, to the iCloud PhotoStream and to our iPad, but it is no longer syncing to my computer (Microsoft, not Apple).   Why would this happen and how can I get it resolved?

    My photos are syncing from my iPhone to the iCloud PhotoStream and to our iPad, but they are no longer syncing to our home computer (Microsoft operating system, not Apple).   Why would this happen and how can I get it resolved?  I have since tried to remove and reinstall the iCloud application in my computer's control panel.  I have verified that I am using the latest Apple operating system and the latest iTunes.  I have reset my photo stream.  Not sure what else to try...   I was also having an issue with my calendar where it would sync from my computer to my iPhone but not vice versa.  Somehow in all the resetting that's resolved, but the photo issue is not.   Again - photos are going into the photostream, but not wirelessly being put into the file on my computer.

    To change the iCloud ID on your device you have to go to Settings>iCloud, tap Delete Account, provide the password to turn off Find My iPhone when prompted, then sign back in with the ID you wish to use.

  • Iphone 6 automatically turn on even not connect to charger, why would this happen and how to solve it?

    iphone 6 automatically turn on even not connect to charger, why would this happen and how to solve it?

    I'm not an apple expert or anything, but after hearing this from a coworker (and doing a quick google search) many of the generic chargers do not work in the 5s (especially after the most recent update.) I'm thinking this may be the problem in your case...the charger is not working so the phone just needs a good charge from either an apple certified charger or a generic that will actually work with the phone. I've read some people are able to pull the cable out, turn it around and then plug it back in facing the opposite direction to get it to work. Many have reported, however, that even when this remedies the cable issue, its still won't charge the phone while it is completely dead (which is likely the case since it won't power on at all.) So if you haven't fixed your problem by now, go buy a new charger and see what happens. You might be able to go into and apple store and borrow a charger there for a few minutes to see if this actually IS the problem. That way you don't waste your money before buying.

  • HT3275 My iMac harddrive only has about 100 gb of use on it. But my backup disk has over 300 gb used up on it. Why would this be?

    My iMac hard drive only has about 100 gb of use on it. But my backup disk has over 300 gb of usage on it. For instance, my iphoto library shows about 13 gb of photos but the backup disc shows almost 20 gb of photos in the iphoto library. Why would this be?

    Because you are using Time Machine which is an archiving backup utility. Any change that is made to a file will cause another fully copy of the file to be backed up. Over time a Time Machine backup will take up an entire hard drive no matter how large the drive may be.

  • I find that after updating my ipad to ios8 banking applications to deposit funds no longer work. The camera image rotates from horizontal to vertical and cannot be corrected. Is this a new ios8 error. I tried two different bank applications for ipad.

    I find that after updating my ipad to ios8 banking applications to deposit funds no longer work. The camera image rotates from horizontal to vertical and cannot be corrected. Is this a new ios8 error. I tried two different bank applications for ipad.

    Hi, Thanks for that further bug description In Your Last Message That Describes The Problem I Am Having perfectly and is exactly the same for me.
    unfortunately that fix for my camera Powershot G6 does not work or apply as the view pictures switch is different on G6 is not usable during download as once you plug in DC/USB cable it turns off, and makes no diff and problem still exists exactly as you just described.
    thanks anyways "Selz Boy"
    it has been 17 days since apple promised to get back to me within 3-5 days hopefully with a solution, but I have still not heard from them.
    They blew me off, i guess, probably i will have to wait for new Yosemite OS update, which they pre-warned me could take as much as 6 months.
    I cannot believe apple released this new update with such major bug issues for camera downloads and that horrible "Photos" pgm which has all sorts of downgrades in features, usefulness and new bugs compared to iPhotos which I just finally got used to and was much better software.
    I am starting to lose faith in Apple and I am getting that Microsoft "FEEL" like I used to have when I was a PC user, which was why I originally switched to Apple  computers in first place.
    Oh well got my fingers crossed here.
    Thankfully the memory card reader solution  is working well, but cost me $45.

  • Hi all, just downloaded a security update on my new iphone 4S.  The phone may be more secure but all the Aps icons have been downgraded in quality. Why would this be and how can I get smart looking aps back? Regards Steve

    Hi all, just downloaded a security update on my new iphone 4S.  The phone may be more secure but all the Aps icons have been downgraded in art quality why would this be.  Before the download the phone looked the business definitely high end quality now it looks like a second rate cheapo.  Please advise how to get the smart Aps icons back. Best regards SuttertonSteve

    Hi KiltedTim, as a newbie to Apple, iphones and forums I would appreciate an explanation of the 'Trolls and Mods' comments on your posting.  I presume the Mods are Apple sentinels but am I really a Troll just because I made a criticism of the new iOS version (even though I did not know I was actually doing that).  Am I a Troll to you because you personally disapprove of criticism of the new iOS or is Troll used by the community to describe anyone who speaks up if they are not happy about a change.  Please understand that by asking these questions it is not my intention to be confrontational (I’ve been called far worse than a Troll over the years) but as I’m new to the group an insight into the politics may be beneficial.  I’m an Old **** who isn’t technically gifted and may need the help of this group in the future so I don’t want to stand on anyone’s toes. Best regards Suttertonsteve.  

  • Info in tab I was using disappeared and was replaced by a list of files on my desktop showing whne I downloaded etc. Why would this happen?

    Information in tab I was using disappeared and was replaced with details of files on my desktop and when I downloaded/accessed them etc. Why would this happen?

    did you inadvertently drag a folder from your desktop into the firefox window?
    try that now for clarity sake

Maybe you are looking for