Hi all,
I have an dtsx (SSIS) for "clone" manually Sql server database to another.
How I copy all stats from one database to another ? I have problem with
"auto stats".
When I try DROP statitics for auto stats I get this error:
No se puede DROP el Ãndice 'dbo.ACTIVIDAD_PROVEEDOR.PK_ACTIVIDAD_PROVEEDOR'.
No es una colección de estadÃsticas.
Cannot DROP index 'dbo.ACTIVIDAD_PROVEEDOR.PK_ACTIVIDAD_PROVEEDOR'. Not
statitics collection.
What can I do '
-- Get Stats list
SELECT
'[' + SCHEMA_NAME(tbl.schema_id) + '].[' + tbl.name + ']' AS
[Table_Name_With_Schema],
'[' + st.name + ']' AS [Name],
'' + SCHEMA_NAME(tbl.schema_id) + '.' + tbl.name + ''
+ '.' + st.name + '' AS [Estadistica]
FROM
sys.tables AS tbl
INNER JOIN sys.stats st ON st.object_id=tbl.object_id
ORDER BY
[Table_Name_With_Schema] ASC,[Name] ASC
Thanks in advance, any help will be appreciated, regards, greetings
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
http://www.setbb.com/putainformatica/viewtopic.php?p=843
www.trabajobasura.com/solusoft"Alhambra Eidos Kiquenet" <AlhambraEidosKiquenet@.discussions.microsoft.com>
wrote in message news:3B43B633-9B97-4AAF-9B5E-7B597F7EA970@.microsoft.com...
> Hi all,
> I have an dtsx (SSIS) for "clone" manually Sql server database to another.
> How I copy all stats from one database to another ? I have problem with
> "auto stats".
> When I try DROP statitics for auto stats I get this error:
> No se puede DROP el índice
> 'dbo.ACTIVIDAD_PROVEEDOR.PK_ACTIVIDAD_PROVEEDOR'.
> No es una colección de estadísticas.
> Cannot DROP index 'dbo.ACTIVIDAD_PROVEEDOR.PK_ACTIVIDAD_PROVEEDOR'. Not
> statitics collection.
>
> What can I do '
>
> -- Get Stats list
> SELECT
> '[' + SCHEMA_NAME(tbl.schema_id) + '].[' + tbl.name + ']' AS
> [Table_Name_With_Schema],
> '[' + st.name + ']' AS [Name],
> '' + SCHEMA_NAME(tbl.schema_id) + '.' + tbl.name + ''
> + '.' + st.name + '' AS [Estadistica]
> FROM
> sys.tables AS tbl
> INNER JOIN sys.stats st ON st.object_id=tbl.object_id
> ORDER BY
> [Table_Name_With_Schema] ASC,[Name] ASC
>
> Thanks in advance, any help will be appreciated, regards, greetings
> --
> http://www.alhambra-eidos.es/web2005/index.html
> www.kiquenet.net
> http://www.setbb.com/putainformatica/viewtopic.php?p=843
> www.trabajobasura.com/solusoft
>
Hi
You are probably trying to drop indexes as statistics, to exclude indexes
try:
SELECT '[' + SCHEMA_NAME(tbl.schema_id) + '].[' + tbl.name + ']' AS
[Table_Name_With_Schema],
'[' + st.name + ']' AS [Name],
'' + SCHEMA_NAME(tbl.schema_id) + '.' + tbl.name + '' + '.' + st.name + ''
AS [Estadistica]
FROM sys.tables AS tbl
JOIN sys.stats st ON st.object_id=tbl.object_id
LEFT JOIN sys.indexes i on i.index_id = st.stats_id and i.object_id =st.object_id
WHERE i.index_id IS NULL
ORDER BY [Table_Name_With_Schema] ASC,[Name] ASC
If you only want auto_stats then
SELECT '[' + SCHEMA_NAME(tbl.schema_id) + '].[' + tbl.name + ']' AS
[Table_Name_With_Schema],
'[' + st.name + ']' AS [Name],
'' + SCHEMA_NAME(tbl.schema_id) + '.' + tbl.name + '' + '.' + st.name + ''
AS [Estadistica]
FROM sys.tables AS tbl
JOIN sys.stats st ON st.object_id=tbl.object_id
LEFT JOIN sys.indexes i on i.index_id = st.stats_id and i.object_id =st.object_id
WHERE i.index_id IS NULL
AND st.auto_created = 1
ORDER BY [Table_Name_With_Schema] ASC,[Name] ASC
John
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment