The components which were failing while publishing/previewing due to the database error was due to the Razor template which was taking more 90 to 200sec to execute that was causing the issue.

To resolve the above issue:

On the CMS and Publisher server went to the  Programs > SDL Web > SDL Web Content Manager configuration in the Microsoft Windows Start menu.

Navigate to the **Timeout** settings section

In that we increased the timeout value from 50sec to 900sec for the Seconds before a timeout error is generated when executing a query.

After increasing the timeout restarted COM+ and required services on both the server to ensure updated settings are used.



[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/aaGcJ.png