Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL 2008 to SQL2005

SQL 2008 to SQL2005

Scheduled Pinned Locked Moved Database
helpsharepointdatabasetoolsannouncement
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jojoba2011
    wrote on last edited by
    #1

    When i get the script from sql 2008 to sql 2005 without any error it finish. when i wanna to execute the script in sql2005 i get this error :

    Msg 139, Level 15, State 1, Procedure Language_Update, Line 0
    Cannot assign a default value to a local variable.
    Msg 137, Level 15, State 2, Procedure Language_Update, Line 9
    Must declare the scalar variable "@param".

    this is the part of script :

    /****** Object: StoredProcedure [dbo].[Language_Update] Script Date: 04/23/2012 11:39:57 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[Language_Update]

    (@LanguageId SmallInt , @Language NVarChar(50))
    AS
    BEGIN
    declare @param nvarchar(1000)= N'update [Common].[Language] set '
    if @Language is not NULL
    BEGIN
    set @param = @param + '[Language]=''' + @Language + ''','
    End
    set @param= substring(@param,0,len(@param))
    set @param = @param + ' Where LanguageId=''' + cast( @LanguageId as nvarchar(5)) + ''' '
    exec sp_executesql @param
    END
    GO

    take attention that the script is about 77000 line and i have about 200 of this type error. Please Help !

    B J 3 Replies Last reply
    0
    • J jojoba2011

      When i get the script from sql 2008 to sql 2005 without any error it finish. when i wanna to execute the script in sql2005 i get this error :

      Msg 139, Level 15, State 1, Procedure Language_Update, Line 0
      Cannot assign a default value to a local variable.
      Msg 137, Level 15, State 2, Procedure Language_Update, Line 9
      Must declare the scalar variable "@param".

      this is the part of script :

      /****** Object: StoredProcedure [dbo].[Language_Update] Script Date: 04/23/2012 11:39:57 ******/
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      CREATE PROCEDURE [dbo].[Language_Update]

      (@LanguageId SmallInt , @Language NVarChar(50))
      AS
      BEGIN
      declare @param nvarchar(1000)= N'update [Common].[Language] set '
      if @Language is not NULL
      BEGIN
      set @param = @param + '[Language]=''' + @Language + ''','
      End
      set @param= substring(@param,0,len(@param))
      set @param = @param + ' Where LanguageId=''' + cast( @LanguageId as nvarchar(5)) + ''' '
      exec sp_executesql @param
      END
      GO

      take attention that the script is about 77000 line and i have about 200 of this type error. Please Help !

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      When you declare variable @param, set default value after declared. Do this replace: Old part of query

      declare @param nvarchar(1000)= N'update [Common].[Language] set '

      New part of query

      declare @param nvarchar(1000)
      set @param ='update [Common].[Language] set '


      I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post.

      1 Reply Last reply
      0
      • J jojoba2011

        When i get the script from sql 2008 to sql 2005 without any error it finish. when i wanna to execute the script in sql2005 i get this error :

        Msg 139, Level 15, State 1, Procedure Language_Update, Line 0
        Cannot assign a default value to a local variable.
        Msg 137, Level 15, State 2, Procedure Language_Update, Line 9
        Must declare the scalar variable "@param".

        this is the part of script :

        /****** Object: StoredProcedure [dbo].[Language_Update] Script Date: 04/23/2012 11:39:57 ******/
        SET ANSI_NULLS ON
        GO
        SET QUOTED_IDENTIFIER ON
        GO
        CREATE PROCEDURE [dbo].[Language_Update]

        (@LanguageId SmallInt , @Language NVarChar(50))
        AS
        BEGIN
        declare @param nvarchar(1000)= N'update [Common].[Language] set '
        if @Language is not NULL
        BEGIN
        set @param = @param + '[Language]=''' + @Language + ''','
        End
        set @param= substring(@param,0,len(@param))
        set @param = @param + ' Where LanguageId=''' + cast( @LanguageId as nvarchar(5)) + ''' '
        exec sp_executesql @param
        END
        GO

        take attention that the script is about 77000 line and i have about 200 of this type error. Please Help !

        J Offline
        J Offline
        jojoba2011
        wrote on last edited by
        #3

        Thanks for Help!
        But its about 200 to 500 of this items!

        How can i do that ? and why doesn't the SQL create correct scripts.

        M L 2 Replies Last reply
        0
        • J jojoba2011

          Thanks for Help!
          But its about 200 to 500 of this items!

          How can i do that ? and why doesn't the SQL create correct scripts.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          How/where is SQL Server generating the script from? Try doing a search and replace ') = N' with '): Set @Update =N'

          Never underestimate the power of human stupidity RAH

          1 Reply Last reply
          0
          • J jojoba2011

            When i get the script from sql 2008 to sql 2005 without any error it finish. when i wanna to execute the script in sql2005 i get this error :

            Msg 139, Level 15, State 1, Procedure Language_Update, Line 0
            Cannot assign a default value to a local variable.
            Msg 137, Level 15, State 2, Procedure Language_Update, Line 9
            Must declare the scalar variable "@param".

            this is the part of script :

            /****** Object: StoredProcedure [dbo].[Language_Update] Script Date: 04/23/2012 11:39:57 ******/
            SET ANSI_NULLS ON
            GO
            SET QUOTED_IDENTIFIER ON
            GO
            CREATE PROCEDURE [dbo].[Language_Update]

            (@LanguageId SmallInt , @Language NVarChar(50))
            AS
            BEGIN
            declare @param nvarchar(1000)= N'update [Common].[Language] set '
            if @Language is not NULL
            BEGIN
            set @param = @param + '[Language]=''' + @Language + ''','
            End
            set @param= substring(@param,0,len(@param))
            set @param = @param + ' Where LanguageId=''' + cast( @LanguageId as nvarchar(5)) + ''' '
            exec sp_executesql @param
            END
            GO

            take attention that the script is about 77000 line and i have about 200 of this type error. Please Help !

            J Offline
            J Offline
            jojoba2011
            wrote on last edited by
            #5

            Thanks! but this is not good trick! and no use in here cause i have different parameters; this was example @Param.

            1 Reply Last reply
            0
            • J jojoba2011

              Thanks for Help!
              But its about 200 to 500 of this items!

              How can i do that ? and why doesn't the SQL create correct scripts.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              jojoba2011 wrote:

              and why doesn't the SQL create correct scripts

              It did. You generated them on Sql2008, and thus it will use all the language-features available for 2008. If you wanted to be compatible with Sql2005, you'd generate them from there. Put your database in compatibility mode (Google knows how) and try to script again.

              Bastard Programmer from Hell :suss:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups