Collect All ID Of Subordinate Groups

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


ADVERTISEMENT

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 View Related

Retrieve Manager/Subordinate Hierarchy From Self-Referencing Table

Jul 23, 2005

Hi SQL GurusCould anyone please explain how the following stored procedure can beamended to retrieve Subordinates in alphabetical order ?The example below simply retrives records in the order in which theywere entered.It sounds very easy but I can't sort it out ?The following code was taken from Narayana Vyas Kondreddi's website(http://vyaskn.tripod.com/index.htm)Consider the employee table of an organization, that stores all theemployee records. Each employee is linked to his/her manager by amanger ID.CREATE TABLE dbo.Emp(EmpIDintPRIMARY KEY,EmpNamevarchar(30),MgrIDintFOREIGN KEY REFERENCES Emp(EmpID))GOCREATE NONCLUSTERED INDEX NC_NU_Emp_MgrID ON dbo.Emp(MgrID)GOINSERT dbo.Emp SELECT 1, 'President', NULLINSERT dbo.Emp SELECT 2, 'Vice President', 1INSERT dbo.Emp SELECT 3, 'CEO', 2INSERT dbo.Emp SELECT 4, 'CTO', 2INSERT dbo.Emp SELECT 5, 'Group Project Manager', 4INSERT dbo.Emp SELECT 6, 'Project Manager 1', 5INSERT dbo.Emp SELECT 7, 'Project Manager 2', 5INSERT dbo.Emp SELECT 8, 'Team Leader 1', 6INSERT dbo.Emp SELECT 9, 'Software Engineer 1', 8INSERT dbo.Emp SELECT 10, 'Software Engineer 2', 8INSERT dbo.Emp SELECT 11, 'Test Lead 1', 6INSERT dbo.Emp SELECT 12, 'Tester 1', 11INSERT dbo.Emp SELECT 13, 'Tester 2', 11INSERT dbo.Emp SELECT 14, 'Team Leader 2', 7INSERT dbo.Emp SELECT 15, 'Software Engineer 3', 14INSERT dbo.Emp SELECT 16, 'Software Engineer 4', 14INSERT dbo.Emp SELECT 17, 'Test Lead 2', 7INSERT dbo.Emp SELECT 18, 'Tester 3', 17INSERT dbo.Emp SELECT 19, 'Tester 4', 17INSERT dbo.Emp SELECT 20, 'Tester 5', 17GOCREATE PROC dbo.ShowHierarchy(@Root int)ASBEGINSET NOCOUNT ONDECLARE @EmpID int, @EmpName varchar(30)SET @EmpName = (SELECT EmpName FROM dbo.Emp WHERE EmpID = @Root)PRINT REPLICATE('-', @@NESTLEVEL * 4) + @EmpNameSET @EmpID = (SELECT MIN(EmpID) FROM dbo.Emp WHERE MgrID = @Root)WHILE @EmpID IS NOT NULLBEGINEXEC dbo.ShowHierarchy @EmpIDSET @EmpID = (SELECT MIN(EmpID) FROM dbo.Emp WHERE MgrID = @Root ANDEmpID > @EmpID)ENDENDGOEXEC dbo.ShowHierarchy 1GO---President------Vice President---------CEO---------CTO------------Group Project Manager---------------Project Manager 1------------------Team Leader 1---------------------Software Engineer 1---------------------Software Engineer 2------------------Test Lead 1---------------------Tester 1---------------------Tester 2---------------Project Manager 2------------------Team Leader 2---------------------Software Engineer 3---------------------Software Engineer 4------------------Test Lead 2---------------------Tester 3---------------------Tester 4---------------------Tester 5

View 3 Replies View Related

I Want To Return A String To A Wrapper From A Subordinate Stored Procedure

Sep 27, 2007

Using SQL Server 2000...I wrote a wrapper to call a sub proc (code provided below). Theintended varchar value returned in the output parameter of each procis a string implementation of an array.(The string separates elements by adding a period after each value.e.g. 1. 2. 3. 4. 5. etc., although my simplified example only createstwo elements.)My vb.net calling code parses the returned string into individualelements.I TESTED BOTH PROCS FIRST:The wrapper returns 'hello' when I test it by insertingSELECT @lString='hello'before the GO, so I believe it is called properly.The sub_proc returns the "array" I want when I call it directly.THE PROBLEM: When I call the wrapper, and expect it to call sub_proc,it returns a zero.In fact, when I assign a literal (like 'hello') to @lString insub_proc, 'hello' is not returned.So the wrapper is not calling the sub_proc, or the sub_proc is notreturning an output value.OR...I have read about some issues with OUTPUT string parameters beingtruncated or damaged somehow when passed. I doubt this is theproblem, but I'm open to anything.I want to use the wrapper because, when it's finally working, it willcall several sub_procs andreturn several output values.Any thoughts? Thanks for looking at it! - BobThe Wrapper:-----------------------------------------------------------------CREATE PROCEDURE wrapper@lString varchar(255) OUTASEXEC @lString = sub_proc @CommCode, @lString OUTGO-----------------------------------------------------------------The subordinate procedure:-----------------------------------------------------------------CREATE PROCEDURE sub_proc@lString varchar(255) OUTASDECLARE @var1 int,@var2 intSELECT @var1 =(SELECT count(mycolumn)FROM mytableWHERE condition=1)SELECT @var2 =(SELECT count(mycolumn)FROM mytableWHERE condition=2)/* If @var1 returns 5 and @var2 returns 7, Then @lString below wouldbe "5. 7." */SELECT @lString = STR(@var1) + '.' + STR(@var7) + '.'GO-----------------------------------------------------------------

View 3 Replies View Related

Problem With Matrix (in Subreport, Multiple Groups), Groups Repeating First Row Data

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

Collect DB Information

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

Collect Server Information

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

Merge Tables And Collect Origin Info

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

Transact SQL :: Script To Collect TPS In Instance Level?

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

Collect Diverse Data Whilst Database Being Created

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

Looking To Collect Distinct Date Part Out Of Datetime Field

Mar 11, 2006

from this, circdate being a datetime field:SQLQuery = "select distinct circdate from circdata order by circdate"I need the distinct date portion excluding the time part.this has come about when I discoveredI am inserting and updating some datetime values with the same value,but for some reason, the values are always off by a few seconds. I seta variable called SetNow assigned to NOW and then set the datetimefields to this SetNow variable. Then when I collect the distinct datetime I am assuming they will have the same values recorded incircdate, but no, they are off by several seconds. Makes no sense to meat all. I tried renaming the variable several times but it makes nodifference at all.any help appreciated, thanks.

View 5 Replies View Related

Does Sql Server Collect Stats On Full Table Scans?

Jul 20, 2005

Hi all. Anyone know if sql server collects stats on how many fulltable scans a table gets and if so how do I get at those stats? Tryingto track down poorly indexed tables / processes and I am guessing thatsql server does have this data secreted away somewhere much like mydb2 and informix databases do.

View 1 Replies View Related

MS SQL Server 2005: Collect Procedure For Dts Pipeline Generate Error

Nov 21, 2006

Dear experts,

My MS SQL Server 2005 is generating the following error. may i know what's wrong with it?

"
The Collect Procedure for the "DTSPipeline" service in DLL "XXX:Program FilesMicrosoft SQL Server (x86)90DTSBinnDTSPipelinePerf.dll" generated an exception or returned an invalid status. Performance data returned by counter DLL will be not be returned in Perf Data Block. The exception or status code returned is the first DWORD in the attached data.
"

Thanks in advance for any assistance rendered.
pat

View 6 Replies View Related

Integration Services :: Collect Data From Multiple ODBC Source

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

Counts By Groups

Jan 8, 2007

I expect to get a record below with a count of 0 (and I do), but when I take the comments out (--) of lines 1 & 6 I don't understand why I get no records at all. I need to be able to see all teams in EvalAnswers even if none of the records satisfies the where clause.1 select Count(*) as cnt--, TeamID
2 from EvalAnswers
3 where CoID=@CoID
4 and EvaluatorID=@EvaluatorID
5 and (Scr0=0 and Sugg0 is NULL)
6 --group by TeamID
7

View 4 Replies View Related

Groups In SQLServer2000

Jan 31, 2002

Hi,
I would like to create groups in SQLServer2000.Do i need to do this by roles or can i create groups for each database.I read some where that there where
no groups for SQLServer7.0. Is this option available for the latest versions.
Any help will be appreciated.

Thanks in Advance.
Ran.

View 3 Replies View Related

SAN&#39;s And File Groups

Jan 8, 2001

If you have a SAN, is there any real benefit to breaking out large tables into file groups?

View 1 Replies View Related

How To Get Records In Groups

Nov 24, 2011

I have a Attendance table named say Attendance which has Class and Status along with some other fields.Class will have the name of the class the student is in,whereas the status will have the Absent/Present data.There is another table named say ClassMaster which is the master which will have all the classnames and there is a column of ClassTeacher which will have the EmployeeCode.This employeeCode comes from a table EmployeeMaster.My requirement is i want to get the count of Absent students in Attendance table depending on the Class.For Example if there are two class say ClassA and ClassB,then i should get the count of the Students from Attendance table that belong to Class A and Class B.How cn i do this in one Query.

View 1 Replies View Related

File Groups

Nov 3, 2007

I am looking to find out when to use file groups when backing up. When should you use this, what's the benefit over just doing a full db backup? Is it better when you are dealing with large db's?

Also this question has been on my mind for a while. Why shouldn't you shrink the db after every full backup? What is the negative in doing so?

Thanks

View 1 Replies View Related

OT? Mysql Groups

Jul 20, 2005

I realize the irony of asking this here, but does anyone know of any MySQLgroups where I can ask my questions?Thanks.

View 1 Replies View Related

Getting Sum Of Certain Groups Using Inscope

May 16, 2008



In my report I have 3 row groups and two column groups as follows, where measure is number of hours for a given project.


2008/05 2008/06 ........
Demand | Allocated Demand | Allocated
- Project 1 1500 1000

- Department1 500 400

- Employee1 200
- Employee2 200

- Department2 1000 600

- Employee3 300
- Employee4 300

+ Project 2 1200 1000
-------------------------------------------------------------------------------------------------------------------------

Grand Total 2700 2000



My question is, is this possible using a Matrix? I have used matrix in some of my reports but have always used automatic/generic SUM feature it provides.

Note carefully that there are no values for Employees in Demand Column Group. Basically I would have to SUM Department groupings to get the Project level total and then SUM all Project Groupings to get the grand total. The Allocation column is okay since the Employees have values in that column. Can this be done using InScope( ) or some other function rather than simply doing the Generic SUM of Rows and Columns of the matrix which would probably throw error when trying to sum a blank value in demand column.

Thanks in advance.

View 2 Replies View Related

Headers And Groups

Apr 13, 2007



How do I put information only at the top of a page and have it change whenever a group occurs.



I want to do something like this. Have this on the top of every page:



Country: current country

State: current state

City: current city



There is a group on country, state and city. Whenever city changes the next page will display a new city. Whenever state changes the next page will display the new state in the header.



I have already put Country, State, and City into their own group headers. However, if either of them change in the middle of the page then the group header repeats. I have group header repeat on so I can see it on each page. If I choose the Page break at start then it breaks but I don't want it to break. I want it to run on the same page if it passes a group and then have the next page display relevant information for the group.



Putting it in the table header works as far as keeping them all on the top of the page but it doesn't change when a grouping ends.



Please assist me in anyway you can.



Thanks,



Sarah

View 9 Replies View Related

Groups Question

Mar 17, 2008



I have my first SSRS report going, after years on Crystal and Access. It has several groups, each nested within the next...I think. I'm having a little trouble with the groups...well, grouping the way I thought I had it set up. The groups come out looking like my primary group is second instead of first, although when I look at the groups in "edit groups" it appears I have them set up correctly.
In Crystal, on the preview page you could see the groups idendified so if there was a problem in a report you could tell what group it was coming from. You could also select and change objects in preview, which made it nice to see the impact of changes. I cannot see either of these features in SSRS. I'm hoping that there's a setting I need to turn on, and also hoping that this product has these user friendly features. Any ideas on that?

Also, in Crystal, when you set up a group or a formula, it became available in the field list within the formula builder, so you could use them by picking them instead of typing the whole thing in again, and that's not available either. Or I can't find it!

Since I'm new to SSRS maybe there are features and settings I haven't found yet, but would appreciate any comments from more experienced users about the overall usability of this tool.

Thanks!

View 9 Replies View Related

Table Groups Keep Together

Apr 20, 2007

Is there any way to keep a table group together. MSFT says no but I can't believe this limitation exists. It's a basic reporting function in any reporting software I've used.



I have one group in a table. I don't want the detail rows to be split when it gets to the bottom of the page.

View 6 Replies View Related

Missing Groups

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

File Groups

Jun 28, 2006

Hi everyone,
When I do the following, did I put the files in Test1FG1 file group to the default file group(Primary) ?

ALTER DATABASE Test1

MODIFY FILEGROUP Test1FG1 DEFAULT
GO

Thanks

View 8 Replies View Related

Custom Groups

Jul 18, 2006

I'm wondering if there is any way in RS to create what Crystal reports calls Custom or Named Groups. This functionality allows you to define groups based on the values found in one of the fields on your report. For example, if I were grouping on a person's last name and I want 3 groups based on the first letter: A-G, H-P, Q-Z. I would want to keep it contained in one table.

View 6 Replies View Related

Ceilings On Groups

Apr 24, 2008

Hi All,


I have a challenging report to create. I need to create a report where I'll have groups then I need to have a ceiling on the group to print only 10 records (if there are more than 10 records) then go to the next page and print the final records for that group. I can do the grouping and I can do the ceiling, but I am having a hard time doing both. I'm open for any suggestions.


Thanks

View 1 Replies View Related

File Groups

Jun 26, 2006

Hi everyone,
While creating our database in only one disc(C or D), suppose that we create more than one file group in order to group our data files. However, in this situation; I wonder that whether it brings any benefit or advantage to us.

Also, I wonder that why we always have to put our data file into separate file group if we use separate discs for data files. Is not it allowed to use only one file group even if we use separate dics ?

Would you explain these to me ?

Thanks

View 13 Replies View Related

Top Count For Groups Possible

Apr 7, 2007

Hello,
in a report in Reporting Services 2005 I want to create a top count 100 for groups.
I have a report sheet with a table containing some groups.
Under the groupings there are other groupings and so on.
Now I want that only the top 100, ordered by a value on group level of the 1st group are contained in the report.



Any ideas?



Best regards,


Stefoon

View 1 Replies View Related

SQL Server Groups

Feb 7, 2007

Is it possible that i can create a SQL Server Group in sql 2005. Eg. in 2K when u right click (in Enterprise manager) on Microsoft Sql servers you can see "New Sql server Group". I am talking about this group. I have many servers in NYC and Dallas and in VA. I want to group them in the group names NYC DAL VA. is it possible.

View 12 Replies View Related

Conversation Groups

Jun 28, 2006

I am thinking of updating my SQL monitoring application to use Service Broker.

Right now I loop through my list of servers performing various checks on each server. Things like 'check last database backup', 'check for new databases', 'check for server restart'. I loop through, one server at a time, doing one check at a time. The more servers I have the longer it is taking.

So, I want to multi-thread the servers, but single-thread the checks on each individual server. This way I can check say, 5 servers at a time, but on each server I will only do one check at a time. This way I won't flood an individual server with multiple checks.

Is this possible? It looks like Conversation groups might be the way to go but I'm not sure.

View 2 Replies View Related

Conversation Groups

Dec 20, 2005

I'm having some troubles with conversation groups.  I need to send two  messages on the same conversation group so I have the following in my SP....

BEGIN DIALOG CONVERSATION @providerConversationHandle
 FROM SERVICE [ProviderDataService]
 TO SERVICE 'CalculatedDataService'
 ON CONTRACT [ProviderDataContract]
 WITH ENCRYPTION = OFF
 ,  LIFETIME = 600;

BEGIN DIALOG CONVERSATION @curveConversationHandle
 FROM SERVICE [ProviderDataService]
 TO SERVICE 'CalculatedDataService'
 ON CONTRACT [ProviderDataContract]
 WITH RELATED_CONVERSATION = @providerConversationHandle
 ,    ENCRYPTION = OFF
 ,  LIFETIME = 600;

SEND ON CONVERSATION @providerConversationHandle
 MESSAGE TYPE [ProviderDataMessage] ( @providerMessage );

SEND ON CONVERSATION @curveConversationHandle
 MESSAGE TYPE [ProviderCurveMessage] ( @curveMessage );

When I query the queue I see two messages, but they don't have the same conversation_group_id.

Any ideas?

Thanks.

 

 

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved