Message
 
 
To
01/03/2010 21:33:37
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01451878
Message ID:
01451880
Views:
26
>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?

BTW, the code looks very much like the code I once posted...

I ran it on my system and so far I didn't get any errors. Could it be you have very long table name or something along these lines?

I think using 400 for everything will work.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View