Query rewrite complains about ragged hierarchy when it does not exist

Hi -
I have a customer dimension with only one level. The lowest level of detai.
When I enable the query rewrite I get an error (see below) about ragged or skipped level hierarchy in my customer dimension. I am trying to figure out what the issue is so I created a one level customer hierarchy (lowest level) and I still get the error.
I do not understand how I can have a skipped/ragged hierarchy when my dimension is at the lowest level.
I am using the lastest versions of AWM and 11G.
Thanks in advance for any help you can provide,
Frank
Invalid Metadata Objects:
Invalid Object "MYTEST.CUST_SALES": "XOQ-01957: The cube has REWRITE MVs and also contains either a ragged or skip-level hierarchy. The hierarchy is "MYTEST.CUST_DIM.STANDARD"."
Edited by: bmwrider on Oct 16, 2009 9:01 AM

Hi there,
See this:- Error when trying to enable cube  MV query rewrite
Thanks,
Stuart Bunby
OLAP Blog: http://oracleOLAP.blogspot.com
OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
OLAP on OTN: http://www.oracle.com/technology/products/bi/olap/index.html
DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

Similar Messages

  • Sender File adpter --don't raise alerts when file does not exist in folder

    Hi,
    My Scenario is File --- >XI ---> SAP.
    I must archieve the file after it got polled. and iam polling for every 60 mins, if the file does not exist,it is throwing an alert like "Could not process file '.file..xml: No such file or directory '
    Is there any way i can avoid raising an alert if file does not exist in the source folder.
    we are on XI 3.0 sp23?
    Thanks
    Srini

    Hello,
    Your Subject:
    >Sender File adpter --don't raise alerts when file does not exist in folder
    is contradictory to your question.
    >if the file does not exist,it is throwing an alert like "Could not process file '.file..xml: No such file or directory '
    > Is there any way i can avoid raising an alert if file does not exist in the source folder.
    I know you want to say "Don't Raise alerts when file does not exist in folder". Correct me if I am wrong.
    Some times it happens, when we write the right thing but it means something else and this is the reason many experts have replied, "how to raise an alert". So if you remove the word "Sender File adapter" from your subject then it will be easy to understand the exact meaning.
    Regards,
    Sarvesh

  • How to update zero to a column value when record does not exist in table but should display the column value when it exists in table?

    Hello Everyone,
    How to update zero to a column value when record does not exist in table  but should display the column value when it exists in table
    Regards
    Regards Gautam S

    As per my understanding...
    You Would like to see this 
    Code:
    SELECT COALESCE(Salary,0) from Employee;
    Regards
    Shivaprasad S
    Please mark as answer if helpful
    Shiv

  • Substitute nulls for blank when row does not exist??

    I am trying to put a query together to build a fixed width file. I am using rpad and using NVL to substitute for nulls. That seems to work fine until I have to do a multi table select. I run into a problem when the the id field in the customer table does not exist in the customer_addr table. The NVL works if the id exists and it does insert the blank for the null, but if the id is not there, then I get the null instead. How can I force the blank for the case where the row is not even in the second table without changing the data in the table?
    select
    rpad('MYDATABASE',20),
    rpad(id,20),
    to_char(updt_dttm,'yyyymmddHHMMSS'),
    rpad(fname,40),
    rpad(mname,35),
    rpad(lname,40),
    (select rpadNVL(a.addr1,' '),10) from customer_addr a where a.id = customer.id and a.addr_type = 100)
    from customer
    Thanks!

    Hi,
    Welcome to the forum!
    user1189388 wrote:
    I am trying to put a query together to build a fixed width file. I am using rpad and using NVL to substitute for nulls. That seems to work fine until I have to do a multi table select. I run into a problem when the the id field in the customer table does not exist in the customer_addr table. The NVL works if the id exists and it does insert the blank for the null, but if the id is not there, then I get the null instead. How can I force the blank for the case where the row is not even in the second table without changing the data in the table?
    select
    rpad('MYDATABASE',20),
    rpad(id,20),
    to_char(updt_dttm,'yyyymmddHHMMSS'),
    rpad(fname,40),
    rpad(mname,35),
    rpad(lname,40),
    (select rpadNVL(a.addr1,' '),10) from customer_addr a where a.id = customer.id and a.addr_type = 100)
    from customer
    Thanks!Sorry, I'm not sure I understand the problem.
    Is the problem with the last column in your SELECT clause?
    (select rpadNVL(a.addr1,' '),10) from customer_addr a where a.id = customer.id and a.addr_type = 100)It looks like you're missing a left-parentheses between RPAD and NVL. If you're getting anything other than an error message, this is probably not what you're running.
    At any rate, the scalar sub-query (the entire expression I quoted above) will be NULL if it doesn';t find any row. You need to apply RPAD and NVL to the results of the scalar sub-query, like this:
    RPAD ( NVL ( (      SELECT  a.addr1
              FROM     customer_addr     a
              WHERE     a.id          = customer_id
              AND     a.addr_type     = 100
         , 10
         )     I hope that answers your question.
    If not, please explain more clearly, and be specific about where the problem is.
    When you post output (or any formatted text) on this site, type these 6 characters:
    (all small letters, inside curly brackets) before and after each section of formatted test.  That's what I did above.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Why am I told Bing is already installed when it does not exist on my computer????????

    I removed Bing from my computer as I did not like it much. Since Google has now become such a useless piece of junk I decided to re-install Bing but each time I try I get the following message.
    Quiote:
    Firefox could not install the search plugin from "https://addons.mozilla.org/firefox/downloads/file/54407/bing-20090601.xml?src=category" because an engine with the same name already exists.
    This engine does no show up anywhere on my computer except for an XML file in Firefox/searchengines. I have deleted them but it makes no difference. The files do not show in Tools\addons nor in about:config. Please don't tell me that Firefox is become as useless as Google...............I don't want to have to use IE.

    Bing should be installed as one of the default search engines (bing.xml in the searchplugins folder in the Firefox program folder)
    If the file is there and you do not see it in Manage Search engines then click the "Restore Defaults" button to restore the default search engines.
    If that didn't help then delete the search.json file and a possible search.sqlite file in the Firefox Profile Folder.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox

  • How do I "Save target as ..." when it does not exist on right clicking in Firefox?

    Some web sites allow files and free mp3 tracks to be downloaded by right clicking on an icon and selecting "save target as ...". But Firefox does not have this option. How do others handle this? I have had to go back to Internet Explorer to use this privilege.
    == This happened ==
    Every time Firefox opened
    == Always been so for me.

    no it isn't........this option saves as an HTML document link. it does not download the file.

  • About ora-01006 :bind variable does not exist

    Hi all of you,i have this dynamic sql :
    DECLARE
    v_query clob;
    cpt number;
    begin
    v_query:='
    SELECT
    count(TBA.ANT_ID)
      FROM
    WHERE TBA.ANT_FUT_ID = TFT.FUT_ID
           AND TBA.ANT_KATEGORIE_CODE_ID = TAKCL.ANT_KATEGORIE_CODE_ID(+)
           AND TBA.ANT_KFZ_REIHEN_ID = TKR.KFZ_REIHEN_ID(+)
           AND TBA.ANT_ID = F1.ANT_ANT_ID(+)
           AND TBA.ANT_ID = F2.ANT_ANT_ID(+)
           AND TBA.ANT_ID = F3.ANT_ANT_ID(+)
           AND TBA.ANT_ID = ERS.ers_bdk(+)
           AND TBA.ANT_ID = F1_2.ANT_ANT_ID(+)
           AND TBA.ANT_ID = F2_3.ANT_ANT_ID(+)
           AND TBA.ANT_ID = MFU.MFU_ANT_ID(+)
           AND MFU.MFU_NIETGEOMETRIE_ID = NG.NG_ID(+)
           AND MFU.MFU_MATRIZEN_BEICHNUNG_ID = MZB.MZB_ID(+)
        -- Suchkriterien: --
        --Ersteller
        AND  DECODE( ERS.ers_id, NULL, ''%'', ERS.ers_name ) LIKE DECODE('':1'',NULL,''%'','''')||''''|| :1 ||''''||DECODE('':1'',NULL,''%'','''')
         --Fahrzeug
        AND  DECODE( TKR.NAME, NULL, ''%'', TKR.NAME ) LIKE DECODE('':2'',NULL,''%'','''')||''''|| :2 ||''''|| DECODE('':2'',NULL,''%'','''')
         --BDK
        AND  DECODE( fuege_db.bdk_nummer( TBA.ANT_ID,''.'' ), NULL, ''%%'',
       fuege_db.bdk_nummer( TBA.ANT_ID,''.'' ) )   LIKE ''%''||:3||''%''
        --Technologie
        AND  TBA.ANT_FUT_ID LIKE DECODE('':4'',NULL,''%'','''')||''''|| :4 ||''''||DECODE('':4'',NULL,''%'','''')
         --Art
        AND ((TBA.ANT_WFP_ID is null and 1=DECODE('':5'',NULL,1,1,1) ) or (TBA.ANT_WFP_ID is not null and 2=DECODE('':5'',NULL,2,2,2)))
        --VTA
        AND TBA.ANT_VTA = decode('':6'',1,1,TBA.ANT_VTA)  ';
    execute immediate v_query
    into cpt USING
    'Dominik Hussmann',
    'AU736_Q7_SUV' ,
    'WPS Stahl',
    '0';  
    end ;
    In the execution,i have this error :ora-01006 :bind variable does not exist, after analyzing,i have found that the problem is with parameters :5 and :6 ,i don't understand they have the same syntax
    as bind variables 1,2,3 and 4.
    Than you for any suggestion.

    I hope you do realise that there are 13 bind-variables in your sql, not 6?
    Variables are bound by position. You cannot use the same bind variable twice, they will be 2 distinct bind variables.
    For example, you use :1 three times, so you need to provide three arguments, in this case three times the same value.

  • Get performance when key does not exist

    Hello,
    I am using BDB version db-4.5.20. I try to get an object which is not present and the performance of this call is extremely slow. The newer versions have an exists call for the key. How can I get better performance in this case. I am using HASH as the underlining DB format.
    Do let me know if you need any more information.
    Thank you!

    Hi,
    If your keys present a locality of reference (accessing a particular key in the Btree is likely to be followed by an access of keys located "near" that key as per the defined sort order) then you'll probably be better of using Btree. Here is information on how to select the underlying access method:
    http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/select.html
    For the Hash access method there are several configuration options you can play with: the hash key comparison function (as of BDB 4.6), the hash function used to distribute keys, the hash database page fill factor and the estimated number of elements that will be stored in the database. Information on these can be found here:
    http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_set_h_compare.html
    http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_set_h_hash.html
    http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_set_h_ffactor.html
    http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_set_h_nelem.html
    http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/h_hash.html
    http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/h_ffactor.html
    http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/h_nelem.html
    Regards,
    Andrei

  • When I compose an email in either gmail or yahoo, the cursor lags behind for about 2 seconds. This does not happen when I compose an email with Safari or Chrome. I am using a Mac with Firefox version 3.6.3. Any idea why this happens?

    When I compose an email in either gmail or yahoo, the cursor lags behind for about 2 seconds. This does not happen when I compose an email with Safari or Chrome. I am using a Mac with Firefox version 3.6.3. Any idea why this happens?
    == This happened ==
    Every time Firefox opened

    try
    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!
    Thank you.

  • My Library Column does not exist when I execute a Caml Query

    Hello,
    I am new to SharePoint programming.  I am trying to understand how I can access the documents in a Library Folder and obtain the field values for each document in the container.  With this in mind I have pieced together the following code from
    various posts that demonstrate how to to this:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint.Client;
    namespace ConsoleListItemsInFolder
        class Program
            static void Main(string[] args)
                ClientContext ctx = new ClientContext("http://mwp_lenovo");
                List DocumentsList = ctx.Web.Lists.GetByTitle("Claims Documents");
                CamlQuery camlQuery = new CamlQuery();
                camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View Scope=\"RecursiveAll\"> " +
                                "<Query>" +
                                "<Where>" +
                                            "<Eq>" +
                                                "<FieldRef Name=\"FileDirRef\" />" +
                                                "<Value Type=\"Text\">/Claims Documents/11111111 Stuart Little</Value>"
    +
                                             "</Eq>" +
                                "</Where>" +
                                "</Query>" +
                                "</View>"; 
                ListItemCollection listItems = DocumentsList.GetItems(camlQuery);
                ctx.Load(
                    listItems,
                    items => items
                    .Include(
                        item => item["Title"],
                        item => item["Claim Number"],
                        item => item["Policy Number"],
                        item => item["Policyholder Name"],
                        item => item["Document Type"]));
                ctx.ExecuteQuery();
                foreach (ListItem listItem in listItems)
                    Console.WriteLine("Title: {0}", listItem["Title"]);
                    Console.WriteLine("Claim NUmber: {0}", listItem["Claim Number"]);
                    Console.ReadLine();
    When I execute the code with the debugger ctx.ExecuteQuery(); throws the following error:
    Microsoft.SharePoint.Client.ServerException was unhandled
      Message=Column 'Claim Number' does not exist. It may have been deleted by another user.  /Claims Documents
      Source=Microsoft.SharePoint.Client.Runtime
      ServerErrorCode=-2147024809
      ServerErrorTypeName=System.ArgumentException
      ServerStackTrace=""
      StackTrace:
           at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
           at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
           at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
           at ConsoleListItemsInFolder.Program.Main(String[] args) in c:\Users\matt.paisley\Documents\Visual Studio 2012\Projects\ConsoleListItemsInFolder\ConsoleListItemsInFolder\Program.cs:line 37
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
    These columns do exist in the Library as verified in Library Settings.  Many of the Library column names contain two words divided by a space.  Is this causing the problem?  Does SharePoint maintain a less offensive representation of the field
    name internally?  If so, how can I get it?
    If I run this code with only the title, then it runs fine.
    I Thank All in advance for any assistance that you can provided.
    Regards,
    Matt Paisley
    Matthew Paisley

    Hello
    In addition to Geetanjali Arora answer, change also those other columns
      item => item["Claim Number"],
      item => item["Policy Number"],
     item => item["Policyholder Name"],
     item => item["Document Type"]
    If you don't know the internal name of a column,
    go to the list containing the columns
    go to "list settings"
    scoll down to the "columns" section
    click on one of your columns et take a look a the url of the new page, you should found parameter "&Field=" => What is after is your field internal name (the one you should use in your CAML query)
    Best regards, Christopher.
    Blog |
    Mail
    Please remember to click "Mark As Answer" if a post solves your problem or
    "Vote As Helpful" if it was useful.
    Why mark as answer?

  • Dear community, what to do when iMovie does not automatically updates video from iPhoto. I've closed and reopen, restarted... still no good

    Dear community, what to do when iMovie does not automatically updates video from my iPhoto. Usually it will automatically generate new content, but now it's stuck 3 days behind the latest new iPhoto entries... I've restarted all programs, restarted the computer... what else?

    Ezy,
    I'm not sure what recourse you really have. My expectation would be that Apple is on the hook to warranty your computer, but they only warrant the machine you've got.
    The issue of exchange is fully in the hands of the dealer. If it were Apple, they would likely have had a longer return/exchange period (2 weeks is standard in the US, and I think they use the same timeframe internationally), and there have been some reports of people getting machines exchanged even if they were just outside the 2-week period.
    However, with Apple dealers, I think they are a little more concerned about old inventory. Who knows what Apple does when you give them back a last-gen Macbook. They probably sell it at a markdown, but even marked down, they still get a profit (most likely). When an authorized reseller gets stuck with an old machine, they probably have to sell it at a loss. Thus, I would expect resellers to be more afraid of holding onto discontinued models.
    That said, if they do a lot of business, they should appreciate the value of customer loyalty: it's usually better to lose money on one purchase than lose a customer (and all their future purchases). If you're a regular customer there, you could point out that disappointment could cause you to go to a competitor. That's playing a bit of hardball though.
    However, there is maybe an upshot to all of this... The new 13" model did not get the quad-core CPU's.. And it lost its dedicated graphics adapter. I've seen a decent number of people complaining that the new 13" model is worse than the previous one (the one I'm assuming you've gotten). So it might not be such a bad thing after all.

  • Asking the Bridge Team:  Bridge "working color space" setting when one does not have the Suite?

    Common sense tells me there is really no such thing as a
    "working color space" in Bridge, because
    Bridge is not an image editor, just a browser
    Therefore, this may turn out to be a purely academic question; but that doesn't keep my curiosity from forcing me to ask it anyway. ;)
    Is there a way to set the Bridge
    "color settings" when one does not have the suite?
    The only Adobe program I keep up to date is Photoshop, so I've never had the suite. My version of Photoshop is 11 (CS4) and I run updated
    (not upgraded) versions of Adobe Acrobat 7.x, Illustrator 10.x and InDesign 2.x. Consequently, the Synchronize color settings command is not available to me.
    It seems to me that Bridge is behaving like a proper color-managed browser (e.g. Firefox with color management enabled), in that it displays tagged image files correctly and assumes sRGB for untagged image files. This normally works fine.
    But what if I wanted Bridge to assume my
    Photoshop color working space for untagged images
    so that it behaves the same as Photoshop? I'm just curious, as I deal with a minuscule, practically negligible amount of untagged files.
    My reason for bringing it up now is that I don't recall this being explicitly mentioned in forum replies when users inquire about color settings in Bridge. A recent post regarding Version Cue in the Photoshop Macintosh forum got me thinking about this. Just wanting to make sure that I'm right in my assumption that
    there is really no such thing as a
    "working color space" in Bridge, because Bridge is not an image editor, just a browser.
    Thanks in advance.

    Hi Ramón,
    Thanks for sharing the outcome of your tests. However, I may have found a bug/exception to Bridge's colour management policy!
    It appears that CMYK EPS photoshop files are not colour managed in Adobe Bridge, even if they contain an embedded ICC profile.
    I've tried every combination in the EPS 'Save As' dialogue box, so it doesn't seem to be an issue with file encoding. Also, Bridge doesn't rely on the low-res preview that is held within the EPS itself.
    My guess is that Bridge is previewing the CMYK EPS with a Bridge-generated RGB image, but it's being displayed as monitor RGB (assigned) rather than colour managed (converted to monitor RGB). For most users the difference will be barely perceptible, but the problem became very noticeable when using Bridge to preview Newsprint CMYK images on a wide-gamut monitor (images that should have appeared muted really leapt off the screen!).
    How do I report this to the Colour Police at Adobe?!?

  • Table or view does not exist when using in PL/SQL block

    I hav something strange...
    When i execute a query it works just fine... When i use the exact same query in a function i want to create, i get the error 'table or view does not exist'
    I create the function with the same user then when i'm executing the query.
    For example:
    select name,userid from portal.WWLOG_ACTIVITY_LOGS
    if i execute this... it works fine. I get my results.
    However when i create a function:
    CREATE OR REPLACE FUNCTION EBUSINESS.GET_USER_CREATOR (p_userid IN Varchar2) return VARCHAR2
    as
    /*CURSOR c_user_creator IS
    select distinct name,userid from portal.WWLOG_ACTIVITY_LOGS
    where sub_domain = 'user' and action = 'create'
    and name = p_userid;*/
    v_creator varchar2(500);
    v_ret_val VARCHAR2(500) := 'NOT_FOUND';
    BEGIN
    select userid into v_ret_val from portal.WWLOG_ACTIVITY_LOGS
    where sub_domain = 'user' and action = 'create'
    and name = p_userid;
    --v_ret_val := x.userid;
    --end loop;
    -- Is the user in the group or not?
    /*OPEN c_user_creator;
    FETCH c_user_creator INTO v_creator;
    IF c_user_creator%FOUND THEN
    v_ret_val := v_creator;
    ELSE
    v_ret_val := 'NOT FOUND';
    END IF;
    CLOSE c_user_creator;*/
    Return v_ret_val;
    END;
    The table or view does not exist...
    I tryed with cursor, select into, for x in (select....)
    Nothing works.
    A select grant is a select grant right? Are there different grant you should use so you can select it into a function or just do a normal select?
    I also tryed to create a view that just sais select * from WWLOG_ACTIVITY_LOGS but that doesn't work...

    Are there different grant you should use so you can
    select it into a function or just do a normal select? Yes. Grants on objects used in functions/procedures must be given directly to the user, and not through a role.

  • Query Error - Schema Does Not Exist

    I get the following error when creating stored procedure:
    Msg 2797, Level 16, State 1, Procedure SearchAllTables, Line 90
    The default schema does not exist.
    CREATE PROC SearchAllTables
    @SearchStr nvarchar(100)
    AS
    BEGIN
    CREATE TABLE #Results(TableName nvarchar(370), KeyValues nvarchar(3630), ColumnName nvarchar(370), ColumnValue nvarchar(3630))
    SET NOCOUNT ON
    DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
        ,@TableShortName nvarchar(256)
        ,@TableKeys nvarchar(512)
        ,@SQL nvarchar(3830)
    SET  @TableName = ''
    SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
    WHILE @TableName IS NOT NULL
    BEGIN
        SET @ColumnName = ''
        -- Scan Tables
        SET @TableName = 
            SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
            FROM    INFORMATION_SCHEMA.TABLES
            WHERE       TABLE_TYPE = 'BASE TABLE'
                AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
                AND OBJECTPROPERTY(
                        OBJECT_ID(
                            QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                             ), 'IsMSShipped'
                               ) = 0
        Set @TableShortName=PARSENAME(@TableName, 1)
        -- print @TableName + ';' + @TableShortName +'!' -- *** DEBUG LINE ***
            -- LOOK Key Fields, Set Key Columns
            SET @TableKeys=''
            SELECT @TableKeys = @TableKeys + '''' + QUOTENAME([name]) + ': '' + CONVERT(nvarchar(250),' + [name] + ') + ''' + ',' + ''' + '
             FROM syscolumns 
             WHERE [id] IN (
                SELECT [id] 
                 FROM sysobjects 
                 WHERE [name] = @TableShortName)
               AND colid IN (
                SELECT SIK.colid 
                 FROM sysindexkeys SIK 
                 JOIN sysobjects SO ON 
                    SIK.[id] = SO.[id]  
                 WHERE 
                    SIK.indid = 1
                    AND SO.[name] = @TableShortName)
            If @TableKeys<>''
                SET @TableKeys=SUBSTRING(@TableKeys,1,Len(@TableKeys)-8)
            -- Print @TableName + ';' + @TableKeys + '!' -- *** DEBUG LINE ***
        -- Search in Columns
        WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
        BEGIN
            SET @ColumnName =
                SELECT MIN(QUOTENAME(COLUMN_NAME))
                FROM    INFORMATION_SCHEMA.COLUMNS
                WHERE       TABLE_SCHEMA    = PARSENAME(@TableName, 2)
                    AND TABLE_NAME  = PARSENAME(@TableName, 1)
                    AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
                    AND QUOTENAME(COLUMN_NAME) > @ColumnName
            ) -- Set ColumnName
            IF @ColumnName IS NOT NULL
            BEGIN
                SET @SQL='
                    SELECT 
                        ''' + @TableName + '''
                        ,'+@TableKeys+'
                        ,''' + @ColumnName + '''
                    ,LEFT(' + @ColumnName + ', 3630) 
                    FROM ' + @TableName + ' (NOLOCK) ' +
                    ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
                --Print @SQL -- *** DEBUG LINE ***
                INSERT INTO #Results
                    Exec (@SQL)
            END -- IF ColumnName
        END -- While Table and Column
    END --While Table
    SELECT TableName, KeyValues, ColumnName, ColumnValue FROM #Results
    END

    Here is the code from my blog post:
    CREATE PROCEDURE spSearchStringInTable
    (@SearchString NVARCHAR(MAX),
    @Table_Schema sysname,
    @Table_Name sysname)
    AS
    BEGIN
    DECLARE @Columns NVARCHAR(MAX), @Cols NVARCHAR(MAX), @PkColumn NVARCHAR(MAX)
    -- Get all character columns
    SET @Columns = STUFF((SELECT ', ' + QUOTENAME(Column_Name)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE DATA_TYPE IN ('text','ntext','varchar','nvarchar','char','nchar')
    AND TABLE_NAME = @Table_Name
    ORDER BY COLUMN_NAME
    FOR XML PATH('')),1,2,'')
    IF @Columns IS NULL -- no character columns
    RETURN -1
    -- Get columns for select statement - we need to convert all columns to nvarchar(max)
    SET @Cols = STUFF((SELECT ', cast(' + QUOTENAME(Column_Name) + ' as nvarchar(max)) as ' + QUOTENAME(Column_Name)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE DATA_TYPE IN ('text','ntext','varchar','nvarchar','char','nchar')
    AND TABLE_NAME = @Table_Name
    ORDER BY COLUMN_NAME
    FOR XML PATH('')),1,2,'')
    SET @PkColumn = STUFF((SELECT N' + ''|'' + ' + ' cast(' + QUOTENAME(CU.COLUMN_NAME) + ' as nvarchar(max))'
    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
    INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE CU ON TC.TABLE_NAME = CU.TABLE_NAME
    AND TC.TABLE_SCHEMA = CU.TABLE_SCHEMA
    AND Tc.CONSTRAINT_NAME = CU.CONSTRAINT_NAME
    WHERE TC.CONSTRAINT_TYPE ='PRIMARY KEY' AND TC.TABLE_SCHEMA = @Table_Schema AND TC.TABLE_NAME = @Table_Name
    ORDER BY CU.COLUMN_NAME
    FOR XML PATH('')),1,9,'')
    IF @PkColumn IS NULL
    SELECT @PkColumn = 'cast(NULL as nvarchar(max))'
    -- set select statement using dynamic UNPIVOT
    DECLARE @SQL NVARCHAR(MAX)
    SET @SQL = 'select *, ' + QUOTENAME(@Table_Schema,'''') + 'as [Table Schema], ' + QUOTENAME(@Table_Name,'''') + ' as [Table Name]' +
    ' from
    (select '+ @PkColumn + ' as [PK Column], ' + @Cols + ' FROM ' + QUOTENAME(@Table_Schema) + '.' + QUOTENAME(@Table_Name) + ' )src UNPIVOT ([Column Value] for [Column Name] IN (' + @Columns + ')) unpvt
    WHERE [Column Value] LIKE ''%'' + @SearchString + ''%'''
    --print @SQL
    EXECUTE sp_ExecuteSQL @SQL, N'@SearchString nvarchar(max)', @SearchString
    END
    GO
    IF OBJECT_ID('TempDB..#Result', N'U') IS NOT NULL DROP TABLE #Result;
    CREATE TABLE #RESULT ([PK COLUMN] NVARCHAR(MAX), [COLUMN VALUE] NVARCHAR(MAX), [COLUMN Name] sysname, [TABLE SCHEMA] sysname, [TABLE Name] sysname)
    DECLARE @Table_Name sysname, @SearchString NVARCHAR(MAX), @Table_Schema sysname
    SET @SearchString = N'Cost'
    DECLARE curAllTables CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY
    FOR
    SELECT Table_Schema, Table_Name
    FROM INFORMATION_SCHEMA.Tables
    WHERE TABLE_TYPE = 'BASE TABLE'
    ORDER BY Table_Schema, Table_Name
    OPEN curAllTables
    FETCH curAllTables
    INTO @Table_Schema, @Table_Name
    WHILE (@@FETCH_STATUS = 0) -- Loop through all tables in the database
    BEGIN
    INSERT #RESULT
    EXECUTE spSearchStringInTable @SearchString, @Table_Schema, @Table_Name
    FETCH curAllTables
    INTO @Table_Schema, @Table_Name
    END -- while
    CLOSE curAllTables
    DEALLOCATE curAllTables
    -- Return results
    SELECT * FROM #RESULT ORDER BY [Table Name]
    It works OK for me.
    I also posted another code today which searches a single column in all tables of the database. I spent about an hour working on that code and it works fine for me too.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Quota deduction when EE has been inactive for more than 180 days / Advance quota days when employee does not have enough balance

    Dear experts,
    We have two requirements regarding to the "Anual leave" quota.
    1. Quota reduction when employee is inactive for more than 180 days
    2. Advance quota days when employeee does not have enough balance
    We have in place an "Anual Leave" quota related to a calendar year period, that gets generated dialy in time evaluation. This quota gets the employee entitlement from a set of rules that stored the corresponding balance in a period time type, that is the one that we defined in the customizing. This is working fine. The problems start when we try to incorporate the other two requirements.
    Regarding the first requirement, if the employee has been inactive for more than 180 days in a calendar year due to unpaid leave, we need to start quota reduction as follow,
    First, we need to clear the balance that was calculated above in the schema.
    Then, we need to calculate one leave day for every 20 days worked till the end of the year, considering as such, everyday the employee is expected to work, except days on which the employee has been absent on unpaid leave.
    For the second requirement we created a manual quota call "Advance Anual Leave". So, if the employee, wishes to take 20 working days holiday, but in his/her Anual Leave quota has only 10 days available, we have to create an "Advance Anual Leave" quota manualy for 10 days. When the quota for next year gets generated, we need to deduct these advanced 10 days from it. This deduction should stop the year after.
    The problem we are finding with these two requirements is that, due to the Anual Leave quota gets generated dialy, we can't get the balance right.
    Thanks in advance!
    Kind regards,
    Alex

    Hello binbingogoABC,
    Shopping on BestBuy.com should be easy and fun and not fraught with the kind of trouble that you describe. I regret very much that this has been your experience.
    Using the information you provided when you signed up for Best Buy Unboxed I was able to locate your cancelled orders. I have requested more information from my back-office partners. As soon as I have additional details about your situation, I will reply again to this message. In the interim, I'm sorry that I must impose upon your patience.
    I'm very grateful that you wrote to us with your concerns.
    Sincerely,

Maybe you are looking for