I was getting the below error while trying to import the database into my DEV box which was originally exported from sandbox environment.
Error message:
*** Error importing database:Could not import package.
Error SQL72014: .Net SqlClient Data Provider: Msg 195, Level 15, State 10, Procedure AXPerf_CreateIndex, Line 1 'TRIM' is not a recognized built-in function name.
Error SQL72045: Script execution error. The executed script:
CREATE PROCEDURE [dbo].[AXPerf_CreateIndex]
@idxStmt NVARCHAR (MAX), @bypass BIT=0, @message NVARCHAR (MAX) OUTPUT, @returnStatus INT OUTPUT, @createdIdxStmt NVARCHAR (MAX) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
PRINT 'AXPerf_CreateIndex v1.0';
DECLARE @DoOpenCursorExistsOnObject AS INT = 0;
DECLARE @kstart AS INT, @kend AS INT, @istart AS INT, @iend AS INT, @isColStrIdx AS BIT, @IncColCount AS INT;
DECLARE @iName AS VARCHAR (1000), @fullyQualifiedTName AS VARCHAR (1000), @scName AS VARCHAR (20), @tName AS VARCHAR (128), @KeyCol AS VARCHAR (MAX), @IncCol AS VARCHAR (MAX);
SET @idxStmt = REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(@ idxStmt, CHAR(13), ' '), CHAR(10), ' '), CHAR(9), ' '), ' ', '<>'), '><', ''), '<>', ' ');
SET @kstart = CharINDEX('(', @idxStmt);
SET @kend = CharINDEX(')', @idxStmt);
SET @istart = CASE WHEN CharIndex('include', @idxStmt, @kend + 1) != 0 THEN CHARINDEX('(', @idxStmt, @kend + 1) ELSE 0 END;
SET @iend = CHARINDEX(')', @idxStmt, @kend
Error SQL72014: .Net SqlClient Data Provider: Msg 195, Level 15, State 10, Procedure AXPerf_CreateIndex, Line 1 'TRIM' is not a recognized built-in function name.
Error SQL72045: Script execution error. The executed script:
CREATE PROCEDURE [dbo].[AXPerf_CreateIndex]
@idxStmt NVARCHAR (MAX), @bypass BIT=0, @message NVARCHAR (MAX) OUTPUT, @returnStatus INT OUTPUT, @createdIdxStmt NVARCHAR (MAX) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
PRINT 'AXPerf_CreateIndex v1.0';
DECLARE @DoOpenCursorExistsOnObject AS INT = 0;
DECLARE @kstart AS INT, @kend AS INT, @istart AS INT, @iend AS INT, @isColStrIdx AS BIT, @IncColCount AS INT;
DECLARE @iName AS VARCHAR (1000), @fullyQualifiedTName AS VARCHAR (1000), @scName AS VARCHAR (20), @tName AS VARCHAR (128), @KeyCol AS VARCHAR (MAX), @IncCol AS VARCHAR (MAX);
SET @idxStmt = REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(@ idxStmt, CHAR(13), ' '), CHAR(10), ' '), CHAR(9), ' '), ' ', '<>'), '><', ''), '<>', ' ');
SET @kstart = CharINDEX('(', @idxStmt);
SET @kend = CharINDEX(')', @idxStmt);
SET @istart = CASE WHEN CharIndex('include', @idxStmt, @kend + 1) != 0 THEN CHARINDEX('(', @idxStmt, @kend + 1) ELSE 0 END;
SET @iend = CHARINDEX(')', @idxStmt, @kend
Error SQL72014: .Net SqlClient Data Provider: Msg 195, Level 15, State 10, Procedure AXPerf_CreateIndex, Line 1 'TRIM' is not a recognized built-in function name.
Error SQL72045: Script execution error. The executed script:
CREATE PROCEDURE [dbo].[AXPerf_CreateIndex]
@idxStmt NVARCHAR (MAX), @bypass BIT=0, @message NVARCHAR (MAX) OUTPUT, @returnStatus INT OUTPUT, @createdIdxStmt NVARCHAR (MAX) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
PRINT 'AXPerf_CreateIndex v1.0';
DECLARE @DoOpenCursorExistsOnObject AS INT = 0;
DECLARE @kstart AS INT, @kend AS INT, @istart AS INT, @iend AS INT, @isColStrIdx AS BIT, @IncColCount AS INT;
DECLARE @iName AS VARCHAR (1000), @fullyQualifiedTName AS VARCHAR (1000), @scName AS VARCHAR (20), @tName AS VARCHAR (128), @KeyCol AS VARCHAR (MAX), @IncCol AS VARCHAR (MAX);
SET @idxStmt = REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(@ idxStmt, CHAR(13), ' '), CHAR(10), ' '), CHAR(9), ' '), ' ', '<>'), '><', ''), '<>', ' ');
SET @kstart = CharINDEX('(', @idxStmt);
SET @kend = CharINDEX(')', @idxStmt);
SET @istart = CASE WHEN CharIndex('include', @idxStmt, @kend + 1) != 0 THEN CHARINDEX('(', @idxStmt, @kend + 1) ELSE 0 END;
SET @iend = CHARINDEX(')', @idxStmt, @kend
Error SQL72014: .Net SqlClient Data Provider: Msg 319, Level 15, State 1, Procedure AXPerf_CreateIndex, Line 1 Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a chan
Reason: The problem is with the stored procedure AXPerf_CreateIndex
Solution: Connect to your sandbox database and drop this stored procedure before exporting it again. Once you drop it reexport the database again and import into the DEV box.
Below are the queries I used .
--Query 1
select * from dbo.sysobjects where id = object_id(N'dbo.AXPerf_CreateIndex')
-- Query 2
DROP PROCEDURE AXPerf_CreateIndex;
GO
@Rahul Talaseela
No comments:
Post a Comment