SQL query to get transaction detail from DEFERRED_TRAN_ID

Hi,
I'm using Oracle Advance Replication and get the transaction detail from Enterprise Manager Console.
So instead of using the console.
Is there a way any SQL query which get transaction details like SQL query fired, old and new column value etc from DEFERRED_TRAN_ID.
thanks

quote:
Originally posted by:
lucapac
I have two tables: tblWorkers and tblSkills. tblWorkers has a
column, Skills, which is populated from a multiple-checkbox form
field with one or more skill_IDs from tblSkills, so each
tblWorkers.Skills consists of a list of one or more comma-delimited
values. For any Skill_ID, I need to generate a listing of all
Workers with the corresponding skill, so I have tried to do
something along the lines of SELECT WorkerName FROM tblWorkers
WHERE Skills IN (Skills, #FORM.Skill_ID#) ... or WHERE Skills IN
(ListFind(Skills, #FORM.Skill_ID#)) ... etc. ??? My results (once I
got data type mismatches out of the way) return all Workers, not
just those with the desired Skill. There must be an easy way to do
this ... How do people with a bit more CF/SQL experience than I
have do this???
As Kronin implied, we normalize our databases. If you don't
understand that answer, the book "Database Design for Mere Mortals"
is often mentioned on this forum.

Similar Messages

  • MS SQL query to get Subscription list from Operations Manager

    Hi Experts,
    Is there anyway get Subscription list from Operations Manager DB using SQL query?  I lost subscription list, and need to create subscription as it was. Very urgent.
    Thanks in advance.
    Regards
    Karthick M

    Hi,
    Hope the powershell command Get-SCOMNotificationSubscription can be helpful for you:
    Get-SCOMNotificationSubscription
    Retrieves a list of notification subscriptions.
    https://technet.microsoft.com/en-us/library/hh918490(v=sc.20).aspx
    Regards,
    Yan Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • SQL query to get the details

    We have a database with machine details such as ID, Hostname, IP Address, OS, etc...
    ID IP Address Hostname Protocol NetMask
    1 10.216.16.47 Test123 DNS 255.255.255.0
    1 10.216.16.48 Test123 DNS 255.255.255.0
    54 10.216.68.85 Test73711340 DNS 255.255.255.0
    71 10.216.63.101 Test737101230 DNS 255.255.255.0
    94 10.216.34.153 Test10000182 DNS 255.255.255.0
    I need to write a query which will find a machine with two IP addresses and give the output with a separate column for each IP.
    Expected output:
    ID IP Address IP Address 2 Hostname Protocol NetMask
    1 10.216.16.47 10.216.16.48 Test123 DNS 255.255.255.0
    54 10.216.68.85 Null Test73711340 DNS 255.255.255.0
    71 10.216.63.101 Null Test737101230 DNS 255.255.255.0
    94 10.216.34.153 Null Test10000182 DNS 255.255.255.0
    Any Suggestions?

    I hope this helps - 
    DECLARE @tblName TABLE (ID INT  , IPAddress   VARCHAR(100),   Hostname     VARCHAR(100),Protocol    VARCHAR(100),NetMask VARCHAR(100) )
    INSERT INTO @tblName
    SELECT 1   ,'10.216.16.47    ','Test123         ','DNS     ','255.255.255.0' UNION ALL
    SELECT 1   ,'10.216.16.48    ','Test123         ','DNS     ','255.255.255.0' UNION ALL
    SELECT 54  ,'10.216.68.85    ','Test73711340    ','DNS     ','255.255.255.0' UNION ALL
    SELECT 71  ,'10.216.63.101   ','Test737101230   ','DNS     ','255.255.255.0' UNION ALL
    SELECT 94  ,'10.216.34.153   ','Test10000182    ','DNS     ','255.255.255.0' 
    ;WITH CTE AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY ID ORDER BY IPAddress) AS  Row_NUM from @tblName)
    select ID,[1] as IPAddress, [2] as IPAddress2,Hostname , Protocol, NetMask  FROM CTE PIVOT (max(IPAddress) FOR Row_NUM in ([1],[2])) PVT
    MCTS 2008 & 2005 , MCITP 2008 -- Please remember to mark the post as answered if it answers your question.

  • SQL Query to get match string from table

    Hi Experts,
    BANNER                                                                         
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production         
    PL/SQL Release 11.1.0.7.0 - Production                                         
    CORE     11.1.0.7.0     Production                                                     
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production                        
    NLSRTL Version 11.1.0.7.0 - Production                                         
    5 rows selected.
    WITH T AS
    SELECT 'JOHN' FIRSTNAME,'PLAYER' LASTNAME FROM DUAL UNION ALL
    SELECT 'MICHEAL','SMITH' LASTNAME FROM DUAL UNION ALL
    SELECT 'SCOTT','MANAGER' LASTNAME FROM DUAL UNION ALL
    SELECT 'FIRST NAME','LAST NAME' LASTNAME FROM DUAL
    )SELECT * FROM T;
    Input String to my Query will be "JOHN NAME SMITH"
    I need to match the input string to provide result based on Firstname OR Lastname from table.
    How can i acheive this?
    Thanks,

    what the problem in constructing??
    you can use something like this....
    declare
    vStrng varchar2(100) := 'JOHN NAME SMITH';
    v_temp varchar2(1000):= 'SELECT  DISTINCT  firstname,lastname FROM employees,
      (SELECT regexp_substr('''||vStrng||''',''[[:alpha:]]+'',1,level) parsedstr
         FROM dual
        CONNECT BY level<=LENGTH(regexp_replace('''||vStrng||''',''[[:alpha:]]'',''''))+1
      ) WHERE instr(firstname,parsedstr)>0 OR instr(lastname,parsedstr)      >0';
    vSQL varchar2(1000):= 'SELECT ENAME,EMPNO,DEPT.DEPTNO FROM EMP,DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO AND (firstname,lastname) in ('||v_temp||')';
    begin
    --rest of your code....
    end;edit: In the same way...you can use any of the above mentioned solutions..
    Ravi Kumar
    Edited by: ravikumar.sv on Apr 6, 2010 4:12 PM

  • Dynamic SQL query to get single value from list in a column

    I have two tables: tblWorkers and tblSkills. tblWorkers has a
    column, Skills, which is populated from a multiple-checkbox form
    field with one or more skill_IDs from tblSkills, so each
    tblWorkers.Skills consists of a list of one or more comma-delimited
    values. For any Skill_ID, I need to generate a listing of all
    Workers with the corresponding skill, so I have tried to do
    something along the lines of SELECT WorkerName FROM tblWorkers
    WHERE Skills IN (Skills, #FORM.Skill_ID#) ... or WHERE Skills IN
    (ListFind(Skills, #FORM.Skill_ID#)) ... etc. ??? My results (once I
    got data type mismatches out of the way) return all Workers, not
    just those with the desired Skill. There must be an easy way to do
    this ... How do people with a bit more CF/SQL experience than I
    have do this???

    quote:
    Originally posted by:
    lucapac
    I have two tables: tblWorkers and tblSkills. tblWorkers has a
    column, Skills, which is populated from a multiple-checkbox form
    field with one or more skill_IDs from tblSkills, so each
    tblWorkers.Skills consists of a list of one or more comma-delimited
    values. For any Skill_ID, I need to generate a listing of all
    Workers with the corresponding skill, so I have tried to do
    something along the lines of SELECT WorkerName FROM tblWorkers
    WHERE Skills IN (Skills, #FORM.Skill_ID#) ... or WHERE Skills IN
    (ListFind(Skills, #FORM.Skill_ID#)) ... etc. ??? My results (once I
    got data type mismatches out of the way) return all Workers, not
    just those with the desired Skill. There must be an easy way to do
    this ... How do people with a bit more CF/SQL experience than I
    have do this???
    As Kronin implied, we normalize our databases. If you don't
    understand that answer, the book "Database Design for Mere Mortals"
    is often mentioned on this forum.

  • Dear Gurus, Can i have SQL query to get Ar cash receipt appled lines details in R12

    Dear Gurus, Can i have SQL query to get Ar cash receipt appled lines details in R12

    I need to get ar and ap details from GL through xla.For ex: Reference1,reference2,reference3,reference4,reference 5, in 11i these column values are displayed in gl_je_lines where as in R12 we need to join xla tables with gl_sl_link_id and gl_sl_link_table
    Can someone provide query to get subledger details particularly ar and ap?.How are the AP & GL Journal Tables linked? [ID 1188714.1]
    R12 Mapping Between Subledger Tables, SLA and GL Tables [ID 871622.1]
    eTRM
    http://etrm.oracle.com/
    Thanks,
    Hussein

  • SQL Query to get Project Plan Name and Resource Name from Reporting database of Project Server 2007

    Can you please help me to write an SQL Query to get Project Plan Name and Resource Name from Reporting database of Project Server 2007. Thanks!!

    Refer
    http://gallery.technet.microsoft.com/projectserver/Server-20072010-SQL-Get-a99d4bc6
    SELECT
    dbo.MSP_EpmAssignment_UserView.ProjectUID,
    dbo.MSP_EpmAssignment_UserView.TaskUID,
    dbo.MSP_EpmProject_UserView.ProjectName,
    dbo.MSP_EpmTask_UserView.TaskName,
    dbo.MSP_EpmAssignment_UserView.ResourceUID,
    dbo.MSP_EpmResource_UserView.ResourceName,
    dbo.MSP_EpmResource_UserView.ResourceInitials
    INTO #TempTable
    FROM dbo.MSP_EpmAssignment_UserView INNER JOIN
    dbo.MSP_EpmProject_UserView ON dbo.MSP_EpmAssignment_UserView.ProjectUID = dbo.MSP_EpmProject_UserView.ProjectUID INNER JOIN
    dbo.MSP_EpmTask_UserView ON dbo.MSP_EpmAssignment_UserView.TaskUID = dbo.MSP_EpmTask_UserView.TaskUID INNER JOIN
    dbo.MSP_EpmResource_UserView ON dbo.MSP_EpmAssignment_UserView.ResourceUID = dbo.MSP_EpmResource_UserView.ResourceUID
    SELECT
    ProjectUID,
    TaskUID,
    ProjectName,
    TaskName,
    STUFF((
    SELECT ', ' + ResourceInitials
    FROM #TempTable
    WHERE (TaskUID = Results.TaskUID)
    FOR XML PATH (''))
    ,1,2,'') AS ResourceInitialsCombined,
    STUFF((
    SELECT ', ' + ResourceName
    FROM #TempTable
    WHERE (TaskUID = Results.TaskUID)
    FOR XML PATH (''))
    ,1,2,'') AS ResourceNameCombined
    FROM #TempTable Results
    GROUP BY TaskUID,ProjectUID,ProjectName,TaskName
    DROP TABLE #TempTable
    -Prashanth

  • Sql query to get numbers from 0 to 99

    How can we write an sql query to get values from 0 to 99 ... this shouldn't be coming from any table

    Bawer wrote:
    Result: (quickly replied by oracle)
    SQL-Error: ORA-30009 (Not enough memory for connect by - 1GB reserved for oracle on VirtualBox)Oracle version? Takes about 8 seconds on my:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Elapsed: 00:00:00.14
    SQL> select count(*) from (
      2  SELECT LEVEL - 1
      3  FROM DUAL
      4  CONNECT BY LEVEL <= 10000000
      5  )
      6  /
      COUNT(*)
      10000000
    Elapsed: 00:00:07.76
    SQL> SY.

  • SQL query to get the Datetime 06 hours prior to the table Datetime value

    Hi Experts,
                    I'm just trying to create a SQL query to get the Datetime which should be 06 hours prior to my Table column value(Executiontime),
    Eg: my Executiontime(column) value is 07:00AM means, this query should fetch the detail of first VMName from table at 01:00AM, 
    SQL Table Name: TestTable
    Columns: VMName(varchar),status(varchar) Executiontime(Datetime)
    SQL Query : Select Top 1 VMName from
    TestTable where convert(date,Exeutiontime)=convert(date,getdate()) and
    status='0' and ExecutionTime > dateadd(hour,6,getdate())
    Request someone to alter this Query to my requirement or give me the new one.
    Regards,
    Sundar
    Sundar

    Hi All,
            Thanks for your Prompt response. I tried the below queries, but still I don't have any luck. Actually the queries are returning the value before the condition met (say when the time difference is more than 06 hours). I want the
    query to return exactly @ 06 hour difference or less than 06 hours,
    Query 01: Select Top 1 VMName from TestTable where
    convert(date,Exeutiontime)=convert(date,getdate())
    and status='0'
    and ExecutionTime >
    dateadd(hour,-6,getdate())
    Query 02: Select
    Top 1 VMName from TestTable where
    status='0'
    and ExecutionTime >
    dateadd(hour,-6,getdate())
    Query 03: Select
    Top 1 VMName from TestTable where status='0'
    and ExecutionTime >
    dateadd(hour,-6,ExecutionTime)
              Can someone point out the mistake please.
    Regards,
    Sundar
    Sundar

  • Sql query to get number of days monthwise

    Hi,
    i am new to sql, can anyone please tell me query to find number of working days between two dates month wise.
    say
    firstdate last date
    21/03/2011 25/06/2011
    march april may june
    9 22 23 18

    Hi,
    918373 wrote:
    even a result like,
    stud_id month amount
    1234 MAR-11 xyz
    1234 JUL-11 ...Please post the exact output that you want.
    Do you want 'xyz' in the output, or do you want a number like 42 (2 hours * 6 weekdays in March 2011, plus 5 hpours * 6 weekdays = 12 + 30 = 42)?
    If you want 42, then post 42. Spend 5 minutes (if it comes to that much) with a calendar and a calculator to get the exact results you want.
    >
    >
    is much better,
    in that case i want it as a view, so that i can get further details from the view....Substituting your table and column names, into the query I posted earlier and replacing COUNT (*) with SUM (no_of_hours), the query is
    WITH     cntr     AS
         SELECT     LEVEL - 1     AS n
         FROM     (
                  SELECT  MAX (enddate - startdate)     AS days_in_range
                  FROM    class_dets
         CONNECT BY     LEVEL     <= 1 + days_in_range
    SELECT       x.stud_id
    ,       TO_CHAR ( TRUNC (x.startdate + c.n, 'MONTH')
                , 'fmMonth YYYY'
                )               AS month
    ,       SUM (no_of_hours)          AS total_hours
    FROM       class_dets  x
    JOIN       cntr        c  ON   x.enddate >= x.startdate + c.n
    WHERE       TO_CHAR ( x.startdate + c.n
                  , 'DY'
                , 'NLS_DATE_LANGUAGE=ENGLISH'     -- If necessary
                )      NOT IN ('SAT', 'SUN')
    GROUP BY  x.stud_id
    ,            TRUNC (x.startdate + c.n, 'MONTH')
    ORDER BY  x.stud_id
    ,            TRUNC (x.startdate + c.n, 'MONTH')
    ;The output, with the sample data you posted, is:
    `  STUD_ID MONTH                                     TOTAL_HOURS
          1234 March 2011                                         42
          1234 April 2011                                        147
          1234 May 2011                                          154
          1234 June 2011                                         154
          1234 July 2011                                          72
          1234 August 2011                                        46
          1234 September 2011                                     14
          1235 June 2011                                          36
          1235 July 2011                                          84
          1235 August 2011                                        92
          1235 September 2011                                     88
          1235 October 2011                                       12
          1236 June 2012                                          56
          1236 July 2012                                         154
          1236 August 2012                                        14Aside from pivoting, is that what you want?
    i edited the your query,
    WITH     all_dates     AS
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=1236), 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ((select enddate from class_dets where stud_id=1236), 'DD/MM/YYYY')     AS end_dateInstead of the 2 lines above, the query I posted had
    SELECT  MAX (enddate - startdate)     AS days_in_rangeWhy did you make that change?
    The first argument to TO_DATE is supposed to be a string. You're calling TO_DATE with this as the first argument
    (select startdate from class_dets where stud_id=1236)which is a DATE, not a string.
                   FROM     dual
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    SELECT     TO_CHAR ( TRUNC (a_date, 'MONTH')
              , 'fmMonth YYYY'
              )               AS month
    ,     COUNT (*) * (select fee from class_dets where stud_id=1236) * (select no_of_hours from class_dets where stud_id=1236)               AS amount
    FROM     all_dates
    WHERE     a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY TRUNC (a_date, 'MONTH')
    ORDER BY TRUNC (a_date, 'MONTH')
    it works very well, but instead of specifying stud_id as 1236,
    but when i say,
    WITH     all_dates     AS
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=cd.stu_id), 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ((select enddate from class_dets where stud_id=cd.stud_id), 'DD/MM/YYYY')     AS end_date
                   FROM     dual
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    SELECT     cd.stud_id,TO_CHAR ( TRUNC (a_date, 'MONTH')
              , 'fmMonth YYYY'
              )               AS month
    , count(*)
    ,     COUNT (*) * (select fee from class_dets where stud_id=1236) * (select no_of_hours from class_dets where stud_id=1236)               AS amount
    FROM     all_dates,class_dets cd
    WHERE     a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY TRUNC (a_date, 'MONTH'),cd.stud_id
    ORDER BY TRUNC (a_date, 'MONTH'),cd.stud_id
    i get error
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=cd.stu_id), 'DD/MM/YYYY')     AS start_date
    ERROR at line 6:
    ORA-00904: "CD"."STU_ID": invalid identifierThere's no column called stu_id in class_dets. There is a column called stud_id (with 2 'd's).
    >
    what should i do?
    (sorry about the query format...how display query in a formatted way? )This site noramlly compresses whitespace.
    Whenever you post formatted text (including, but not limited to, code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • SQL query to get a list of relations between workitems

    How can I create a SQL query to get a list of all problems with related changes?  And all problems with related incidents?
    I have tried to join the tables RelationshipTypeDim with ProblemDimKey and ChangeRequestDim, but the results are not correct.

    The relationships in the data warehouse can be kind of tricky. The relationships are contained in the WorkItemRelatesToWorkItemFactvw table. This table lists the related items by their WorkItemDimKey, so you cannot reference directly from the ChangeRequestDimvw
    or ProblemDimvw. You will need to reference the WorkItemDimvw to get the WorkItemDimKey for each entry.
    The query below will get all of the related work items from the Change Request class. The way the joins work is ChangeRequestDimvw gets the list of change requests. Then inner joins WorkItemDimvw to get the WorkItemDimKey for each CR. Then inner joins WorkItemRelatesToWorkItemFactvw
    to get all of the CRs with related work items. Then inner joins the WorkItemDimvw again to get the ID of the related work item. 
    Now the tricky part is it appears that these relationship are set based on which item  that created the relationship. So you need to union a second query that reverse the relationship on the WorkItemRelatesToWorkItemFactvw. 
    This query should give you a good start on getting the related work items. You can filter it down from here if you only want to include problems.
    SELECT C.ID, WIWI.ID
    FROM dbo.ChangeRequestDimvw C
    INNER JOIN dbo.WorkItemDimvw WI ON
    WI.EntityDimKey = C.EntityDimKey
    INNER JOIN dbo.WorkItemRelatesToWorkItemFactvw AS WIRWI ON
    WIRWI.WorkItemDimKey = WI.WorkItemDimKey
    INNER JOIN dbo.WorkItemDimvw AS WIWI ON
    WIWI.WorkItemDimKey = WIRWI.WorkItemRelatesToWorkItem_WorkItemDimKey
    union
    SELECT C.ID, WIWI.ID
    FROM dbo.ChangeRequestDimvw C
    INNER JOIN dbo.WorkItemDimvw WI ON
    WI.EntityDimKey = C.EntityDimKey
    INNER JOIN dbo.WorkItemRelatesToWorkItemFactvw AS WIRWI ON
    WIRWI.WorkItemRelatesToWorkItem_WorkItemDimKey = WI.WorkItemDimKey
    INNER JOIN dbo.WorkItemDimvw AS WIWI ON
    WIWI.WorkItemDimKey = WIRWI.WorkItemDimKey
    Order by C.ID
    Matthew Dowst |
    Blog | Twitter

  • SQL query to get the list of approvals

    Hi,
    Could someone let me know the SQL query to get the list of all the pending approvals for a user in OIM 11g R2.
    Thanks

    There are a few ways to do this:
    -  The easiest would be to use a Relationship Query from the CMC. To do this, go to the Universes section on the CMC, right click on the relevant universe, select tools >> Check Relationships.
    - Use Query Builder. You will need more than one query to pull the information you need. You could try something like the below (for Webi)
    SELECT SI_NAME, SI_WEBI, SI_DATACONNECTION FROM CI_APPOBJECTS
    WHERE SI_KIND = 'universe' and SI_NAME = 'Universe Name'
    This will give you a list of Webi Reports by SI_ID.
    You'll need another query to list Webi report names:
    SELECT SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID IN (SI_ID from query above)
    - This is trivial via Auditing / the Activity universe. This of course will only return reports that have already run.
    Best.
    Srinivas

  • SQL query to get last 6 months records neglect the current month

    Hi All;
    I need help with 
    sql query to get last 6 months records neglect the current month
    Any help much appreciated
    Thanks
    Pradnya07

    SELECT <> FROM tbl WHERE dt >=dateadd(month,-6,GETDATE())
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • SQL query to get last 10 records in the table?

    Hi,
    Can anyone tell me the SQL query to get last 10 records in the table?
    Thanks!!
    MCP

    Please, define what "last" means. Sets are unordered by definition, so if you want to retrieve rows from a table in a specific order you need to specify what that order is - e.g. by maintaining a value in a column (or a combination of columns) that you can use in the ORDER BY clause of the SELECT statement.
    If, for instance, you kept the time when the row was inserted in a special column (InsertedTime), you could use this in your query like this:
    select top (10)
      <column list>
      from <table or view>
      where <restriction(s)>
      order by InsertedTime desc;
    ML
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • Query to get the details of Blocking and deadlock occurred for the Day

    Hi,
       I need a query to get the details of blocking and deadlock occurred for the day.

    You havent specified which version of SQL you are using which makes it difficult to give a solution. Assuming its latest versions , by default SQL Server (in any versions) doesnt track blocking information.
    You need to run some kind of queries/traces to capture blocking. The same goes with Deadlocks where majority of the DBA's enable trace flag 1222/1205 when they suspect deadlocks happening.
    Check this link -
    http://dba.stackexchange.com/questions/10644/deadlock-error-isnt-returning-the-deadlock-sql/10646#10646
    This link gives code to get historic deadlock information. I havent used it , I just googled to get that.
    That being said if you are looking for something to capture for the future check the below links.
    Check these links on how to setup extended events to capture deadlock and blocking.
    http://sqlblog.com/blogs/jonathan_kehayias/archive/2010/12/21/an-xevent-a-day-21-of-31-the-future-tracking-blocking-in-denali.aspx
    http://blogs.msdn.com/b/sqlserverfaq/archive/2013/04/27/an-in-depth-look-at-sql-server-memory-part-2.aspx
    http://blogs.technet.com/b/mspfe/archive/2012/06/28/how_2d00_to_2d00_monitor_2d00_deadlocks_2d00_in_2d00_sql_2d00_server.aspx
    HTH
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

Maybe you are looking for

  • Is there a way to have the Notification bar in the Beta 7 build?

    My version of the Beta just upgraded to the beta 7 build and with it, it took away the Notification bar, as well as the ability to restore it. A friend of mine suggested to search for an add-on, but I do not believe that to be a possibility as the No

  • What am I missing out on using color on 15" MBP (1400x900) monitor?

    Minimum recommended resolution: 1650x1050 Should I trade the 15" in for 17" model (Just bought it)? I'm a complete beginner and have never used color before. Basic answers are appreciated. This is not for "TV" production, just small shop jobs and hob

  • Employee wise cost posting

    Hello Experts, we wish to post personnel related payment/cost transactions (like, Salary, Mobile reimbursement, Conveyance, Staff Advance, etc) against the name of that particular staff member. therefore staff member to be viewed as to be cost center

  • Are there any of the older browsers we can be using right now?

    I know from the past, we've used older versions in times , there were problems. I would like to know which ones to use that work good, and are safe.There's been so many browsers over the years, I'm not sure which ones to try. Thank You. "application"

  • Question on Redo logs in RAC

    DB version:11.2 Platform : Solaris 10 We create RAC DBs manually. Below is a log of the DB creation from Node1 . Instance in Node2 is not yet created (only binary is installed in Node2). SQL> conn / as sysdba Connected to an idle instance. SQL> start