web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Installing CRM 2013 SP1 doesn't update database

(0) ShareShare
ReportReport
Posted on by 105

Hi,

during installation of CRM 2013 SP1 I got the below mentioned error and database (organization) is not updated (only the server is updated).

Does anyone know what coudlk be a problem? Thanks, Michal.

12:08:20|  Error| Installer Complete: OrganizationDatabaseHotFixer - Error encountered
12:08:20|  Error| Exception occured during Microsoft.Crm.Tools.Admin.OrganizationDatabaseHotFixer: Error.ActionFailed Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction
InnerException:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Crm.CrmException: Error installing sp with name=p_InsertNewWebResource
Must declare the scalar variable "@filename". ---> System.Data.SqlClient.SqlException: Must declare the scalar variable "@filename".
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
   at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
   at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace)
   at Microsoft.Crm.Metadata.SqlHelper.ExecuteBatches(IDbTransaction transaction, IDbCommand sqlCommand)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProcedureInternal(StoredProcedureData spData, SqlExecutionContext sqlContext)
   --- End of inner exception stack trace ---
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProcedureInternal(StoredProcedureData spData, SqlExecutionContext sqlContext)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProceduresInternal(String targetType, String databaseName, String catalogXmlFile, Boolean dropExistingProceduresFirst, Boolean startTransaction)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProceduresUpdate(String targetType, String databaseName, String catalogXmlFile)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Microsoft.Crm.Setup.Database.DllMethodAction.Execute(Guid organizationId)
   at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseInfo releaseInfo, Boolean isInstall)
   at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall)
   at Microsoft.Crm.Setup.Database.DatabaseInstaller.InstallUpdate(String configurationFilePath, Boolean upgradeDatabase)
   at Microsoft.Crm.Setup.Common.Update.DBUpdateDatabaseInstaller.ApplyDBUpdates(Guid orgId)
   at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdatesInternal(Guid orgId, String orgUniqueName, String releaseFilePath, Boolean ignoreErrors)
   at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdates(Guid orgId, String orgUniqueName, OrganizationOperationType operationType)
   at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.Do(IDictionary parameters)
   at Microsoft.Crm.Setup.Shared.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo)
InnerException:
Microsoft.Crm.CrmException: Error installing sp with name=p_InsertNewWebResource
Must declare the scalar variable "@filename". ---> System.Data.SqlClient.SqlException: Must declare the scalar variable "@filename".
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
   at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
   at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace)
   at Microsoft.Crm.Metadata.SqlHelper.ExecuteBatches(IDbTransaction transaction, IDbCommand sqlCommand)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProcedureInternal(StoredProcedureData spData, SqlExecutionContext sqlContext)
   --- End of inner exception stack trace ---
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProcedureInternal(StoredProcedureData spData, SqlExecutionContext sqlContext)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProceduresInternal(String targetType, String databaseName, String catalogXmlFile, Boolean dropExistingProceduresFirst, Boolean startTransaction)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProceduresUpdate(String targetType, String databaseName, String catalogXmlFile)
InnerException:
System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@filename".
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
   at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
   at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace)
   at Microsoft.Crm.Metadata.SqlHelper.ExecuteBatches(IDbTransaction transaction, IDbCommand sqlCommand)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProcedureInternal(StoredProcedureData spData, SqlExecutionContext sqlContext)
ClientConnectionId:1e14a314-5fec-4f50-b0d2-e67b16175c0e

12:08:20|   Info| Setting organization state.  New state = Failed
12:08:20|  Error| Update Organization with Id=8bcc8138-0c00-46ef-a17f-2bbbae259125 failed with Exception:
System.Exception: Error.ActionFailed Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Crm.CrmException: Error installing sp with name=p_InsertNewWebResource
Must declare the scalar variable "@filename". ---> System.Data.SqlClient.SqlException: Must declare the scalar variable "@filename".
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
   at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
   at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace)
   at Microsoft.Crm.Metadata.SqlHelper.ExecuteBatches(IDbTransaction transaction, IDbCommand sqlCommand)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProcedureInternal(StoredProcedureData spData, SqlExecutionContext sqlContext)
   --- End of inner exception stack trace ---
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProcedureInternal(StoredProcedureData spData, SqlExecutionContext sqlContext)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProceduresInternal(String targetType, String databaseName, String catalogXmlFile, Boolean dropExistingProceduresFirst, Boolean startTransaction)
   at Microsoft.Crm.Setup.StoredProcedureService.InstallStoredProceduresUpdate(String targetType, String databaseName, String catalogXmlFile)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Microsoft.Crm.Setup.Database.DllMethodAction.Execute(Guid organizationId)
   at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseInfo releaseInfo, Boolean isInstall)
   at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall)
   at Microsoft.Crm.Setup.Database.DatabaseInstaller.InstallUpdate(String configurationFilePath, Boolean upgradeDatabase)
   at Microsoft.Crm.Setup.Common.Update.DBUpdateDatabaseInstaller.ApplyDBUpdates(Guid orgId)
   at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdatesInternal(Guid orgId, String orgUniqueName, String releaseFilePath, Boolean ignoreErrors)
   at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdates(Guid orgId, String orgUniqueName, OrganizationOperationType operationType)
   at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.Do(IDictionary parameters)
   at Microsoft.Crm.Setup.Shared.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo)
   --- End of inner exception stack trace ---
   at Microsoft.Crm.Setup.Shared.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo)
   at Microsoft.Crm.Setup.Shared.Installer.Install(IDictionary stateSaver)
   at Microsoft.Crm.Tools.Admin.OrganizationOperation.Install(IDictionary stateSaver)
   at Microsoft.Crm.Tools.Admin.OrganizationOperation.Execute()
   at Microsoft.Crm.Tools.Admin.OrganizationDatabaseHotFixer.Execute()
   at Microsoft.Crm.Tools.Admin.ApplyDatabaseHotFixInstaller.ApplyDatabaseHotFix(IApplyDatabaseHotFixInfo applyDatabaseHotFixInfo)
12:08:20|   Info| Found the older table DBUpdateInstallInfo_V5, updating new table and deleting
12:08:21|   Info| GetDBUpdateRevisionThresholdForServer(): Threshold = 6.1.0000.0581.

*This post is locked for comments

I have the same question (0)
  • Gekosin Profile Picture
    60 on at

    I currently have the same issue with an upgrade i am trying to run, the odd thing is i moved the DB to another environment that had everything installed already (CRM 2013, rollup 1, 2 and service pack 1) and the upgrade worked.

  • Suggested answer
    Nizar JLASSI Profile Picture
    2 on at

    Hi,

    It seems like a problem of altering/create of a stored procedure called : p_InsertNewWebResource

    Check if this sp exists in your [Org]_MSCRM database.

    This is the sp tsql code :

    CREATE PROCEDURE [dbo].[p_InsertNewWebResource](

    @webresourceid UNIQUEIDENTIFIER,

    @fileName SYSNAME,

    @isManaged BIT,

    @webResourceType INT,

    @orgId UNIQUEIDENTIFIER,

    @name SYSNAME,

    @isHidden BIT,

    @canBeDeleted BIT,

    @isCustomizable BIT,

    @content varchar(max),

    @description nvarchar(max),

    @introducedVersion nvarchar(96),

    @introducedVersionFloat FLOAT,

    @adminUserId UNIQUEIDENTIFIER,

    @systemUserId UNIQUEIDENTIFIER,

    @solutionId UNIQUEIDENTIFIER

    ) AS

    BEGIN

    DECLARE @emptyGuid UNIQUEIDENTIFIER

    SET @emptyGuid = '00000000-0000-0000-0000-000000000000'

    IF NOT EXISTS (SELECT * FROM WebResourceBase WHERE WebResourceId=@webresourceid)

    BEGIN

    INSERT INTO WebResourceBaseIds (WebResourceId) VALUES(@webresourceid)

    INSERT INTO WebResourceBase(Name, IsManaged, WebResourceType, ComponentState, ModifiedOn, OrganizationId, WebResourceIdUnique, DisplayName, IsHidden, WebResourceId, CreatedOn, CanBeDeleted, IsCustomizable, Content, [Description], IntroducedVersion, Crea
    tedBy, ModifiedBy, CreatedOnBehalfBy, ModifiedOnBehalfBy, SolutionId)

    VALUES (@filename, @isManaged, @webResourceType, '0', getutcdate(), @orgId, newid(), @name, @isHidden, @webresourceid, getutcdate(),@canBeDeleted, @isCustomizable, @content, @description, @introducedVersion, @adminUserId, @adminUserId, @systemUserId,
    @systemUserId, @solutionId)

    INSERT INTO DependencyNodeBase(BaseSolutionId, TopSolutionId, ParentId, DependencyNodeId, ComponentType, ObjectId, IsSharedComponent, IntroducedVersion)

    VALUES (@solutionId, @solutionId, @emptyGuid, NEWID(), 61, @webresourceid, 0, @introducedVersionFloat)

    INSERT INTO SolutionComponentBase(SolutionComponentId, SolutionId, ComponentType, IsMetadata, ObjectId, ModifiedOn, ModifiedBy, CreatedOn, CreatedBy)

    VALUES (NEWID(), @solutionId, 61, 0, @webresourceid, getutcdate(), @systemUserId, getutcdate(), @systemUserId)

    END

    END

    If the sp dos not exist exists, execute this code, and it will create it in the db.

    If the sp exists, replace CREATE PROCEDURE by ALTER PROCEDURE and execute the code.

    After that retry your SP1 install.

     

  • Gekosin Profile Picture
    60 on at

    Hi There,

    I checked the Store Procs and it appears that the InsertNewWebResource was not there so i ran the script, then did the service pack re install as suggested but still no luck get the same error.

  • Verified answer
    Paul.Livengood Profile Picture
    95 on at

    I had the same issue. It was because my System Databases were Case Sensitive, but the one Stored Procedure (p_InsertNewWebResource) is not written for a Case Sensitive System Database.

    Fix:

    To fix this I had to modify the XML code that creates the Stored Procedure during the CRM Update.

    Assuming CRM is installed in the default location on the C drive, you need to do the following

    • Edit this file; C:\Program Files\Microsoft Dynamics CRM\Setup\Serviceability\Latest\Actions_Org\Install\UpdateStoredProcedures.xml

    • Find the XML with p_InsertNewWebResource – searching for it is best.

    • Find the “@filename” piece of code and change it to “@fileName”.

    • Save the XML file

    • ReRun the Update

     

    Hope this helps

    Paul

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans