Error - F1 F1 F1 F1 F1 - Help
reza.ariyan
Posts: 5
When im trying to restore my backup (SQLPackage2.exe) this error occur :
i was created a fn_GetColumns manually :
but this error occur :
*************************************************** Ambiguous column name 'ID'. -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE FUNCTION [dbo].[fn_SynchronizeColumn] ( @ColumnsName_SplitedByComma NVARCHAR(MAX), @TableName NVARCHAR(120) ) RETURNS TABLE AS RETURN ( SELECT [ID],[ColumnName] FROM dbo.fn_GetColumns(@TableName) INNER JOIN ( SELECT * FROM dbo.fn_GetSplited(@ColumnsName_SplitedByComma) ) AS temp ON [Value] = [ColumnName] ) ***************************************************
i was created a fn_GetColumns manually :
CREATE FUNCTION [dbo].[fn_GetColumns] ( @Table NVARCHAR(120) ) RETURNS @ColumnsList TABLE ( [ID] INT IDENTITY NOT NULL, [TableName] [nvarchar](50) NOT NULL, [ColumnName] [nvarchar](50) NOT NULL, [IsIdentity] [bit] NOT NULL, [IsPrimary] [bit] NOT NULL ) AS BEGIN DECLARE @TableName NVARCHAR(120) ; DECLARE @ColumnName NVARCHAR(50) ; DECLARE @IsIdentity BIT ; DECLARE @PrimaryColumnName NVARCHAR(50) ; DECLARE @IsPrimary BIT ; DECLARE crsFI CURSOR FOR ( SELECT DISTINCT sys.tables.name AS TableName, sys.all_columns.name AS Columns, sys.all_columns.is_identity AS IsIdentity, dbo.vw_PK_Columns.PKColumn FROM sys.tables INNER JOIN sys.all_columns ON sys.tables.object_id = sys.all_columns.object_id LEFT OUTER JOIN dbo.vw_PK_Columns ON sys.all_columns.name = dbo.vw_PK_Columns.PKColumn WHERE sys.tables.name = @Table ) OPEN crsFI FETCH NEXT FROM crsFI INTO @TableName, @ColumnName, @IsIdentity, @PrimaryColumnName WHILE @@FETCH_STATUS = 0 BEGIN IF @PrimaryColumnName = @ColumnName SET @IsPrimary = 1 ELSE SET @IsPrimary = 0 INSERT @ColumnsList VALUES ( @TableName, @ColumnName, @IsIdentity, @IsPrimary ) FETCH NEXT FROM crsFI INTO @TableName, @ColumnName, @IsIdentity, @PrimaryColumnName END CLOSE crsFI DEALLOCATE crsFI RETURN END
but this error occur :
****************************************** There is already an object named 'fn_GetColumns' in the database. -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE FUNCTION [dbo].[fn_GetColumns] ( @Table NVARCHAR(120) ) RETURNS @ColumnsList TABLE ( [ID] INT IDENTITY NOT NULL, [TableName] [nvarchar](50) NOT NULL, [ColumnName] [nvarchar](50) NOT NULL, [IsIdentity] [bit] NOT NULL, [IsPrimary] [bit] NOT NULL ) AS BEGIN DECLARE @TableName NVARCHAR(120) ; DECLARE @ColumnName NVARCHAR(50) ; DECLARE @IsIdentity BIT ; DECLARE @PrimaryColumnName NVARCHAR(50) ; DECLARE @IsPrimary BIT ; DECLARE crsFI CURSOR FOR ( SELECT DISTINCT sys.tables.name AS TableName, sys.all_columns.name AS Columns, sys.all_columns.is_identity AS IsIdentity, dbo.vw_PK_Columns.PKColumn FROM sys.tables INNER JOIN sys.all_columns ON sys.tables.object_id = sys.all_columns.object_id LEFT OUTER JOIN dbo.vw_PK_Columns ON sys.all_columns.name = dbo.vw_PK_Columns.PKColumn WHERE sys.tables.name = @Table ) OPEN crsFI FETCH NEXT FROM crsFI INTO @TableName, @ColumnName, @IsIdentity, @PrimaryColumnName WHILE @@FETCH_STATUS = 0 BEGIN IF @PrimaryColumnName = @ColumnName SET @IsPrimary = 1 ELSE SET @IsPrimary = 0 INSERT @ColumnsList VALUES ( @TableName, @ColumnName, @IsIdentity, @IsPrimary ) FETCH NEXT FROM crsFI INTO @TableName, @ColumnName, @IsIdentity, @PrimaryColumnName END CLOSE crsFI DEALLOCATE crsFI RETURN END ******************************************:oops:
Comments
This is my SQLPackage
This function probably ended up intact because either fn_GetColumns or fn_GetSplited has a column called ID added after fn_SynchronizeColumn was created.
You'll probably have to modify the function so that it qualifies the ID column, for instance:
How can i resolve its problem ...
it's included 2 Compressed resource file
how can i decompress this resource files ?
http://bettereducation.com.au/it/yaf_po ... smexe.aspx
Because the package code set the "compression" flag, you would probably have to zip the resources again before compiling, but I'm unsure whether Packager's "zlib.dll" can decompress WinZipped files. If you're really, really stuck and can't repackage, then this is the only way I can think of.
Your best option would be to modify the procedure in the database and repackage the whole database.