Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stats script not able to run on SQL Server 2005
Message
From
01/03/2010 21:33:37
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Stats script not able to run on SQL Server 2005
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01451878
Message ID:
01451878
Views:
102
In order to benefit of SMO objects on SQL Server 2005, I have installed SQLSysClrTypes and SharedManagementObjects on a specific server. So, now, I can benefit of SMO objects and do some fancy things. I should now be also able to execute a stats script I have to obtain WA_Statistics information. The script is as follow:
SET ANSI_WARNINGS OFF
if object_ID('TempDB..#Stats') is not null
   drop table #Stats

create table #Stats (TableName varchar(128), Statistics_Name varchar(128), Statistics_Keys varchar(128))

if object_ID('TempDB..#Stats_Temp') is not null
   drop table #Stats_Temp

create table #Stats_Temp (Statistics_Name varchar(128), Statistics_Keys varchar(128))

exec sp_MSforeachtable 
  'insert into #Stats_Temp execute sp_helpstats ''?'', ''ALL''','?',
   'insert into #Stats select ''?'', * from #Stats_Temp','delete from #Stats_Temp'

select * from #Stats where Statistics_Name like '_WA%'
Now, with the two Microsoft program installed, I can run this script. However, on a SQL Server 2005, it gives an error:

"Msg 8152, Level 16, State 2, Procedure sp_helpstats, Line 101
String or binary data would be truncated."

I haven't been able to figure out what I could adjust to have this script to be compliant on both versions. I know it is related to the fact that it runs on SQL Server 2005. So, I would need to adjust one more thing. Anyone would be able to know what it is exactly?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform