@pv variable declared outside of query batches

Compares and synchronizes SQL database content.

@pv variable declared outside of query batches

Postby mcdrewski » Thu Jun 19, 2014 4:31 am


I'm trying to do a large and complex synchronisation, and generate a script. When I do so i get something looking like this (the other 30Mb or so is snipped)

Code: Select all

Run this script on:
(local).DEST    -  This database will be modified
to synchronize it with:
You are recommended to back up your database before running this script
Script created by SQL Data Compare version 10.7.0 from Red Gate Software Ltd at 19/06/2014 2:09:49 PM

-- Pointer used for text / image updates. This might not be needed, but is declared here just in case
DECLARE @pv binary(16)

PRINT(N'Drop constraints from [dbo].[TABLEA]')


EXEC(N'INSERT INTO [dbo].[TABLEX] ([BAR], [FOO]) VALUES (231, ''...firstpart...'')')
UPDATETEXT [dbo].[TABLEX].[FOO] @pv NULL NULL N'...secondpart...'


the problem is that @pv is declared before the "GO" is issued (actually, there are multiple "GO" commands), and as such is out of scope when referred to later. This seems like a fairly clearcut bug to me. Any ideas on workarounds other than manually editing the script?

I'm using SQLServer 2012 FYI
Posts: 3
Joined: Sun Nov 12, 2006 11:48 pm

Postby Brian Donahue » Thu Jun 19, 2014 9:47 am

The variable @pv used for BLOB handles is scoped to batches in T-SQL, so it goes out of scope when a batch ends with a GO. The problem was identified a few times and fixed, and it looks like the particular root cause of this in v10 (SDC-1682) will be fixed in v11 when it comes out. I can let you know when it's out or there is a beta.
Brian Donahue
Posts: 6590
Joined: Mon Aug 23, 2004 9:48 am

Return to SQL Data Compare Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests