Collect Missing Index Data Into Central Repository From Sys.dm_db_missing_index_group_stats, Groups, Details
Nov 2, 2007
Greetings:
I am trying to gather into a central location the missing index data from the sys DMV's for dynamic index creation in the next step. In trying to use a cursor, I get the following errors:
Msg 154, Level 15, State 3, Line 20
variable assignment is not allowed in a cursor declaration.
Msg 102, Level 15, State 1, Line 94
Incorrect syntax near 'Get_Data'.
Msg 16916, Level 16, State 1, Line 2
A cursor with the name 'Get_Server' does not exist.
Msg 16916, Level 16, State 1, Line 3
A cursor with the name 'Get_Server' does not exist.
Here is the SQL:
--CREATE PROCEDURE usp_Get_Missing_Index_Data
--AS
--Declare @Sql2 nvarchar(4000)
Declare @Sql nvarchar(4000)
DECLARE Get_Server Cursor -- gets a server name from a list of servers
for
Select MachineName from rsqlaudit1.DBStatistics.dbo.servers
Open Get_Server
Declare @Server nchar(20)
Fetch Next from Get_Server Into
@Server
While (@@FETCH_STATUS = 0) --and (@@FETCH_STATUS <> -2)
BEGIN
DECLARE Get_Data Cursor
FOR
select @sql= 'select distinct id.*
, gs.avg_total_user_cost
, gs.avg_user_impact
, gs.last_user_seek
,gs.unique_compiles
from '+@Server+'.master.sys.dm_db_missing_index_group_stats gs
,'+@Server+'.master.sys.dm_db_missing_index_groups g
,'+@Server+'.master.sys.dm_db_missing_index_details id
where gs.group_handle = g.index_group_handle
and id.index_handle = g.index_handle
order by gs.avg_user_impact desc'
exec (@Sql)
Open Get_Data
DECLARE @Handle int,
@database smallint,
@object int,
@equality nvarchar(4000),
@inequality nvarchar(4000),
@Included nvarchar(4000),
@statement nvarchar(4000),
@avg_user_cost float,
@avg_user_impact float,
@last_seek datetime,
@compiles bigint
Fetch NEXT FROM Get_Data INTO
@Handle,
@database,
@object,
@equality,
@inequality,
@Included,
@statement,
@avg_user_cost,
@avg_user_impact,
@last_seek,
@compiles
While (@@FETCH_STATUS = 0) --and (@@FETCH_STATUS <> -2)
BEGIN
insert into rsqlaudit1.DBStatistics.dbo.Missing_Index_data
values (@Server,
@Handle,
@database,
@object,
@equality,
@inequality,
@Included,
@statement,
@avg_user_cost,
@avg_user_impact,
@last_seek,
@compiles)
FETCH NEXT FROM Get_Data into
@Server,
@Handle,
@database,
@object,
@equality,
@inequality,
@Included,
@statement,
@avg_user_cost,
@avg_user_impact,
@last_seek,
@compiles
Fetch Next from Get_Server Into
@Server
END
CLOSE Get_Data
DEALLOCATE Get_Data
GO
CLOSE Get_Server
DEALLOCATE Get_Server
GO
Any suggestions are appreciated.
Thanks,
Derek
View 3 Replies
ADVERTISEMENT
Dec 5, 2014
There is a table with the id and categories Parentid. The challenge is this: you need to collect in each category one drain all the ID that concern it. For Example:
declare @t table (
[id] [bigint],
[Parentid] [bigint],
[Name] [nvarchar](50)
)
insert into @t
[code]....
View 1 Replies
View Related
Nov 3, 2007
Server:
Sql 2005 SP2 running on Win2003 Ent. SP1
I have a 3rd party app that needs me to add a user to the SQLServer2005SQLAgentUser group for the instance I placed the DB in. This group doesn't exist on my server for any of my instances. Is there a simple way to generate it or a document that can tell me how to manually create it?
View 4 Replies
View Related
Jan 25, 2008
I have a new SQL 2005 (SP2) Reporting Services server to which I've just upgraded and deployed some SSRS 2000 reports.
I have a subreport that contains a matrix with two groups. The report data seems to be inexplicably repeating the data for the first row in the group for all rows in the group. Example:
ID1
ID2
DisplayData
1
1
A
1
2
B
1
3
C
2
1
A
2
2
B
2
3
C
Parent group is on ID1, child group is on ID2, report would show:
1
1
A
2
A
3
A
2
1
A
2
A
3
A
Is this a matrix bug in 2005 SP2, or do I need to do something differently? I can no longer pull a comparison version from an SSRS 2000 server to verify, but I believe it was working as expected before...
View 2 Replies
View Related
Mar 10, 2005
Hi,
I need to get the index_name,colum_name and table_name in entire database.
Coule you let me know how I can get that details.
Thanks,
View 7 Replies
View Related
Aug 15, 2014
I would like synchronizing all the missing objects (logins, agent jobs, SSIS, and anything else that I've missed) across SQL 2012 Availability Groups.
I would like to be able to able to automate this process....
View 2 Replies
View Related
Dec 17, 2007
I have a clustered server environment where three of the SQL Server local groups were not created during installation. One of these missing groups is SQLServer2005SQLAgentUser$ComputerName$InstanceName, and this is causing problems with trying to automate replication.
How do I create this group after I have installed SQL Server?
Thanks,
Neal
View 4 Replies
View Related
Jun 1, 2012
I have just started in a brand new role where I need to collect a large amount of diverse data. Part of this data is whether the steps in a guideline has been followed ( a simple check box or yes/no) (but there are maybe 100 guidelines)
My IT department have suggested we use SQL to create the database, but this will obviously take time. In the meantime my boss is keen that I get on with the data collection before the database is ready. I do not want to repeat steps when I create the SQL database so is there any format you would recommend I collect my data in now that can be easily applied to the SQL database - ie if I used Excel, would that be best, and should I then try to keep potential SQL table data separate?
View 3 Replies
View Related
Jan 23, 2008
I Use the below QUERY to fetch the index details of a table from SQL Server 2000 database .
EXEC sp_helpindex 'mytable'
Is there any alternative for the above query .
Because the above query is not fetching some indexes in some version of SQL Server database .
I am trying the above query against SQL Server 2000,2005 and SQL Server 7 versions .
View 4 Replies
View Related
Jun 11, 2015
I am able to collect data from Progress DB, using ODBC Connectivity. The problem I am facing is, i have to iterate thru multiple servers. How do i configure ODBC source dynamically. It creates problem. Using expression, i tried to set the connectionstring dynamically, but it fails.
View 2 Replies
View Related
Sep 15, 2015
We have multiple SQL 2012 SQL servers setup in an alwaysOn availability groups. Where should we schedule the re-index? We have Server1 as the primary and 2 secondaries Server2 and Server3. Are their any tricks to have it run on which ever one is the primary?
View 1 Replies
View Related
Aug 29, 2015
there are several remote locations where sql is running, my company has asked me to find a way to collect all the data from the remote locations to a central location automatically,for example day to day data should be synced at night time from 2am to 7 am and it should be compressed automatically before data transfers to the central location. NOTE there is no domain only standalone workstations
View 3 Replies
View Related
Sep 25, 2006
Hi all,
I am new to replication and have a few questions.
1) Are there any "hooks" available to insert processing when a subscriber is about to copy data from a replicating site?
2) Is it possible for a subscriber to change only his local copy of the data - without replicating the changes back to the publisher?
I realise that once the data changes in one place it isn't really replicated anymore, and I realise that my limited knowledge of the subject might well mean I'm not even asking the right questions. Therefore, I shall try to describe as best I can my scenario.
I wish to use many servers for transactional input (to distribute the workload) and use replication to publish the inputted data to a subscribing central site. One of the tables I wish to replicate has an identity column as primary key, but the records should otherwise be unique - i.e. no two records should differ only in the value of the key. Another table, which should also be replicated, uses this id value as a foreign key.
I can use the identity increment and seed to guarantee no key violations will occur when copying data to the central server. However, there is another issue: Several servers can create the same record but with different id values.
I need to "merge" such records by deleting duplicate entries in the table with the identifier as primary key, and update the foreign keys correspondingly. To clarify (I hope!), here's an example of what data I might have on the central site after copying data from two input sites:
TRANSACTION table
amount = 200, metadata_id = 1001 // Replicated from server INPUT_1
amount = -117, metadata_id = 2001 // Replicated from server INPUT_2
METADATA table:
id=1001 Actitiy=Sales, Country=USA
id=2001 Activity=Sales, Country=USA
What I would like is basically for the central site to identify that metadata 2001 is really the same as metadata 1001, update the foreign key in the TRANSACTION record accordingly and not import (or delete, if this "merging" is done in a post-treatment) the duplicate metadata record.
If anyone can offer any advice on how to achieve this I would appreciate your input.
View 3 Replies
View Related
Oct 15, 2015
Is it possible to replicate data from 3 publishers to a single/central subscriber transactionally? In other words I have Server A, Server B, Server C with databases A,B,C respectively. I need to replicate 2 articles from A,2 from B and 2 from C to a central Server D that hosts database D. D will have only 6 articles. The replication is Transactional Replication.
If it is possible what will be the drawbacks of such implementation? (if one server goes down will the whole replication break?) If not possible then what is the best way of implementing this?
View 3 Replies
View Related
May 19, 2005
Hi,
I run a nightly dbcc checktable on order_header and today I see this error occurs.
Table error: Table 'ORDER_HEADER' (ID 203147769). Missing or invalid key in index 'PK_ORDER_HEADER' (ID 4) for the row:
Server: Msg 8955, Level 16, State 1, Line 1
1. I have no idea what caused it?
2. How do I fixed this online as the application is 24/7?
3. I did try to dbcc reindex but it failed reporting that can't create index because of duplicate in primary index key????
Please show me a way to fix this.
Thanks
Dave
View 2 Replies
View Related
Mar 12, 2007
Dear all,
We have such problems:
DBCC results for 'TRAMES'.
Server: Msg 8955, Level 16, State 1, Line 1
Data row (1:3893993:34) identified by (RID = (1:3893993:34) ) has index values (PO_ID = 80123).
Server: Msg 8951, Level 16, State 1, Line 1
Table error: Table 'TRAMES' (ID 1573580644). Missing or invalid key in index 'IX_POID' (ID 2) for the row:
Server: Msg 8955, Level 16, State 1, Line 1
Data row (1:3893993:48) identified by (RID = (1:3893993:48) ) has index values (PO_ID = 80095).
Server: Msg 8951, Level 16, State 1, Line 1
Table error: Table 'TRAMES' (ID 1573580644). Missing or invalid key in index 'IX_POID' (ID 2) for the row:
Server: Msg 8955, Level 16, State 1, Line 1
Data row (1:3893993:79) identified by (RID = (1:3893993:79) ) has index values (PO_ID = 80123).
Server: Msg 8951, Level 16, State 1, Line 1
Table error: Table 'TRAMES' (ID 1573580644). Missing or invalid key in index 'IX_POID' (ID 2) for the row:
Server: Msg 8955, Level 16, State 1, Line 1
Data row (1:3893993:92) identified by (RID = (1:3893993:92) ) has index values (PO_ID = 80095).
There are 1703901 rows in 18180 pages for object 'TRAMES'.
CHECKDB found 0 allocation errors and 4 consistency errors in table 'TRAMES' (object ID 1573580644).
And really I don't know what can I do to prevent such problems. I know how to fix it with a dbreindex, but it blocks the production during several minutes, and we have to restart the whole plant...
we are using SQL 2000 standard edition 8.00.2039 (with SP4)
Thank you,
regards
Olivier
View 2 Replies
View Related
Jul 23, 2005
One of the table that is in a merge replication somehow is missing anindex. Strangely, only the table in one of the subscriber of the mergereplication is missing the index; another subscriber and the publisherof the merge replication don't have this problem.How should I add the missing index back to that table? My understandingis that making structural change on a table that is inmerge-replication is different from making change on a table that isnot merge-replicated. For example, when we need to add a column into atable that is being merge-replicated, we must add the column bychanging the attributes in the properties of the published article(table) instead of simply using CREATE INDEX command. I am wonderingwhether there is a similar restriction on adding an index onto a tablethat is merge replicated.I have already added the index back to the table anyway. I am askinghere just in case doing this may get me into a problem later on.Thanks in advance for any info.Jay Chan
View 3 Replies
View Related
Apr 23, 2015
I have an exact copy of a database on 2 instances of SQL server (dev and test - dev is restored from test).There's a view that I select top 1000 rows from that runs extremely slow on both instances (DEV and TEST) however on DEV the execution plan specifies that I'm missing an index however in TESTÂ the execution plan does not specify that I'm missing an index.
View 3 Replies
View Related
Jul 22, 2015
At my subscriber database I found some missing Indexes if I update all the missing Indexes on subscriber DB, does it impact at on publisher side?
View 2 Replies
View Related
Oct 30, 2014
I'm in the process of trying to optimize a stored procedure with many queries. The execution plan provides a missing non-clustered index on nearly every query, and they're all fairly similar. The only real difference between them are what's in the INCLUDE statement. The two key columns are listed in every missing index. Let's say each query is approximately 5% of the total batch and 90% of the queries all fall into the category I listed above. How should I go about creating the missing indexes? Create all of the missing indexes or create one generic one that has all the INCLUDE columns? Create a minimal index with just a few of the common INCLUDE columns?
Here's an example of what I'm talking about with the missing indexes:
/*
USE [DB]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[TABLE_1] ([COLUMN_A],[COLUMN_B])
INCLUDE ([C4ABCD],[C4ARTX],[C4ASTX],[C4ADNB],[C4AFNB],[C4BKVA])
GO
*/
/*
The Query Processor estimates that implementing the following index could improve the query cost by 99.9044%.
*/
/*
USE [DB]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[TABLE_1] ([COLUMN_A],[COLUMN_B])
INCLUDE ([C4ARTX],[C4ASTX],[C4ADNB],[C4CZST])
GO
*/
/*
The Query Processor estimates that implementing the following index could improve the query cost by 99.5418%.
*/
/*
USE [DB]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[TABLE_1] ([COLUMN_A],[COLUMN_B])
INCLUDE ([C4ABCD],[C4ARTX],[C4ASTX],[C4ADNB],[C4AFNB],[C4BKVA])
GO
*/
View 3 Replies
View Related
Jan 20, 2008
Hi,
We have a few Analysis Server databases. I need to go to each server/database and in a Word document write the information for each server/database. For example I have a database called Analysis Services Project 1 with Data Source dsIIBSW. I need to write it in a document. Is there a fast way of doing that?
Thanks
Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.
View 2 Replies
View Related
Jul 27, 2001
I am trying to develop a sql script that will select information from statistical tables on several servers and build a report based on the information collected from each. What SQL statements are used to connect to another database or does anyone have an example of a script that collectes information from several servers?
View 1 Replies
View Related
Oct 27, 1999
Hi all ,
The DTS packages I saved in Repository is found disappeared
But when I tried to save a new one with old package name I got an error message that its already there. What should I do in order to veiw all the stored packages in the repository ?
Thank You all
View 2 Replies
View Related
Mar 11, 2015
I have table like :
emp
eno ename deptnno sal
1 a 10 50000
2 b 20 100000
3 c 20 150000
4 d 30 200000
5 e 30 2500000
Here how can I get all employee details excluding junc datas?
View 1 Replies
View Related
Mar 21, 2008
Hi,
Can anyone tell me is it possible to put static data (a string) inside details section of a table?
I've tried to find some more pieces of information in the Report Definition Language Specification, but to no avail.
When I put some strings as a detail's cells values they are displayed in the preview window in VS.
But thay are invisible when I open my report using ReportViewer in my app.
So does it means that the only accepted value of a cell within the details section of a table is a name of the field from DataSet (something like =Fields!FieldName.Value) ?
Regards,
Stan
View 1 Replies
View Related
Jan 21, 2002
How can I see the repository dts packages.
I want to move repository dts packages from server1 to server2.
Help me please.
TIA,
Paul
View 1 Replies
View Related
Jul 9, 1999
I have several Repository DTS packages on my server, but these are not available on all client machines. I have no problems working on these packages from my workstation, or some of my coworkers, but others cannot even see the packages. In fact, when logged onto the server itself, the packages don't show up!!
Has anyone seen this, and is there a fix?
Thanks,
Patrick
View 1 Replies
View Related
Nov 14, 2006
Hi
Can anyone help me out in getting the information or execution progress of a package like "number of records migrated", "which component is getting executed at present",etc...when we migrate the datas using the package which we have created programmatically and trying to execute the package programatically.We can see these informations in the the "progress tab" when we execute the package using BIDS in SSIS.
Thanks in advance
Regards
View 3 Replies
View Related
Apr 29, 2015
If you have 2 tables with the same columns and you would like to see all distinct records in a result of a select and also the information in the records which table the record comes from (for instance: from table A or from table B or bot tables contain it) what should you do?
View 5 Replies
View Related
Oct 22, 2015
I have a requirements to collect Transactions per second from a sql server instances level. Any script to collect TPS in the instance level ?
View 5 Replies
View Related
Jan 21, 2002
How can move repository stored dts packages. Where do they store?
TIA
paul
View 1 Replies
View Related
Jan 17, 2001
I've installed OLAP, SP1 & 2. But when I try to register that OLAP server from my machine using the OLAP Manager interface, I get the error: 'Cannot retrieve the repository information..'. Any ideas?
Thanks!
View 2 Replies
View Related
Sep 29, 2000
... and not being able to open them anymore.
I am working with SQL Server 7.0 SP 1. Everything seemed to be running OK but from some days ago when I create a new DTS package and I save it in MS Repository, the package doesn´t appear under the "Repository Package" folder even when I refresh it.
I know it is there because I can see it in the Metadata folder, but there I can not modify it. What happened? Are DTS packages secure? Should I better use local packeges and save them in SQL Server?
Thanks a lot.
View 1 Replies
View Related