SQL 2008 T-SQL

  • Pretty Good question! I liked it. Shows off some of the new enhancements in SQL2008...:-)

  • Interesting behaviour. If you change the last SET line to SET @msg = @msg+@msg+@msg then you get 111111 (at least you do with SQL Server 2005 SP3). Strange that you get an implicit conversion for multiplication but not for addition, which is interpreted as concatenation. I think I'd feel more comfortable if the multiplication failed with a "cannot convert" error.

    John

  • It will actually generate an error.

  • anil

    the statement below is same for sql server 2005

    DECLARE @i AS INT

    .

    .

    set @i =100;

    .

    .

    SET @i =@i +25;

    The difference in the statementl are:

    DECLARE @i AS INT = 100 which combines the DECLARE and SET statements

    SET @i +=25; --here the is no need to repeat the @i parameter

    Combined these new features allow for less typing, and more readable code.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • When u declaring local variable at the same statement u can't assign a value

    e.g Declare @i as int = 100

    it will give error,

    u have to declare like

    Declare @i as int

    set @i=100

  • sur_manpower (8/31/2009)


    When u declaring local variable at the same statement u can't assign a value

    e.g Declare @i as int = 100

    it will give error,

    u have to declare like

    Declare @i as int

    set @i=100

    to clarify - in SQL 2005 you can't

    Declare @i as int = 100

    But in SQL 2008 you can.

  • This is a new feature in SQL 2008

  • Easy one!

  • Hi,

    I am having the same sort of problem, however with a linked server. We have a linked server setup to a Sybase server. Use the Sybase 15 SDK. Connection is using Microsoft ole db provider for ODBC. Works fine in SQL 2005. In SQL 2008 however I keep getting.

    An error occurred while executing batch. Error message is: Invalid attempt to GetBytes on column 'Date'. The GetBytes function can only be used on columns of type Text, NText, or Image.

    The only workaround I have is to either set the database compatibility level in SQL 2008 back to 90, and it works fine, or to convert the datetime field in my openquery statement before it comes back to SQL 2008. Ideally we don't want to set the database compatibility level back to 90, and would like to keep at 100.

    Any ideas?

    Jeremy

Viewing 9 posts - 16 through 23 (of 23 total)

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