Autoi Restore - Litespeed

  • Ok, what you could do is to declare two variables:

    Declare @s-2 nvarchar(4000)

    Declare @s1 nvarchar(4000)

    After this line:

    set @s-2 = @s-2 + '"' + @dfname + '" to "' + @newdatapath + @dbname + '_' + @dfname + '_data' + @ext + '"'', @WITH = ''move '

    put this condition:

    if len(@s) >=3900

    begin

    set @s1= @s-2

    set @s-2= ''

    end

    in the end put

    print @s1

    print @s-2

    you would need to change this line:

    exec master..sp_executesql @s-2

    in order to run it or you can just concatenate the two printouts together and run it manually.

    Alternatively you can use declare @s-2 varchar(8000) and comment out

    the exec string.

    I am not sure if nvarchar(max) will work with sp_executesql, but you may try this as well.

  • instead doing this can we do with a cursor or some CTE's ?? just in case.

  • Yes you can. You can use a larger datatype to fit your script and then just print it out. However 8000 character should work for your immidiate needs as your original script is only 5000 characters.

  • Ok, nvarchar(max) should resolve all your problems. Just change @s-2 declaration:

    Declare @s-2 nvarchar(max)

  • This was removed by the editor as SPAM

  • I understand if you restore from one server to another with different drive and folder names, you would need to specify "with move" option. If the folder and drive structure is the same, you can restore without this option.

  • This was removed by the editor as SPAM

Viewing 7 posts - 16 through 22 (of 22 total)

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