Alternative for Cursor in SQL Server 2012

Hi all,
  I keen to know Alternative for Cursor in SQL Server 2012. Why everyone telling Cursor have performance impact. Any other alternative for row by row comparison like Array in SQL 2012 ?
Thanks

It is not the cursor that kills you - it is the loop as such. I've seen more than one example of a poor man's cursor, where they have selected TOP 1 from a #temp ORDER BY, and several operations on the temp table - which is completely void of indexes,
making the operations for the loop control the slowest in the batch. So you use cursor when you need to iterate.
But in many cases, you should work and think set-based instead.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Using WMI alert for mirroring in Sql server 2012

    We are using mirroring in Sql Server 2012  and we are using WMI alerts for some of events such as Connection lost,Manual failover,...
    In alert definition we have set the followings:
    Type: WMI event alert
    NameSpace:
    \\.\root\Microsoft\SqlServer\ServerEvents\MSSQLSERVER
    Query: select * from DATABASE_MIRRORING_STATE_CHANGE where State = 6
    The alert is bing triggered correctly,but on email description instead of having meaningful explaination like 'Connection lost',We have the same query:
    Query: select * from DATABASE_MIRRORING_STATE_CHANGE where State = 6
    We have used the same implementation in our Sql Server 2008 servers and it is working fine.This mashine (Sql Server 2012) is a new mashine.
    I would appreciate if someone help me on this.AlsoI checked and 'Include body of e-mail in notification message' was already set.
    Thanks
    Aspet
    A.G

    Are you looking for alerting related to mirroring like below ?
    http://www.mssqltips.com/sqlservertip/1859/monitoring-sql-server-database-mirroring-with-email-alerts/
    http://technet.microsoft.com/en-us/library/cc966392.aspx
    Raju Rasagounder Sr MSSQL DBA

  • How to do Ad-hoc reports with SSRS 2012 (Report Builder 3.0) for the database SQL Server 2012

    <p>Hi,</p><p>Please could anybody help me how to do ad-hoc reports by using SSRS 2012.</p><p>I am able to create ad-hoc reports using Report Builder3.0 and SQL Server 2008 R2. </p><p>I have built the report Model
    in for the instance 2008 R2&nbsp;</p><div class="t-paste-container">Using Report Manager 2012 </div>

    Hi Gowri,
    From your description, you can create create ad-hoc reports using Report Builder 3.0 and SQL Server 2008 R2, and now you want to know how to how to do ad-hoc reports by using SSRS 2012, right? In SQL Server 2012, the default version of Report Builder is
    3.0, so you can create create ad-hoc reports using Report Builder 3.0 as before.
    If you have any questions, please feel free to ask.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How can I make one computer server at Home for access of SQL Server 2012/2008

    Hi All,
    Sorry for this basic question but I am zero in networking. I will be very grateful if someone guides what should I do to make one of my home PC as server. Scenario is as follows:
    I want to give training to few students about SQL SERVER T-SQL.
    I have one Laptop using SQL Server 2012 having Windows 7 Pro(Laptop Master-want to make this server). I have other laptop running Windows 7 pro and got SQL SERVER 2008. My students have mix of laptops including Windows XP, Windows Vista, Windows 7 and Windows
    8. All students have SQL SERVER 2008 installed and working.
    Q1: I actually want to make Laptop Master(explained in above paragraph) as server and want other laptops to access that master server in home network. I will install sample exercise database on server and students will be writing queries to access
    data.
    Q2: can I secure sample database from students who can copy sample database from server?
    Q3: can students run queries remotely sitting their home?
    Thanks in advance.
    Kind Regards
    A K
    Adnan

    Hi itsadnan,
    According to your description, if you want to make your Laptop as Server, and your student can log in your SQL Server 2012 instance, you need to ensure that your computer and student’s computers are the same domain, and you enable TCP/IP, name pipes protocol
    in SQL Server Configuration Manager, your SQL Server 2012 instance is allowed to connect remotely and your student install SQL Server Manager Studio 2012 as client tool in their computer, and you create the related login name for your students. For more information,
    see:
    http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
    According to your requirement, in actual, since your students install SQL Server 2008 on their computer, you totally can ask your student to install the sample exercise database in their SQL Server. For example, there are many resource about sample database
    in Website, which is helpful for student to learn database technology, such as
    AdventureWorks databases for SQL Server 2008. From SQL Server Management Studio, they can attach an AdventureWorks database, then write queries to access data.
    Since you have SQL Server 2008 in your other laptop, you can create the sample exercise database, and student can install this database via backup and restore, then write queries to access data and send to you for checking if it is right.
    Note:  Due to backwards compatibility, The students could not restore SQL Server 2012 database in their SQL Server 2008 instance.
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • No tabular entries appear under BI for SSDT in SQL Server 2012 SP1

    Missing "Analysis Services Tabular Project", "Import From PowerPivot" and "Import From Server (Tabular)"
    under BI/Analysis for SSDT 2012 SP1 using VS 2010 shell. I created a separate instance for Tabular. I see all selections in VS2012 but the book I'm using refers to the VS2010 shell which I would prefer to use. I've repaired all instances and reinstalled SSDT
    all to no avail.

    Hello,
    We can download Business Intelligence for Visual Studio 2012 from the site below:
    http://www.microsoft.com/en-us/download/details.aspx?id=36843
    Here are the steps to install Business Intelligence templates for VS 2012:
    http://msdn.microsoft.com/en-us/library/jj856966(v=sql.110).aspx
    If you have any feedback on our support, please click
    here.
    Regards 
    Elvis Long
    TechNet Community Support

  • SQL Server 2012 Change Data Capture for Oracle by Attunity support for Oracle 12

    I would like to know if there are any plans for SQL Server 2012 Change Data Capture for Oracle by Attunity to support versions of Oracle 12 and if by when.

    I have asked from the author of
    http://blogs.msdn.com/b/mattm/archive/2012/03/26/cdc-for-oracle-in-sql-server-2012.aspx about this.
    I will either ask him to answer here or I would be a messenger.
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • SQL Server 2012 support

     Does anyone know of any official statements regarding the running of SharePoint Server 2007 over SQL Server 2012?  Or if no official statements, has anyone tried it yet?
    Actually, I have the same question with regard to Windows Server 2012, if anyone knows anything about SharePoint Server 2007 support for that as well.
    Thanks.

    I haven't heard of any news or information from Microsoft about plans for support of SQL Server 2012 or Windows Server 2012 with SharePoint 2007, so the best source that I know to look at is their official TechNet documentation on software requirements for
    the platform:
    http://technet.microsoft.com/en-us/library/cc262485(v=office.12).aspx. That article states that it is supported on SQL Server versions 2000 through 2008 R2 and Windows Server versions 2003 through 2008 R2, as long as you keep SharePoint 2007 updated to
    the proper service packs to support the given version (believe the R2 versions of the 2008 OS and Database engine both require at least SharePoint 2007 Service Pack 2).
    There's not any information on the Service Pack 3 that indicates that it includes compatibility with the 2012 releases of Windows Server and SQL Server, so I don't think that's a possibility.
    This is just my opinion, but I really don't think you're going to see compatibility with the 2012 releases happening for SharePoint 2007, for a couple of reasons. First, Microsoft's focus is on SharePoint 2010 and potential future releases for the SharePoint
    platform. There are a lot of rumblings out there right now that vNext is rapidly approaching on the horizon, and in the past at times like this Microsoft has a track record of really not paying a whole lot of attention to vCurrent -1. The other reason is that
    from a business standpoint Microsoft like to structure its software so that when a customer does an upgrade of one platform or system they often have to bring others along for the ride as well. In this case, if you want SharePoint 2007 to use those new OS
    and SQL versions you're probably going to have to also upgrade SharePoint to 2010 to get it.
    I know it can be frustrating, but that's how Microsoft approaches things and if we want to use their software those are the rules we have to abide by.
    MCITP and MCTS: SharePoint, Virtualization, Project Server 2007
    My books on Amazon: The SharePoint 2010 Disaster Recovery Guide and
    The SharePoint 2007 Disaster Recovery Guide.
    My blog: My Central Admin.

  • Finalizing SQL Server 2012 SP2 update

    Hi,
       I just successfully upgraded SQL Server 2012 Developer Edition from SP1 CU8 to SP2.
       Here is the actual portrait I have in my control panel (Installed programs + version):
           Version changed after SP2 update (through Windows Update):
             Microsoft SQL Server 2012 Express LocalDB                          11.2.5058.0
            Microsoft SQL Server 2012 Transact-SQL ScriptDom              11.2.5058.0
            Microsoft SQL Server 2012 Transact-SQL Compiler Service    11.2.5058.0
            Microsoft SQL Server 2012 Native Client                                11.2.5058.0
            Microsoft SQL Server 2012 Policies                                        
    11.2.5058.0
            Microsoft SQL Server 2012 Setup (English)                            11.2.5058.0
            Microsoft VSS Writer for SQL Server 2012                              11.2.5058.0
            Microsoft System CLR Types for SQL Server 2012                  11.2.5058.0
            SQL Server Browser for SQL Server 2012                               11.2.5058.0
          Version changed only after installing corresponding Features Pack component:
             Microsoft SQL Server 2012 T-SQL Language Service              11.2.5058.0    
             SQL Server Report Builder 3 for SQL Server 2012                  11.2.5058.0
             Microsoft SQL Server 2012 Management Objects                   11.2.5058.0
          Version did not change:
             Microsoft SQL Server System CLR Types                                10.51.2500.0
             Microsoft SQL Server 2012 Data-Tier App Framework            11.1.2902.0
    My questions:
    1. Am I missing any components update or is my actual SP2 setup OK?
    2. Even if I tried to install DACFramework SP2 Feature pack by running corresponding installer, it told me that I had an higher version...  Does any of you have a different version number for this component?
    3. I actually have SSDT for VS2010 installed.  The corresponding versions I actually have are the following:
               Microsoft SQL Server Data Tools 2010                                 
    10.3.31009.2
               Microsoft SQL Server Data Tools - enu                                 
    10.3.31009.2
               Microsoft SQL Server Data Tools Build Utilities - enu             10.3.31009.2
        Should I consider upgrading any component so they work with SQL 2012 SP2 properly?  If so, could someone provide me the corresponding download/webpage links?
    4. Finally, should I upgrade to CU2 which is actually available. Among other problems, I notice that it should fix an index rebuild problem.  Any other major issues it targets?  Is there any easy way I can test if I should install this update or
    not?
    Thanks for helping.

    Hi again,
      I knew I was at SP2 level now.  My request is more about the Features Pack components as well as the CU2 which is actually out:
    1- Features Pack components that I couldn't update:
             Microsoft SQL Server System CLR Types                                10.51.2500.0    
    --> presume was for VS2008
             Microsoft SQL Server 2012 Data-Tier App Framework            11.1.2902.0       --> is this the real last version?
    2- SQL Server Data Tools vs Visual Studio 2010 SP1 + SQL Server 2012 SP2
               Microsoft SQL Server Data Tools 2010                                 
    10.3.31009.2
               Microsoft SQL Server Data Tools - enu                                 
    10.3.31009.2
               Microsoft SQL Server Data Tools Build Utilities - enu             10.3.31009.2
        Do I have the last versions possible (VS2010) or should I update something?
    3- SQL Server 2012 SP2 CU2
        What simple test can I do in order to verify if I really need to install this patch or not?
    Thanks for helping!

  • SQL Server 2012 Express SP1 will not install on Windows Server 2012 Essentials R2

    I have been attempting to install SQL Server 2012 with SP1 Express Edition for about a two weeks and have been unsuccessful.  My organization recently purchased a new Dell PowerEdge T320 Server (64 Bit) with Intel Xeon Proc.-E5-2420; 2.2Ghz, 32 Gb RAM,
    1 Tb RAID 5 H/D, and Windows Server 2012 R2 Essentials (preinstalled).  The server will be configured as an on premises server.  We are running a small church management application that requires SQL Server 2012 SP1 Express.  Per the direction
    of our application vendor, we downloaded the SQL Server 2012 SP1 Express file (SQLEXPRADV_x64_ENU.exe) from the Microsoft SQL Server Website.  We ran the file "As Administrator" and the SQL Server 2012 Setup program began. 
    We selected New SQL Server Stand-Alone Installation, successfully installed the needed Product Updates, and accepted the MS SQL Server 2013 Express License terms. 
    When the Feature Selection Page appeared we checked only the "Data Base Eng Services".  The
    Instance Configuration Page was displayed and we inserted a "Named Instance= Shelby",then pressed next.  On the
    Server Configuration Page the only change was setting the "sql server browser = automatic".  The Database Engine Configuration Page appeared
    and we inserted the following settings:1] Server Configuration Tab; a) mixed mode, b)inserted SQL Server Admin pswd, c) added current user as administrator: 2] Data Directories Tab; default/no changes: 3] User Instanced Tab; default/no
    changes: and 4] Filestream Tab; default/no changes.  Next the
    Reporting Services Configuration Page came up and the reporting services native mode was set to
    "install and configure".  The Error Reporting Page appeared and was left as the
    "default".  The SQL Server 2012 Setup program proceeded to Installation Progress Page and started to install. Just before the install program ended it displayed a message saying that there
    were errors and the Database Eng Services did not succeed. I uninstalled SQL Server 2012 SP1 Express three (3) times, ran Windows Update after every uninstall, attempted to install the Database Engine and got the same results.  Are there any patches or
    special procedures for correctly installing SQL Server 2012 SP1 Express on my hardware configuration or Windows Server 2012 Essentials R2?  Any insight would be greatly appreciated.

    Can you post the setup Summary and detail logs, which will help to figure out the problem? The details about the location can be found at https://msdn.microsoft.com/en-us/library/ms143702(v=sql.110).aspx
    Satish Kartan www.sqlfood.com

  • SCCM 2012 SP1 + WSUS + Server 2012 + SQL Server 2012

    Hi all;
    I installed SCCM 2012 with Sp1 for my site server and everything is going well.. And than i installed the WSUS role on my Windows Server 2012 and SCCM 2012 SP1 it gave an error message which is "Fatal Error: The schema version of the database is from a newer
    version of WSUS than currently installed.  You must either patch your WSUS server to at least that version or drop the database." My database server is SQL Server 2012... Do you know any pathc for WSUS or SQL Server 2012 doesnt support WSUS yet???
    Thank You...
    MCT

    Normally if you are going to install SCCM 2012 SP1 +Windows 2012 with SQL 2012, Then you better use the SQL 2012 sp1.
    also when you are installing the WSUS version 6.2 which come with server 2012 make sure you leave the default settings as it is. it shows in the below article.
    also when you are giving the path to save the WSUS contents make sure the drive you going to create the wsus folder and the place where you going to download the updates is having free disk space and its formatted with the NTFS volume. Also the service account
    you are using for this configuration should have the admin rights to the location of the wsus folder you going to create,
    Thanks
    Hasitha

  • SQL Server 2012 Evaluation (x64 bit) does not install

    Hi
    I downloaded the following files from the site:
    http://www.microsoft.com/download/en/details.aspx?id=29066
    SQLFULL_x64_ENU_Core.box
    SQLFULL_x64_ENU_Install.exe
    SQLFULL_x64_ENU_Lang.box
    i have  double-clicking the executable to SQLFULL_x64_ENU_Install.exe ,i got error popup box as below
    popup box name :Unloading the box
    error message:The application cannot find one of its required files,possibly it was unable to create it in the folder.please make sure that
    the folder in which application was downloaded is accessible and not read-only
    os : windows 7 home basic
    i am the adminstator in the machine and tried to copy the files to diffeent drives and click the exe
    but still its stays same error message
    can some one please suggest on next steps
    Thanks

    Hi sai sudeep,
    I know that you have downloaded the SQL Server 2012, but it wasn’t successful because the entire application contains more files and folders and not just three files (setup.exe, .box files). So, as Alberto Morillo said, you could download an ISO file for installing.
    Please pay attention to that a Service Pack 1 or higher is required on windows 7 for installing the SQL Server 2012.
    please refer to:
    Download Windows 7 Service Pack 1:
    http://www.microsoft.com/en-us/download/details.aspx?id=5842 .
    Hardware and Software Requirements for Installing SQL Server 2012:
    http://msdn.microsoft.com/en-us/library/ms143506(v=sql.110).aspx.
    How to install SQL Server 2012:
    http://msdn.microsoft.com/en-us/library/ms143219.aspx.
    Regards,
    Amy Peng
    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.

  • MS SQL Server 2012 SP2 post-installation error

    Hi all,
    Windows update gave me an option to install updates for my MS SQL Server 2012. One was the SP1 and the other was the SP2. During that time i selected both but in the end the update for 'Security Update for
    SQL Server 2012 Service Pack 1 (KB2977326)' failed and the update for 'Microsoft SQL Server 2012 Service Pack 2 (KB2958429)' succeeded.
    What i saw then when I run management studio and did a select top 100 rows command on a table I got the below error: 
    An error occurred while executing batch. Error message is: Method not found: 'System.String Microsoft.SqlServer.Management.Smo.Util.BytesToHexString(Byte[], Int32)'.
    This happens only for select statements. Edit and all other works fine. Does anybody know about this issue?
    Thanks for you time. :)

    Hi DBTheoN,
    We check whether a program is an add-in from "Programs and Features" based on experience. I understand it is a little hard.
    So, here I have another way to check which assemblies are being loading during the querying. That, we can follow these steps:
    Download
    Process Monitor
    Open Process Monitor and start monitoring
    Open SQL Server Management Studio, and then execute the query
    Stop the monitoring
    From Process Monitor, filter the result by Process name(ssms.exe), Event Class(File IO) and Path(End With .dll)
    Save it and share it with us
    Once I receive the log, I will help to analyze it.
    Thanks,
    Jinchun Chen

  • Can DPM 2012 R2 backup SQL Server 2012 AlwaysOn enabled databases

    Is it possible to use DPM 2012 R2 for backing up
    SQL Server 2012 AlwaysOn enabled databases ?
    Because if Alwayson configured for any Database , particular database is not available to select for backup.

    Hi,
    Yes, starting with DPM 2012 SP1 SQL AlwaysOn enabled databases can be protected as long as they are not part of sharepoint farm. DPM shows the Availability Groups under Cluster Group.
    You must explicitly add the system account NTAuthority\System or NT AUTHORITY\DPMRA to the Sysadmin group on SQL Server.
    Protecting SQL Server Data
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT]
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Installing SQL Server 2012 Developer Edition or wait for SP2?

    Hi everyone,
      I just received my copy of SQL Server 2012 Developer Edition I ordered.  As usual, before installing, I searched the web for any hint or other stuff on the subject.
      I first found that SP1 was already available.  Honestly I prefer installing using the last version available instead of upgrading.  I found the SP1 install package using the following web address:
    http://www.microsoft.com/fr-ca/download/details.aspx?id=35575
      Is this the right install package to use? 
      Now, still reading everything I could find on that SP1, I found stories about major issues with SP1. 
    Two examples I remember:
    http://connect.microsoft.com/SQLServer/feedback/details/770630
    http://support.microsoft.com/kb/2793634/en-us?wa=wsignin1.0
    Two others (not specifically related to SP1):
    http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/thread/a0da3372-ab3d-4af0-b4c4-0d47163e0e03/
    http://www.sqlperformance.com/2012/11/system-configuration/2012-cal-problems
      My question.  Should I wait for SP2?  If so, any target date when it should be available?
      If not, what would you recommend as the logic install sequence?  Should I look for any cumulative update(s)?  Any other "manual settings" I should consider?
      Finally, can someone guide me regarding what options I should choose while installing.  My main goal is to program/build C++, C# applications using VS2010 that will interface with SQL Server for data storage purposes (add/update/delete,
    batch update/delete) and reports.
    Hope to hear from someone.
    Stephane
    BTW:  My current setup is the following:
    Intel(R) Core(TM)2 CPU  [email protected]
    3.00 Go
    Vista Ultimate SP2 32bits
    Visual Studio 2010 Professional Edition (which will be upgraded to last SP once installed)

    Hi again,
      I proceeded with download of CU7.  On Microsoft's webpage, there are several files we can download:
    2012_SP1_DAC_CU7_2894115_11_0_3393_x86
    2012_SP1_AOrcleDes_CU7_2894115_11_0_3393_x86
    2012_SP1_AOrcleSer_CU7_2894115_11_0_3393_x86
    2012_SP1_PPExcel_CU7_2894115_11_0_3393_x86
    SQLServer2012_SP1_CU7_2894115_11_0_3393_x86
      Which one I should choose?
      Also, some people reported having problems installing this update. 
    http://blogs.msdn.com/b/sqlreleaseservices/archive/2013/11/19/cumulative-update-7-for-sql-server-2012-sp1.aspx
      Can you comment?
    Thanks again for helping,
    Stéphane

  • SQL Server 2012 Management Studio:In the Database, how to print out or export the old 3 dbo Tables that were created manually and they have a relationship for 1 Parent table and 2 Child tables?How to handle this relationship in creating a new XML Schema?

    Hi all,
    Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
    Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
    Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
    Problem #1) How can I print out or export these 3 dbo Tables?
    Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service. 
    --> Failed to retrieve data for this request. --> Invalid class.  Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
    to manage a service. --> Failed to retrieve data for this request. --> Invalid class.  .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates>   What causes this set of error messages? How can
    I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
    Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
    Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
    Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
    Thanks in advance,
    Scott Chang    

    In the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
    1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
    2) I don't know why you get that error, but any particular reason you want to run PowerShell?
    4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
    As for left/right join, notice that these two are equivalent:
    SELECT ...
    FROM   a LEFT JOIN b ON a.col = b.col
    SELECT ...
    FROM   b RIGHT JOIN a ON a.col = b.col
    But please never use RIGHT JOIN - it gives me a headache!
    There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
    Here is an example where you can study the different join types and how they behave:
    CREATE TABLE apple (a int         NOT NULL PRIMARY KEY,
                        b varchar(23) NOT NULL)
    INSERT apple(a, b)
       VALUES(1, 'Granny Smith'),
             (2, 'Gloster'),
             (4, 'Ingrid-Marie'),
             (5, 'Milenga')
    CREATE TABLE orange(c int        NOT NULL PRIMARY KEY,
                        d varchar(23) NOT NULL)
    INSERT orange(c, d)
       VALUES(1, 'Agent'),
             (3, 'Netherlands'),
             (4, 'Revolution')
    SELECT a, b, c, d
    FROM   apple
    CROSS  JOIN orange
    SELECT a, b, c, d
    FROM   apple
    INNER  JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    LEFT   OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    RIGHT  OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    FULL OUTER JOIN orange ON apple.a = orange.c
    go
    DROP TABLE apple, orange
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for

  • Custom 404-page for a single directory ?

    Is it possible to change the 404 error response for a single directory (and ist subdirectories)? Like I can do with a ".htaccess" - file on an apache webserver? I know it's possible to do it global with weblogic.httpd.errorPage.xxx=URL in weblogic.pr

  • Service Order Creation through Sales Order...

    Hello, I got one requirement it is , we need to copy the account assignment (WBS element ) from sales order line item to service order line item . Morever same wbs element should be used to create automatic settlement rule in service order. This shou

  • How to turn off ken burns effect in new imovie

    The new iMovie---11--  how in the heck do I turn off the Ken Burns effect? Nothing against Mr Burns but.... I don't want everything to move! Thanks!

  • Is there any text table for t005...urgeny

    hi, is there any text table for t005...wat is the field to diplay country name in output...Ex: " england"

  • No Pass-by-Value or Copy Constructors

    After having used AS3 for some months now, I've realized that there is no pass-by-value option when passing variables into functions. The only option is pass-by-reference. Similarly, there are no default copy constructors. So, if I want to create a c