We have a very strange problem with a database that has been moved from production to production.
The first time the database was moved, it was disconnected, copied and reconnected, the second time we tried to restore the backup copy of the stage.
Both SQL servers are the same version of MS SQL 2008 running on 64-bit hardware.
The database access code is the same assembly built using the .net 2.0 framework.
Here is the error message and some stack trace:
Exception Details: System.Data.SqlClient.SqlException: Error converting data type numeric to numeric. Stack Trace: [SqlException (0x80131904): Error converting data type numeric to numeric.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1953274 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849707 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +204 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137 Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
If I use Red Gate SQL Compare to compare the staging database and live, they will be the same.
Here is the stored procedure that causes the error on the real server:
ALTER PROCEDURE [dbo].[File_Files_InsertUpdateSingleItem] ( @FileId numeric(18,0) output, @Filename nvarchar(255), @Guid uniqueidentifier, @Name nvarchar(100), @ContentType nvarchar(50), @Size numeric(18, 0), @Description nvarchar(2000), @DateCreated datetime, @DateModified datetime, @IsUserUploaded bit, @UploadedByUserID numeric(18, 0) ) AS SET NOCOUNT ON IF @FileId > 0 BEGIN UPDATE [dbo].[File_Files] SET [Filename] = @Filename, [GUID] = @Guid, [Name] = @Name, [ContentType] = @ContentType, [Size] = @Size, [Description] = @Description, [DateCreated] = @DateCreated, [DateModified] = @DateModified, [IsUserUploaded] = @IsUserUploaded, [UploadedByUserID] = @UploadedByUserID WHERE [FileID] = @FileId END ELSE BEGIN INSERT INTO [dbo].[File_Files]( [Filename], [GUID], [Name], [ContentType], [Size], [Description], [DateCreated], [DateModified], [IsUserUploaded], [UploadedByUserID]) VALUES( @Filename, @Guid, @Name, @ContentType, @Size, @Description, @DateCreated, @DateModified, @IsUserUploaded, @UploadedByUserID) SET @FileId = scope_identity() END