issue with mssql spatial extensions...
johnwebbcole
Posts: 8
I've packaged a databse that uses mssql spatial extensions (http://www.codeplex.com/MsSqlSpatial) on 2005 sp2 and I'm getting the following error when I run the package:
http://www.codeplex.com/MsSqlSpatial
<SQLError Package="HUDNPS"><Error>Line 1: Length or precision specification 0 is invalid.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
Incorrect syntax near the keyword 'EXTERNAL'.</Error><Assembly>HUDNPSStore1</Assembly><Package>Package2.resx</Package><Batch>Batch1204</Batch><SQL>CREATE FUNCTION [ST].[MPointFromText] (@wkt [nvarchar] (0), @srid [int]=N'-1')
RETURNS [varbinary] (max)
WITH EXECUTE AS CALLER
EXTERNAL NAME [MsSqlSpatialLibrary].[UserDefinedFunctions].[MPointFromText]</SQL></SQLError>
From what I can tell, this is the correct syntax for this function. How can I get this DB loaded using Packager 5?
Thanks,
John Cole
http://www.codeplex.com/MsSqlSpatial
<SQLError Package="HUDNPS"><Error>Line 1: Length or precision specification 0 is invalid.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
Incorrect syntax near the keyword 'EXTERNAL'.</Error><Assembly>HUDNPSStore1</Assembly><Package>Package2.resx</Package><Batch>Batch1204</Batch><SQL>CREATE FUNCTION [ST].[MPointFromText] (@wkt [nvarchar] (0), @srid [int]=N'-1')
RETURNS [varbinary] (max)
WITH EXECUTE AS CALLER
EXTERNAL NAME [MsSqlSpatialLibrary].[UserDefinedFunctions].[MPointFromText]</SQL></SQLError>
From what I can tell, this is the correct syntax for this function. How can I get this DB loaded using Packager 5?
Thanks,
John Cole
Comments
It sounds like you have an assembly, and the database that you are migrating to isn't capable of running the script to migrate that assembly for some reason.
Does this assembly need an asymmetric key in the database, or have the database set to allow UNSAFE? Packager can't migrate keys and I don't think it supports all database settings, and I think you may be able to get it to work by running ALTER DATABASE SET TRUSTWORTHY ON to allow external assemblies to run.
RedGate scripted the CLR function as:
but MSSQL throws this error:
Msg 1001, Level 15, State 1, Procedure GetRecordHistoryDataString, Line 2
Line 2: Length or precision specification 0 is invalid.
Msg 319, Level 15, State 1, Procedure GetRecordHistoryDataString, Line 3
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
Msg 156, Level 15, State 1, Procedure GetRecordHistoryDataString, Line 4
Incorrect syntax near the keyword 'EXTERNAL'.
If I use MS SQL script the function it scripts it as:
This version works. Do you know why there is a difference with two versions, and if the RedGate Packager supports Creating CLR Functions?
http://msdn.microsoft.com/en-us/library/ms189876.aspx
Thank you for the help,
Greg Mack
Thanks!
I will get the 5.4 release and post what I find. Thanks for the tip.
Greg
After changing the line to it executes without error. I have found 2 more incidences and they are both within the create statement of Functions. One also contains it as a parameter:
I can make the changes to the project, but is there something I could do to get the packager to correct this for me?
Thank you for the help,
Greg
I hope this helps.
Greg