INSERT OUTPUT

  • good question!!!!


    [font="Times New Roman"]rfr.ferrari[/font]
    DBA - SQL Server 2008
    MCITP | MCTS

    remember is live or suffer twice!
    the period you fastest growing is the most difficult period of your life!
  • Love the question. No tricks and a back-to-the-basics one.

    I was expecting a few BEGIN/ROLLBACK TRANSACTION commands in there to make it a little trickier but it turns out it was a very nice straightforward question. Thank you for that.

    Best regards,

    Andre Guerreiro Neto

    Database Analyst
    http://www.softplan.com.br
    MCITPx1/MCTSx2/MCSE/MCSA

  • Where is the DATE datatype in sql server??????????

    CREATE TABLE mytesttable

    (

    MyID INT IDENTITY

    , mychar VARCHAR(20)

    , mydate DATE DEFAULT GETDATE()

    )

    DECLARE @mytable TABLE ( i INT, d DATE);

    INSERT dbo.mytesttable (mychar)

    OUTPUT INSERTED.myid, INSERTED.mydate INTO @mytable

    VALUES ( 'First Row')

    SELECT i, d FROM @mytable

  • monpara.sanjay (2/8/2012)


    Where is the DATE datatype in sql server??????????

    In all versions since SQL Server 2008.

    You are aware that mainstream support for SQL Server 2005 has already ended, are you? I'd consider upgrading, if I were you... :hehe:


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • monpara.sanjay (2/8/2012)


    Where is the DATE datatype in sql server??????????

    Here: DATE (Transact-SQL)

    It's been around for four years or so now 🙂

  • Thanks to clarify

    I am using SQL Server 2005.

  • monpara.sanjay (2/8/2012)


    Thanks to clarify

    I am using SQL Server 2005.

    That was already clear 😛

    Steve said it well a few posts back...

    Steve Jones - SSC Editor (2/2/2012)


    SQL 2005 is out of support, over 5 years old. At this point, you should have heard of DATE as a data type. If not, you should be learning what's new, or slightly new.

  • Hugo Kornelis (2/8/2012)

    You are aware that mainstream support for SQL Server 2005 has already ended, are you? I'd consider upgrading, if I were you... :hehe:

    You're right that the ideal situation is to always have the most current version of the server software installed; however, some of us work with organizations and customers that have outdated hardware and software and we must use what is available.

    We do not always have the option of telling our clients they must use the latest server software version or we cannot work on their project. Most of my clients are set with what they have and the timeframes and budget constraints prohibit any server software upgrades.

    To maintain my client list, I must be fluent in several server types including MySQL, Oracle, MS SQL Server, and even Teradata. My clients cannot easily change their server types or versions without it being a major undertaking. Besides, there's a lot of debate out there as to which server software is better and I'm not going to start debating that with my clients.

    I make more money ($/hour wise) when I work with small companies that are using older software than I do with large enterprises that have the most up-to-date versions. The smaller companies don't have the budget dollars to keep upgrading their software nor do they have the money to keep a DBA on staff. So, when one is needed, they pay top dollar for services. Larger companies keep DBA's on staff with an annual salary and that's significantly less pay.

  • Its right, cengland0

    and This forum should want to define minimum version to use in question.

  • cengland0 (2/8/2012)


    Hugo Kornelis (2/8/2012)

    You are aware that mainstream support for SQL Server 2005 has already ended, are you? I'd consider upgrading, if I were you... :hehe:

    You're right that the ideal situation is to always have the most current version of the server software installed; however, some of us work with organizations and customers that have outdated hardware and software and we must use what is available.

    Hence the word 'consider'. The wider point is that whatever versions of SQL Server we work with, it makes sense to at least be aware that things like DATE exist.

  • monpara.sanjay (2/8/2012)


    and This forum should want to define minimum version to use in question.

    The site editor already gave his reasons for not specifying a minimum version. At least you will know next time.

  • cengland0 (2/8/2012)


    Hugo Kornelis (2/8/2012)

    You are aware that mainstream support for SQL Server 2005 has already ended, are you? I'd consider upgrading, if I were you... :hehe:

    You're right that the ideal situation is to always have the most current version of the server software installed; however, some of us work with organizations and customers that have outdated hardware and software and we must use what is available.

    We do not always have the option of telling our clients they must use the latest server software version or we cannot work on their project. Most of my clients are set with what they have and the timeframes and budget constraints prohibit any server software upgrades.

    To maintain my client list, I must be fluent in several server types including MySQL, Oracle, MS SQL Server, and even Teradata. My clients cannot easily change their server types or versions without it being a major undertaking. Besides, there's a lot of debate out there as to which server software is better and I'm not going to start debating that with my clients.

    I make more money ($/hour wise) when I work with small companies that are using older software than I do with large enterprises that have the most up-to-date versions. The smaller companies don't have the budget dollars to keep upgrading their software nor do they have the money to keep a DBA on staff. So, when one is needed, they pay top dollar for services. Larger companies keep DBA's on staff with an annual salary and that's significantly less pay.

    All true.

    Please note that I never said that a SQL Server professional should work hard to forget SQL Server 2005 functionality. On the contrary, do foster taht knowledge!

    But what I do say, is that any SQL Server professional should work hard to get knowledge of supported versions as well. With Developer Edition available for a mere 50 or so bucks and able to be installed on any reasonably modern laptop or desktop (and Express Edition available in case even Developer Edition is too expensive), there really is no excuse for not getting yourself acquainted with newer versions. You may be stuck supporting SQL Server 2005 now - but one day, your company might want to upgrade. Or you may be forced to look for another job. And having your knowledge stuck at a version that's been out for almost seven years now, that is out of mainstream support, and that has been superseded by two new versions (2008 and 2008R2 count as seperate versions), plus another one around the corner - that does not look good on your resume!

    So I disagree that the minimum version should be included in all QotD questions. I think we should all assume that questions apply to supported versions of SQL Server, unless stated differently.

    (And if you think differently, then there are lots and lots of questions where I could comment that it does not apply to SQL Server 6.5. Or 4.2. Or even 1.0 (though I would have trouble verifying the last two claims).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • While I may want to have Sql Server 2012 when it comes out, I know that it most likely will not happen and I should be content with the 2008R2 upgrade I received last spring (from 2000). I actually have to work with MSDE for some projects that code is needed for.

    I can see both sides of the reasoning for explaining what version was needed.

    However; as a learning tool, maybe we should have explanations of the reasons why people may get the wrong answers or errors, which could get extended to people learning more about the new features available and could push upgrades

    That said, in Sql2000 you get a different error: "Line 11: Incorrect syntax near 'OUTPUT'."

    Also, I feel the QOTD should also remove any objects it creates.

    Director of Transmogrification Services
  • A somewhat educated guess and I got it right!

    http://brittcluff.blogspot.com/

  • Hugo Kornelis (2/8/2012)


    So I disagree that the minimum version should be included in all QotD questions. I think we should all assume that questions apply to supported versions of SQL Server, unless stated differently.

    My view on this. If it's specific to one supported version, i.e. SQL Server 2008 R2, but not SQL Server 2008, the version should be included. If it's either of those versions, then no version need be included.

    We may ask SQL 2005 compliant questions, but no guarantees.

Viewing 15 posts - 46 through 60 (of 62 total)

You must be logged in to reply to this topic. Login to reply