LOVE this script! has worked brilliantly on most of the site I maintain. The site I am having issues with is a perpetual PITA.
Having issues upgrading, so it's at 7.2.0 site and I am getting this error:
System.Data.SqlClient.SqlException (0x80131904): Cannot truncate table 'dbo.SearchItemWord' because it is being referenced by a FOREIGN KEY constraint.
at System.Data.SqlClient.SqlConnection. (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, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at DotNetNuke.Data.SqlDataProvider.ExecuteScriptInternal(String connectionString, String script)
ClientConnectionId:4ae098f6-32ce-4953-a56e-9175c040bd35
Error Number:4712,State:1,Class:16
IF Exists (SELECT * FROM sys.tables WHERE object_id = OBJECT_ID(N'dbo.[SearchItemWord]'))
TRUNCATE TABLE dbo.[SearchItemWord]
System.Data.SqlClient.SqlException (0x80131904): Cannot truncate table 'dbo.SearchItem' because it is being referenced by a FOREIGN KEY constraint.
at System.Data.SqlClient.SqlConnection. (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, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at DotNetNuke.Data.SqlDataProvider.ExecuteScriptInternal(String connectionString, String script)
ClientConnectionId:98bcfb43-9568-4431-ab5d-9878b00dd06f
Error Number:4712,State:1,Class:16
IF Exists (SELECT * FROM sys.tables WHERE object_id = OBJECT_ID(N'dbo.[SearchItem]'))
TRUNCATE TABLE dbo.[SearchItem]
System.Data.SqlClient.SqlException (0x80131904): Cannot truncate table 'dbo.SearchWord' because it is being referenced by a FOREIGN KEY constraint.
at System.Data.SqlClient.SqlConnection. (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, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at DotNetNuke.Data.SqlDataProvider.ExecuteScriptInternal(String connectionString, String script)
ClientConnectionId:61696cda-1e37-4e45-ad59-98a0497125e1
Error Number:4712,State:1,Class:16
IF Exists (SELECT * FROM sys.tables WHERE object_id = OBJECT_ID(N'dbo.[SearchWord]'))
TRUNCATE TABLE dbo.[SearchWord]