Two Hyphens in SQL

Quite often, I see example SQL from books (Mastering Oracle SQL from Orielly and Oracle SQL High Performance Tuning) having 2 hyphens in it (--) as minus operator , e.g.:
SELECT .. FROM t WHERE order_dt > SYSDATE -- 100*4;
I tested it with Oracle 9iR2 and it doesn't look like a valid syntax (a single hyphen should be the corrent syntax). I just wondering if this is some old syntax? I think it is unlikely that 2 books make the same error!

Two hyphens is single line comment; everything after the hyphens is comment.
SQL> select * -- This is comment
  2    from dual -- so is this
  3  /
D
X
SQL>

Similar Messages

  • How to add Two Columns in SQL

    How to add Two Columns in SQL
    For Example
    Jan Feb
    215 NULL
    How to add these two values in SQL

    Anything + NULL is NULL.
    Check this:
    SQL> SELECT 1 + NULL from dual;
        1+NULL
    SQL> You have to do this:
    SQL> with t as (SELECT 235 JAN, NULL FEB FROM dual)
      2  SELECT NVL(JAN,0) + NVL(FEB,0) FROM t;
    NVL(JAN,0)+NVL(FEB,0)
                      235
    SQL>

  • Space between two hyphens

    I am writing an html file in TextEdit. When I write a comment <!-- comment here --> the space between the two hyphens (--) disappears automatically and becomes one which makes the comment dysfunctional. Can anyone help me fix this? It happens when I write in TextEdit.

    Textedit is intended as an editor to edit text and as such has settings that make text editing easier, such as turning two hyphens into a long dash.
    While these features can be turned off or modified to let you more easily edit programs I recommend you get an editor designed to edit programs. Bare Bones Software | TextWrangler is a good free editor that will make your programming life a lot easier.
    As for this specific problem look in Textedit's preferences and turn off smart dashes, that should fix this. But as I wrote if you do much programing you should get a different editor.
    regards
    Also if you continue to use Textedit turn off smart quotes also.

  • Three tier (mod pl/sql) vs. two tier (PL/SQL Gateway)

    I've been using 10g Database and 10g application server on separate servers for some time now.
    Going the two tier (11g) route has some attractions, but what are the disadvantages?
    The Oracle documentation I've seen says very little on making the decision, giving benefits as:
    Ease of configuration
    Included in the database
    No separate server installation
    - but no negatives.
    Does anyone have any real live experience of comparing the two options?
    I'm inclined to believe that three tier might have more tuning flexibility, better performance if each tier is on a different server. Maybe worse than two tier if on one server, assuming two tier eliminates communication overheads..
    Does pl/sql gateway have the caching ability of Apache/mod pl/sql - I assume not? - that could make a big difference.
    Any thoughts would be welcome...

    There are several key performance advantages of OHS over EPG. I'm working a lot with the EPG right now and pushing the XDB team to add several of these features (maybe in 11.2, possible backport, but don't count on it). I used recommendations from the yslow Firefox add-in to do some performance tuning. Here's there list of Best Practices:
    http://developer.yahoo.com/performance/rules.html
    - EPG does not add an "Expires" header. So, lets say you have 25 images in your page template, and none of them change. Each page view will still request those 25 images. They use etags, so you don't have to download the images, but your browser still makes the requests which is quite slow. From my testing, pages could be up to 4 times slower with the EPG with a pretty standard template. The XDB team is aware of this and working hard to resolve it.
    - EPG does not support gzip. This is another HUGE performance hit.
    Keep in mind you can't test any of those issue with debug mode in APEX, you really need to use a browser plugin such as Firebug + ySlow. The render speed from APEX's point of view will be the same, no matter what HTTP server you use.
    The other big on is mod_rewrite support. There is no way easily create friendly URLs for your apps. Another thing to consider is that a number of Identity Management systems, such as Oracle Access Manager (OAM) work by installing an Apache Module or in the case of IIS, some type of plugin (forget what they call it). There is no concept of this in EPG.
    IMHO, it's convenient for laptops, but I would never use it for production unless you needed some feature that it exposes, such as WebDav or FTP access to the XDB repository...
    Tyler

  • Execution of Immediate SQL in compiled package in two versions of SQL*PLUS

    A peculiar problem has risen in our database.
    Execution of Immediate SQL in compiled package in two versions of SQLPLUS gives different results
    We have a compiled package with two procedures that contain immediate SQL statements, and these are:
    +PROC_DELETE_ROWS+
    +     -- This immediate sql deletes unreferenced Document Types from the DOC_REF_TYPE table+
    +     delete from doc_ref_type t where exists (select 1 from PROARC_DOC_REF_TYPE_VW d where d.doc_ref_type = t.doc_ref_type)+
       +     and not exists (select 1 from doc_ref d where d.doc_ref_type = t.doc_ref_type)+
       +     and doc_ref_type not in (select doc_ref_type from eis_doc_ref_type)+
       +     and doc_ref_type not in (select eis_doc_ref_type from eis_doc_ref_type)+
    +PROC_ADD_NEW_ROWS+
    +     -- Drop the temporary table+
    +     drop table TMP_PROARC_DOC_REF_TYPE+
    +     -- Create a temporary table+
    +     create table tmp_PROARC_DOC_REF_TYPE as+
    +     select DOC_REF_TYPE, substr(DOC_REF_TYPE_DESC,1,100) as DOC_REF_TYPE_DESC+
    +     from PROARC_DOC_REF_TYPE_VW+
    +     -- Insert document types that do not exist in the DOC_REF_TYPE table+
    +     insert into doc_ref_type t (DOC_REF_TYPE, DOC_REF_TYPE_DESC)+
            +     select distinct DOC_REF_TYPE, DOC_REF_TYPE_DESC from tmp_PROARC_DOC_REF_TYPE s+
            +     where not exists (select 1 from doc_ref_type t where t.doc_ref_type = s.doc_ref_type)+
    I am using the following test script:
    +Exec mypackage.proc_delete_rows;+
    +Commit;+
    +Select count(*) from DOC_REF_TYPES;+
    +Exec mypackage.proc_add_new_rows;+
    +Commit;+
    +Select count(*) from DOC_REF_TYPES;+We have a Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit
    I am using SQL*Plus: Release 8.1.7.0.0
    The test script is working as expected.
    Count after delete =155
    Count after insert = 511
    but when I use another computer with SQL*Plus: Release 10.x
    The Test script returns the following
    Count after delete =155
    Count after insert =155
    The same is happening when I am running the scripts as a scheduled job.
    QUESTION:
    I believe I have found a fix for the problem though. By changing tmp_PROARC_DOC_REF_TYPE in the insert statement to all upper case, the script is running in both environments apparently. But how is this possible? I am executing a compiled package in the database. The session shell should have no impact on the behaveour of the procedure I am calling. What causes this?
    Edited by: Reon on Jun 16, 2011 4:44 AM

    1) I am using the same user (PANDORA)
    2) (PANDORA) for both
    3) I am actually not handling any errors. Just skipping any error altogether. I'll check to see what exceptions are raised, and come back.
    I have also noticed that SQL/PLUS is not the culprit here. If I use SQLTools 1.5 to run the script, the same thing happens. So it has to do something with the connection or session environment that is inheritet to both clients.
    The CODEZ:_
      procedure add_doc_types IS
      sqlstr     VARCHAR2(2000);
      begin
      BEGIN
           sqlstr := 'drop table TMP_PROARC_DOC_REF_TYPE';
         EXECUTE IMMEDIATE sqlstr;
        EXCEPTION
          WHEN OTHERS THEN
            null;
        END;
      BEGIN
           sqlstr := 'create table tmp_PROARC_DOC_REF_TYPE as select DOC_REF_TYPE, substr(DOC_REF_TYPE_DESC,1,100) as DOC_REF_TYPE_DESC from PROARC_DOC_REF_TYPE_VW';
         EXECUTE IMMEDIATE sqlstr;
        EXCEPTION
          WHEN OTHERS THEN
            null;
        END;
        BEGIN
            sqlstr := 'insert into doc_ref_type t (DOC_REF_TYPE, DOC_REF_TYPE_DESC)
                    select distinct DOC_REF_TYPE, DOC_REF_TYPE_DESC from TMP_PROARC_DOC_REF_TYPE s
                    where not exists (select 1 from doc_ref_type t where t.doc_ref_type = s.doc_ref_type)';
         EXECUTE IMMEDIATE sqlstr;
            sqlstr := 'update doc_ref_type t set DOC_REF_TYPE_DESC = (
                    select DOC_REF_TYPE_DESC from tmp_PROARC_DOC_REF_TYPE s
                    where t.doc_ref_type = s.doc_ref_type)
                    where exists (select 1 from tmp_PROARC_DOC_REF_TYPE s where t.doc_ref_type = s.doc_ref_type)';
         EXECUTE IMMEDIATE sqlstr;
        EXCEPTION
          WHEN OTHERS THEN
            null;
        END;
      end add_doc_types;
      procedure delete_doc_types IS
      sqlstr     VARCHAR2(2000);
       BEGIN
            sqlstr := 'delete from doc_ref_type t where exists (select 1 from PROARC_DOC_REF_TYPE_VW d where d.doc_ref_type = t.doc_ref_type)
            and not exists (select 1 from doc_ref d where d.doc_ref_type = t.doc_ref_type)
            and doc_ref_type not in (select doc_ref_type from eis_doc_ref_type)
            and doc_ref_type not in (select eis_doc_ref_type from eis_doc_ref_type)';
          EXECUTE IMMEDIATE sqlstr;
         EXCEPTION
           WHEN OTHERS THEN
             null;
      end delete_doc_types;Edited by: Reon on Jun 16, 2011 2:01 AM

  • Two count(*) in sql statement

    hi viewers,
    I need the similar query in oracle for the following Informix query.
    select count(*),(select count(*) from table_name where col1=10) from table_name where col1=10;
    i have a solution also but the problem is, if that table has no rows then output is not 0,0
    select count(*),(select count(*) from table_name where col1=10) from table_name where col1=10 group by col1;
    thanks
    hari

    A little remark: the behavoiur you stick on is a default feature in Oracle:
    SQL> select count(*) from emp where deptno = 40;
      COUNT(*)
             0
    SQL> select count(*) from emp where deptno = 40 group by deptno;
    no rows selectedThese two queries work differ. It is described in Oracle documentation:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#i89203
    Oracle applies the aggregate functions to each group of rows and returns a single result row for each group.
    If you omit the GROUP BY clause, then Oracle applies aggregate functions in the select list to all the rows in the queried table or view
    As Alex pointed out, you should not include group by clause and should use count(*) instead of a subquery.
    Rgds.

  • How to Join two diff pl/sql table  ???

    i have three queries
    1.One Query returns office and city
    2.Second Query return City - State
    3.Third Query returns State and Sub region
    I use three cursors and i want the output as Office -City -State -Sub region
    city is the joining for 1 and 2
    state is the joining for 2 and 3
    I am thinking of putting into pl/sql table .if it is okay tell me by giving how u will join the two pl/sql tables and if there is any other way kindly let me know .It is urgernt and please give me the code logic so that i can proceed

    First thing why are you using cursors? You can do it
    using SQL.Agreed, it can all be specified in a single SQL statement.
    Secondly I don't think there is some as Pl/Sql TableThere used to be something called a PL/SQL Table, but these have now, thankfully, been renamed to Associative Arrays, because that is what they are, Arrays, not tables. You can't treat Assoc. Arrays as database tables so you can't do Joins in the same way as you would with an SQL statement. To implement a join using arrays would require some (possibly recursive) loops to process each of the arrays to get the required data. This would of course be a lot slower than just using SQL on database tables.
    ;)

  • How to pass two parameters to sql query

    I try to create a sql script to update two columns in one table. I want to set it as parameter. When people execute this sql script, they need to pass parameter into sql query, then query will be executed successfully. The problem is I am only able to pass one parameter. If set two parameters in one line code, it will get ORA-00933 errors. Please advice me where I was wrong. The code is simple and like this:
    update MY_TABLE set year = &year AND month = &month where application_type = 'xxxx';
    If I only have: update MY_TABLE set year = &year where application_type = 'xxxx'; It works. If I set two parameters to pass value. It will get error.

    Hi,
    When you UPDATE two or more columns in the same statement, use ',' instead of 'AND' to separate them:
    update  MY_TABLE
    set     year = &year
    ,       month = &month
    where   application_type = 'xxxx';The correct syntax for all SQL statements, including UPDATE, can be found in the [SQL Language manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10008.htm#sthref9598].

  • Linking two tables in SQL

    Hi,
    Iam struggling with SQL for this scenario..can you please through some light on this.
    Table A:
    Order Number || W.O.Number || Enetrprise || ResourcePool
    1 || 1 || A || RP1
    2 || 2 || A || RP1
    3 || 3 || A || RP2
    4 || 4 || A || RP2
    5 || 5 || A || RP3
    B
    ResourcePool || Available Date
    RP1 || 20-Dec-2007
    RP1 || 21-Dec-2007
    RP1 || 22-Dec-2007
    RP2 || 20-Dec-2007
    RP2 || 21-Dec-2007
    RP3 || 20-Dec-2007
    RP3 || 21-Dec-2007
    My query should fetch
    Order Number|| W.O.Number|| Enetrprise|| ResourcePool|| Available Date
    1 || 1 || A || RP1 || 20-Dec-2007
    1 || 1 || A || RP1 || 21-Dec-2007
    1 || 1 || A || RP1 || 22-Dec-2007
    2 || 2 || A || RP1 || 20-Dec-2007
    2 || 2 || A || RP1 || 21-Dec-2007
    2 || 2 || A || RP1 || 22-Dec-2007
    3 || 3 || A || RP2 || 20-Dec-2007
    3 || 3 || A || RP2 || 21-Dec-2007
    4 || 4 || A || RP2 || 20-Dec-2007
    4 || 4 || A || RP2 || 21-Dec-2007
    5 || 5 || A || RP2 || 20-Dec-2007
    5 || 5 || A || RP2 || 21-Dec-2007
    when Iam including A.resourcepool=B.resourcepool in the query its returning no rows.
    Thanks

    (repeated)
    select Order Number,W.O.Number, Enetrprise, a.ResourcePool, Available Date
    from a,b
    where a.resourcepool=b.resourcepool;
    this is the simplest join condition.
    just check whether you have some data in those tables!

  • Combine two row in sql

    Hello Guys,
    Is it possible to create this kinda output.
    Input:
    Table1
    Column1
    Column
    1
    A
    2
    B
    3
    C
    4
    D
    Table2
    A
    B
    C
    D
    0
    1
    0
    0
    1
    0
    1
    0
    0
    1
    1
    1
    0
    1
    0
    1
    Output:
    B
    AC
    BCD
    BD
    Actually i want to Combine two different table column deepen where 1 .
    thanks

    Hello ,
    you need to use PIVOT ,See the below sample :
    Step 1 :
    insert into DailyIncome values ('SPIKE', 'FRI', 100)
    insert into DailyIncome values ('SPIKE', 'MON', 300)
    insert into DailyIncome values ('FREDS', 'SUN', 400)
    insert into DailyIncome values ('SPIKE', 'WED', 500)
    insert into DailyIncome values ('SPIKE', 'TUE', 200)
    insert into DailyIncome values ('JOHNS', 'WED', 900)
    insert into DailyIncome values ('SPIKE', 'FRI', 100)
    insert into DailyIncome values ('JOHNS', 'MON', 300)
    insert into DailyIncome values ('SPIKE', 'SUN', 400)
    insert into DailyIncome values ('JOHNS', 'FRI', 300)
    insert into DailyIncome values ('FREDS', 'TUE', 500)
    insert into DailyIncome values ('FREDS', 'TUE', 200)
    insert into DailyIncome values ('SPIKE', 'MON', 900)
    insert into DailyIncome values ('FREDS', 'FRI', 900)
    insert into DailyIncome values ('FREDS', 'MON', 500)
    insert into DailyIncome values ('JOHNS', 'SUN', 600)
    insert into DailyIncome values ('SPIKE', 'FRI', 300)
    insert into DailyIncome values ('SPIKE', 'WED', 500)
    insert into DailyIncome values ('SPIKE', 'FRI', 300)
    insert into DailyIncome values ('JOHNS', 'THU', 800)
    insert into DailyIncome values ('JOHNS', 'SAT', 800)
    insert into DailyIncome values ('SPIKE', 'TUE', 100)
    insert into DailyIncome values ('SPIKE', 'THU', 300)
    insert into DailyIncome values ('FREDS', 'WED', 500)
    insert into DailyIncome values ('SPIKE', 'SAT', 100)
    insert into DailyIncome values ('FREDS', 'SAT', 500)
    insert into DailyIncome values ('FREDS', 'THU', 800)
    insert into DailyIncome values ('JOHNS', 'TUE', 600)
    Now :
    VendorId IncomeDay IncomeAmount
    SPIKE FRI 100
    SPIKE MON 300
    FREDS SUN 400
    SPIKE WED 500
    SPIKE TUE 200
    JOHNS WED 900
    SPIKE FRI 100
    JOHNS MON 300
    SPIKE SUN 400
    SPIKE WED 500
    FREDS THU 800
    JOHNS TUE 600
    Step 3:
    select * from DailyIncome
    pivot (avg (IncomeAmount) for IncomeDay in ([MON],[TUE],[WED],[THU],[FRI],[SAT],[SUN])) as AvgIncomePerDay
    Output :
    VendorId MON TUE WED THU FRI SAT SUN
    FREDS 500 350 500 800 900 500 400
    JOHNS 300 600 900 800 300 800 600
    SPIKE 600 150 500 300 200 100 400
    More details
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • Finding Paths Between Two Nodes Using SQL Sorted by Cost

    Hi Gurus,
    I want to find all paths from source node to target node that shall be sorted by the cost. I don't know whether it could be achieved with SQL statement. How to start with this query? The script to create the underlying tables along with the data are given below:
    create table nodes ( nodeId int Primary Key, nodeName varchar(50));
    create table paths ( pathId int Primary Key, fromNodeId int, toNodeId int, cost int );
    insert into nodes values (1,'ISL');
    insert into nodes values (2,'LHR');
    insert into nodes values (3,'HYD');
    insert into nodes values (4,'FSL');
    insert into nodes values (5,'MUL');
    insert into nodes values (6,'KHI');
    insert into nodes values (7,'QT');
    insert into paths values (1,1,3,20);
    insert into paths values (2,1,5,10);
    insert into paths values (3,1,7,80);
    insert into paths values (4,2,4,10);
    insert into paths values (5,3,4,40);
    insert into paths values (6,3,5,20);
    insert into paths values (7,3,6,10);
    insert into paths values (8,6,7,30);
    insert into paths values (9,6,5,30);
    insert into paths values (10,6,3,10);
    insert into paths values (11,7,2,20);
    insert into paths values (12,5,4,40);
    insert into paths values (13,5,7,40);
    Suppose the source = ISL and target = QT, their are various paths from ISL to QT:
    Ord# Relative Path Cost
    ==== ================================= =================
    1. ISL -> MUL -> QT 50
    2. ISL -> HYD -> KHI -> QT 60
    3. ISL -> QT 80
    4. ISL -> HYD -> MUL -> QT 80
    5. ISL -> HYD to KHI -> MUL -> QT 100
    This gives us all possible paths sorted by cost.
    Any hint or help will be highly appreciated.
    Thanks in advance and best regards
    Bilal
    Edited by: naive2Oracle on Feb 11, 2011 9:59 AM

    I like recursive with clause B-)
    col path for a30
    with nodes(nodeId,nodeName) as(
    select 1,'ISL' from dual union
    select 2,'LHR' from dual union
    select 3,'HYD' from dual union
    select 4,'FSL' from dual union
    select 5,'MUL' from dual union
    select 6,'KHI' from dual union
    select 7,'QT'  from dual),
    paths(fromNodeId,toNodeId,cost) as(
    select 1,3,20 from dual union
    select 1,5,10 from dual union
    select 1,7,80 from dual union
    select 2,4,10 from dual union
    select 3,4,40 from dual union
    select 3,5,20 from dual union
    select 3,6,10 from dual union
    select 6,7,30 from dual union
    select 6,5,30 from dual union
    select 6,3,10 from dual union
    select 7,2,20 from dual union
    select 5,4,40 from dual union
    select 5,7,40 from dual),
    tmp(nodeName,fromNodeId,toNodeId,cost) as(
    select a.nodeName,b.fromNodeId,b.toNodeId,b.cost
      from nodes a,paths b
    where a.nodeId=b.fromNodeId),
    rec(nodeName,path,fromNodeId,toNodeId,cost) as(
    select nodeName,cast(nodeName as varchar2(40)),
    fromNodeId,toNodeId,cost
      from tmp
    where nodeName = 'ISL'
    union all
    select b.nodeName,a.path || '->' || b.nodeName,
    b.fromNodeId,b.toNodeId,
    a.cost+decode(b.nodeName,'QT',0,b.cost)
      from rec a,tmp b
    where a.toNodeId = b.fromNodeId
       and a.nodeName !='QT')
    CYCLE fromNodeId SET IsLoop TO 'Y' DEFAULT 'N'
    select path,cost from rec
    where IsLoop ='N'
      and nodeName ='QT'
    order by cost;
    PATH                    COST
    ISL->MUL->QT              50
    ISL->HYD->KHI->QT         60
    ISL->HYD->MUL->QT         80
    ISL->QT                   80
    ISL->HYD->KHI->MUL->QT   100

  • Combine two tables T-SQL

    Hi there,
    It might be simple Query for you but I was missing the logic.
    I have Tab A    this does have 4 records.
               Tab B  this does have 14 records.
    Note: those 4 records exists in Tab B
    I want to insert rest of the 10 records into the Tab A.
    Any suggestion pls.
    Thanks,
    Siva 

    Hi,
    Please run the below script and see if it serves your requirement.
    DECLARE @TableA TABLE
    ID INT,
    NAME VARCHAR(10)
    INSERT INTO @TableA 
    VALUES   (1, 'James')
    ,(2, 'Ramz')
    ,(3, 'Chandu')
    ,(4, 'Suraj')
    SELECT *
    FROM @TableA
    DECLARE @TableB TABLE
    ID INT,
    NAME VARCHAR(10)
    INSERT INTO @TableB 
    VALUES   (1, 'James')
    ,(2, 'Ramz')
    ,(3, 'Chandu')
    ,(4, 'Suraj')
    ,(5, 'Krishna')
    ,(6, 'John')
    SELECT *
    FROM @TableB
    Now as per your requirement, you need to insert rows 5 & 6 from TableB into TableA
    INSERT INTO @TableA
    SELECT Tab1.* 
    FROM @TableB Tab1
    LEFT JOIN @TableA Tab2 ON Tab1.id = Tab2.id
    WHERE Tab2.id IS NULL
    The above query gives inserts the non-existing records 
    SELECT *
    FROM @TableA
    Thanks, Satish Chandra

  • Sql Service and Databases won't start on two of my databases SQl 2005

    getting the errors below
    In Event viewer I have Event ID 17120 SQL Server Could not Spawn FRuncm thread check the sql server error log and the windows event logs for information about possible related problems.
    Event id 17826 Could not start the Network Library because of an internal error in the netwpork library. To determine the cause review the errors immediately preceding this one in the error log.
    Also Event id 17182 TDSSN1 Client initialization failed with error 0x2,
    status code 0x1
    I think this post could help me but I do not know
    what is the domain login account for the SQL service is in sql 2005.
    Please see the post below
    1. added our domain login account for the SQL service to the local group SQLServer2005MSSQLUser$HSPCSVR03$MSSQLSERVER
    2. added the domain login account for the Agent service to SQLServer2005SQLAgentUser$HSPCSVR03$MSSQLSERVER
    3. added both accounts to the local computer Administrators group.
    4. deleted C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat.I hope someone can help me with this. this broken Backup exec Database
    has become a nightmare. Two of the sql databases, both the bkup exec one and one called MS SQlserver will not start under services and the local system account or the Administrator account.
    Droid Hacker

    Hello,
    Did you refer to the folloing blog to troubleshooting this issue?
    Error Messages of SQL Server 2005 Start Up Failure
    According to the blog above, "TDSSNIClient initialization failed with error 0x2" , 0x2 is the OS error. Typing "net helpmsg 2" in command prompt return:The system cannot find the file sepcify. Status code 0x1 is general status code. You can review error
    log which start from error:17182 in SQL Server error log and mapping status code to specific problem.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Do I need Distributed Transaction Scope when I have Two Database in Single SQL Server Instance

    Dear Sirs.
    I have Two Database in SQL Server Express 2008 R2, I Move Row From Database 1 Table 1 to Database 2 Table 1
    Do I need Distributed Transaction or just regular Transaction.
    Thank you in Advance. 
    Irakli Lomidze

    Dear Sirs.
    I have Two Database in SQL Server Express 2008 R2, I Move Row From Database 1 Table 1 to Database 2 Table 1
    Do I need Distributed Transaction or just regular Transaction.
    Thank you in Advance. 
    Irakli Lomidze
    Whats you are doing does not qualify under distributed transaction. Please read about distributed transaction from below link
    http://technet.microsoft.com/en-us/library/ms188721%28v=sql.105%29.aspx
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • SQL Server 2012 - 3 SQL clustered instances - one default/ two named instances - how assign/should assign static ports for named instances

    We have two physical servers hosting 3 SQL 2012 clustered instances, one default instance and two named instances.
    The default instance is using port 1433 and the two named instances are using dynamic port assignment.
    There is discussion about assigning static port numbers to the two named clustered SQL instances.
    What is considered best-practice?  For clustered named instances to have dynamic or static ports?
    Are there any pitfalls to assigning a static port to a named instance that is a cluster?
    Any help is greatly appreciated

    Hi RobinMCBC,
    In SQL server the default instance has a listener which listens on the fixed port which is TCP port 1433. And for the named instance the port on which the SQL server listens is random and is dynamically selected when the named instance of the SQL server
    starts.
    For Standalone instance of the SQL server we can change the dynamic port of the named instance to the static port by using SQL server configuration manager as other post, however, in case of the cluster, when we change the port no. of the named instance
    to the static port using the method described above, the port no. again changes back to the dynamic port after you restart the services. I recommend you changing the Dynamic port of the SQL Server to static port 
    on all the nodes , disabling and enabling the checkpointing to the quorum.
    For more information, you can review the following article about how to change the dynamic port of the SQL Server named instance to an static port in a SQL Server 2005 cluster.
    http://blogs.msdn.com/b/sqlserverfaq/archive/2008/06/02/how-to-change-the-dynamic-port-of-the-sql-server-named-instance-to-an-static-port-in-a-sql-server-2005-cluster.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

Maybe you are looking for