Unfortunately i'm not able to provide too much information regarding this possible bug. This is occurring on a clients machine in which i do not have access to, and am unable to get a copy of the data locally to test due to our agreement.
I have generated a script locally and it works fine. When generating on the clients database which is the same structurally, just more data, the following error is occurring:
Msg 137, Level 15, State 1, Line 1506
Must declare the scalar variable "@pv".
On basic inspection of the script the DECLARE @pv is at the top of the script, however the error is possibly due to the declaration out of scope.
It is a basic comparison with no default options changed, between a database and an another database which is the same but is empty.
The error emailed by the client is on the following lines:
- Code: Select all
EXEC(N'INSERT INTO [dbo].[doc_DocumentData] ([DocumentID], [DocumentText], [DocumentDescription], [DocumentTextPrivate], [FileExt], [ModifiedDate], [DocumentSiteID]) VALUES (1595, 0x1111111111111111111111111111111111, '''', 0x11111111111111111111111111111111111111111111111111111111111'
+N'111111111111111111111, ''.htm'', ''2008-12-16 15:47:11.410'', NULL)')
SELECT @pv=TEXTPTR([DocumentTextPrivate]) FROM [dbo].[doc_DocumentData] WHERE [DocumentID]=1595
UPDATETEXT [dbo].[doc_DocumentData].[DocumentTextPrivate] @pv NULL NULL 0x11111111111111111111111111
EXEC(N'INSERT INTO [dbo].[doc_DocumentData] ([DocumentID], [DocumentText], [DocumentDescription], [DocumentTextPrivate], [FileExt], [ModifiedDate], [DocumentSiteID]) VALUES (1596, 0x111111111111111111111111111111111111, '''', 0x111111111111111111111, ''.htm'', ''2008-12-17 14:06:41.520'', NULL)')
The solution was to add a 2nd declaration of @PV just above where the error was occurring.
Sorry i am unable to provide any further details.