Command column data in SYSMAINTPLAN_LOGDETAIL in MSDB database?
Hi All,
I have been facing the data issue in SYSMAINTPLAN_LOGDETAIL table in MSDB.
When I query on this table, I don't see data in "COMMAND" column.
And also I am not able to view T-SQL in maintenance plan history as it is disable.
Can any one please let me know the solution how can I get command column data into the table?
thanks in advance.
Nik
Regards, Naman
Hi,
In SQL Server 2000 symaintplan table was acessible directly but from 2005 onwards this table is not directly accessible due to increased security this table gets updated when maintenance plan runs. I dont think its a data issue i ran below commands
on my SQL Server found some rows had some entries for column 'command' while some of it does not. Also curious thing was when col 'succeeded' value was zero this col had some text present.
select * from msdb.dbo.sysmaintplan_logdetail where command <> '' and succeeded= 0--executing select * can take long time please note depending on rows presentselect * from msdb.dbo.sysmaintplan_logdetail where succeeded= 0
I cannot find any online documentation on msdb.dbo.sysmaintplan_logdetails to actually see what is being captured in this column.But what I can guess is it captures command which actually executed.This is a system table its difficult to tell how actually column
command is updated
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
My TechNet Wiki Articles
Similar Messages
-
Reading column data type in SSAS tabular database using adomd
I am working on SSAS tabular database and I need to find out the column datatype. I am using ADOMD for this. So far I looked at AdomdDataReader.GetSchemaTable
Method & looked at the below code snippet to retrive Metadata from the AdomdDataReader.
foreach (DataRow objRow in schemaTable.Rows)
foreach (DataColumn objColumn in schemaTable.Columns)
Console.WriteLine(objColumn.ColumnName + " = " + objRow[objColumn]);
Console.WriteLine();
I wonder with only the list of columns available to me, how can I execute a query/command and utilize adomd reader to get this information?
What is the best approach to read column metadata?Hi, One option that you can try is to use AMO. Here is a sample code that connects to multi-dimensional model.
http://sqlblogcasts.com/blogs/drjohn/archive/2012/03/15/ssas-utility-to-check-you-have-the-correct-data-types-and-sizes-in-your-cube-definition.aspx
You will have to change few things to make it work for tabular model. Sorry, I did not try myself but I hope this will give you some ideas.
// get DSV - this code assumes only one DSV in cube definition
AMO.DataSourceView
dsv = olapDatabase.DataSourceViews[0];
foreach (AMO.Dimension
dim in olapDatabase.Dimensions)
foreach (AMO.DimensionAttribute
attr in dim.Attributes)
foreach (AMO.DataItem
dItem in attr.KeyColumns)
AddAttributeDataItem(dtCubeDataTypes,
"Key", dsv, attr, dItem);
AMO.DataItem contains column size and data type when connected to a tabular database. -
Can i see the column DATA(BLOB type) in PM_OBJECTS of DCM schema
we installed DCM managed clustering .it is Database repository type.
i am trying to see the column DATA(BLOB type) in PM_OBJECTS of DCM schema .
I wrote a program in java to read blob data type and write it into a temporary file.
when i open temporary files all the data in junk format.
can i see the real data of thatcolumn.Is it possible?
first of all for what purpose DCM shema will be used?Hi,
There is no option to show the comments on the diagram.
We plan to add such feature in the next version.
Ivan -
How to create a view consisting of data from tables in2 different databases
Using Oracle 10.2g
I have 2 databases Gus and haggis on Comqdhb schema.
glink indicates a databse link between Haggis and Gus
In Gus there are tables student,subject,grade,school containing columns like upn...
STUDENT
upn
academicYear
SUBJECT
subject
GRADE
examlevel
grade
SCHOOL
sn
In HAGGIS there are tables student,grade,teacher containing columns upn...desc below.
STUDENT
upn
GRADE
grade
upn
academicyear
level
Create view in your HAGGIS database which will join all of the exam grades together. You should have one view which will produce the following relation :
examGrade(upn, subject, examlevel, sn, grade,academicYear)
so I need to create a view which gets the data from both the tables in both the databases.
create view as examGrade(upn, subject, examlevel, sn, grade,academicYear) as select s.upn
But i am not getting how to select a column from 2 tables in different databases
I mean if i said
select upn from comqdhb.student@glink,comqdhb.student;
select upn from comqdhb.student@glink,comqdhb.student
ERROR at line 1:
ORA-00918: column ambiguously defined
help me out,Thank you.Thank you for the reply will follow up the code format
Create views in your HAGGIS schema database which will join all of the exam grades together. You should have one view which will produce the following relation :
examGrade(upn, subject, examlevel, sn, grade,academicYear)
I understand that there wont be duplication when we use conditions
If i query
select count(upn)
from comqdhb.student@glink I get 9000
but after the union
create view examGrade(upn, subject, examlevel, sn, grade,academicYear)
as
select distinct s.upn as upn
, g.subject as subject
, g."LEVEL" as examlevel
, g.grade as grades
, '9364097'
, to_number(g.academicyear) as academicyear
from comqdhb.student s
, comqdhb.grade g
where s.upn=g.upn
union
select s.upn
, sb.subject
, g.elevel
, g.grade
, s.acyr
, sc.sn
from comqdhb.subject@glink sb
, comqdhb.student@glink s
, comqdhb.gradevalues@glink g
, comqdhb.school@glink sc,
, comqdhb.studentingroup@glink sg
, comqdhb.teachinggroup@glink tg
where sb.sid=tg.sid
and tg.gid=sg.gid
and sg.upn=s.upn
and g."LEVEL"=tg.elevel
and s.school=sc.id
and sc.id=tg.id; returns
count(upn) from exam gradeIt gets stuck actually sometimes it returns
932002 some results.
2:
Another problem i am having which i am trying to solve and written up my ideas but haven't been getting the expected results.Hope you can help.Thank you.
Information:
=======
All children take exams at the age of 16 called a General Certificate of SecondaryEducation (GCSE).
They have to study and take exams in Mathematics, English and Science, and can take other subjects such as History, French, Art etc. Most students will study between 5 and 10 different subjects before taking their GCSEs.
For each exam, a student is awarded a grade from A*, A, B,C,D,E,F,G,U,X An A* grade is the best grade achievable and an X is the worst grade.
In order to analyze how students have performed, each grade is mapped to a numeric value as follows:
Grade Numerical score
A* 8
A 7
B 6
C 5
D 4
E 3
F 2
G 1
U 0
X 0
Now why i need this avgGCSE is because i have to create a view containing avgGCSE of the students it is used in the next question where a condition is avgGCSE is between 6.5 and 7
In order to calculate the avgGCSE the idea is to calculate the grades of the students and map the grades to their corresponding scores/values
add them all up and div by the total no of grades to get the avg.
desc comqdhb.STUDENT@glink;
STUDENT
=======
UPN
FNAME
CNAME
DOB
GENDER
PREVIOUSSCHOOL
XGCSE
SCHOOL
ACYR
STUDENTINGROUP
=============
UPN
GID
STARTDATE
ENDDATE
GRADE
GRADEVALUES
===========
GRADE
LEVEL
VALUE
I have a opinion that xgcse in STUDENT table refers to the avgGCSE which i want to calculate as when i asked my professor as to what xgcse he said that he forgot to take it out of the table and it is not necessary while creating avggcse.
select *
from comqdhb.student@glink
where xgcse<6.5; Displaying a result
returns:
UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
===========================================================================
1011 KIMBERLY ABBOT 07-JUL-79 f none 3.93500948 2 2
select *
from comqdhb.student@glink
where xgcse between 6.5 and 7 and upn = 1386; Displaying a result
returns:
UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
===========================================================================
1386 STEPHANIE AANNESSON 15-JAN-79 f none 6.88873 2 2 so if xgcse is the avgGCSE then upn 1011 has avggcse<6.5 and 1386 has avggcse >6.5
my idea was backward strategy like so now if we find out upn 1368 has suppose xgcse(avggcse)>6.5 how to extract the avggcse for the particular upn We need to map grades from GRADEVALUES to grade in STUDENTINGROUP and map upn from studentingroup to upn in student to output the values for the corresponding grades from GRADEVALUES
select grade
from comqdhb.studentingroup@glink
where upn = 1011;
Result:
GRADE
=====
D
F
B
E
C
E
E
B
8 rows selected. Mapping each grade to the corresponding value and calculating we get
32/8=4 total(values to corresponding grades)/no of grades.
But the xgcse for upn 1011 is 3.935 and i am getting 4!! maybe xgcse isn't avggrade but ? is the procedure by me correct for calculating avggcse
select grade
from comqdhb.studentingroup@glink
where upn = 1386;
Result:
GRADE
======
A*
A*
A*
A*
B
A*
A*
A
B
B
B
11 rows selected. grade to the corresponding value and calculating we get
79/11=7.12 total(values to corresponding grades)/no of grades.
But the xgcse for upn 1011 is 6.88... and i am getting 7.12!!
But another problem
when i say
select g.value,g.grade
from comqdhb.gradevalues@glink g
, comqdhb.studentingroup@glink sg
where g.grade=sg.grade
and sg.upn=1011;
result:
======
VALUE GRADE
===========
100 B
100 B
80 C
60 D
40 E
40 E
40 E
20 F
6 B
6 B
5 C
VALUE GRADE
=============
4 D
3 E
3 E
3 E
2 F
16 rows selected.
select distinct g.value,g.grade
from comqdhb.gradevalues@glink g
, comqdhb.studentingroup@glink sg
where g.grade=sg.grade
and sg.upn=1011;
result:
======
VALUE GRADE
============
2 F
100 B
6 B
3 E
60 D
5 C
4 D
80 C
40 E
20 F
10 rows selected. I am getting only 8 for the query
select grade
from comqdhb.studentingroup@glink
where upn = 1386; here its becomming 10 and also its displaying values as 100 and ...
select distinct *
from comqdhb.gradevalues@glink;
GRADEVALUES
===========
LEVEL GRADE VALUE
================================
a A 120
a B 100
a C 80
a D 60
a E 40
a F 20
a U 0
a X 0
g A 7
g A* 8
g B 6
LEVEL GRADE VALUE
================================
g C 5
g D 4
g E 3
g F 2
g G 1
g U 0
g X 0
18 rows selected. I was hoping if i could map the grades and get the values and calculate avggrade by total(values)/count(values)that would be it but here there are values like 100...
select sum(g.value)/count(g.grade) as avggrade
from comqdhb.gradevalues@glink g
, comqdhb.studentingroup@glink sg
where g.grade=sg.grade
and sg.upn=1386;
avggrade
========
37.4375 the avggrade cant be this big and when i map each grade i obtained for 1368 like a to 7+b to 6 so on i get avggrade 7.12
kindly help.
Edited by: Trooper on Dec 15, 2008 4:49 AM -
Help on export sybase iq tables with data and import in another database ?
Help on export Sybase iq 16 tables with data and import into another database ?
Hi Nilesh,
If you have table/index create commands (DDLs), you can create them in Developper and import data using one of methods below
Extract/ Load table
Insert location method : require IQ servers to be entered in interfaces file
Backup/Restore : copy entire database content
If you have not the DDLs, you can generate them using IQ cockpit or SCC.
http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01773.1604/doc/html/san1288042631955.html
http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01840.1604/doc/html/san1281564927196.html
Regards,
Tayeb. -
ORA-01242: data file suffered media failure: database in NOARCHIVELOG mode
Hi All,
Need help from the gurus.
Currently we are in state unable to do anything.
Was using a database and all of a sudden it crashed. Tried to mount the database, open it, it failed. Also tried the recover and alter database open, even that failed. Errors are as follows.
Errors in file e:\oracle\product\10.2.0 \admin\devrevdb\bdump\devrevdb_p000_2620.trc:
ORA-00603: ORACLE server session terminated by fatal error
ORA-01242: data file suffered media failure: database in NOARCHIVELOG mode
ORA-00449: background process 'DBW0' unexpectedly terminated with error 1242
ORA-01242: data file suffered media failure: database in NOARCHIVELOG mode
In my spfile, the administrator has set only two control files and there is no mirroring and hence do not have another control file that will help me boot the db.
Please let me know how I should go about it. I am only a timebeing person trying to carryout a db activity. Any help would be of great help.Hemant,
thanks for the reply.
I tried the way you suggested and it threw an error.
ORA-01145: offline immediate disallowed unless media recovery enabled
I searched and found that an additional tag of drop needs to be added to the command which you suggested.
ALTER DATABASE DATAFILE '<filename>' OFFLINE DROP.
i don't know what will the drop command have an effect ?
i have copied the data file to another location. Since i don't know much, i just want to be sure of what im doing.
if the above command is successfull, will it drop the datafile or the tablespace and i can no more use it. How can i use the copied datafile.
Thanks,
Sachin
I -
How to search all columns of all tables in a database for a keyword?
Dear Team,
i have an requirement that : i want to search all the columns of all the tables in the particular database based on the specific key word or an free text.
example :
table 1: columns data
empname sam
empid 01
table 2 columns data
deptname sam
departmentid 10
table 3 columns data
organization name sam
organization id 1
when i search for text " SAM"
it should search me from the entire database, all tables and columns of it and display the result
output : tablename cloumn value
table1 empname sam
table2 deptname sam
table3 organizationame sam
the example is just an sample not the real data .
please help me with sample code or any link related to it .
thanks in advanceHi justin , thanx for the reply
the basic requirement that we required is ,
the user will just type the keyword( value in the coumn) he required and it should search all the tables and columns of the table in the database and i have to show this in the front ent in the table format. here the user will analyse the information based on the search .
it is just like the google search we does( type the keyword in free text) it will display the result.
so for that i have to search entire table and columns in the whole database.
please if any one provides me the solution it will be help full for me.
thanx in advance -
How to search all columns of all tables in a database
i need to search all columns of all tables in a database , i already write the code below , but i've got the error message below when run this script
DECLARE
cnt number;
v_data VARCHAR2(20);
BEGIN
v_data :='5C4CA98EAC4C';
FOR t1 IN (SELECT table_name, column_name FROM all_tab_cols where owner='admin' and DATA_TYPE='VARCHAR2') LOOP
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' ||t1.table_name|| ' WHERE ' ||t1.column_name || ' = :1' INTO cnt USING v_data;
IF cnt > 0 THEN
dbms_output.put_line( t1.table_name ||' '||t1.column_name||' '||cnt );
END IF;
END LOOP;
END;
Error report:
ORA-00933: SQL command not properly ended
ORA-06512: at line 7
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Any help pleaseSQL solutions by Michaels
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
11g upwards
SQL> select table_name,
column_name,
:search_string search_string,
result
from (select column_name,
table_name,
'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
from cols
where table_name in ('EMP', 'DEPT')),
xmltable (str columns result varchar2(10) path '.')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME es RESEARCH
EMP ENAME es JAMES
EMP JOB es SALESMAN
EMP JOB es SALESMAN
4 rows selected. -
Create List of Tables/Columns/Data Types
I am new to Oracle (from SQL Server) and I am looking for a query that will create a list of tables, columns, data types, etc. (data dictionary) in an Oracle database -- one that I can import into, say, MS Access or use Crystal reports and create a report that shows the same.
I had a query to do this in SQL Server -- but it was specific to SQL Server. Does anyone have one to do the same in Oracle? I'm hoping not to have to re-invent the wheel.
Thanks!Hi user653145!
The Data Dictionary has many queries to view informations. Some of these view are
dba_tables
dba_tab_columns
dba_views
etc.
Look for the "Oracle Database Referenc" in the Oracle Onlinedocumentation at
http://tahiti.oracle.com
to get a full list of all data dictionary views.
hope this helps! -
Hi,
I've database Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
I need help on manipulating BLOB column data. It is storing .msg file. I want to modify its 'Subject:' line. Below query gives me position of Subject line but when I'm trying to read its content before modifying it then it is giving me error as ORA-06502: PL/SQL: numeric or value error: raw variable length too long:
SELECT dbms_lob.substr(case_content, dbms_lob.instr( blob_column, utl_raw.cast_to_raw('Subject')),50)
FROM my_table
But below query gives me position properly:
SELECT dbms_lob.instr( blob_column,utl_raw.cast_to_raw('Subject'))
FROM my_table
Thanks in advance.
Regards,
ChintanFirstly I would be wary of doing any string manipulation of binary data (.msg file). Secondly are you sure you have the parameters in dbms_lob.substr the correct way round: http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_lob.htm#i999349 You are getting the substring of case_content, starting with an offset of 50 and taking n bytes/chars where n is the postion of hte first occurence of "Subject" in case_content.
Ben -
How do I know the column data type
Hello,
For example I have created table Test:
SQL> create table Test(
2 rollNo number(3),
3 Name varchar2(80));
Table created.Now I desc Test but its not showing the column data type
SQL> desc test
Name
ROLLNO
NAME Can I know that?
Best regardsWhat happens when you issue,
set linesize 2000
SQL>desc testAre you sure that you are not missing scrolling the bar in the bottom of the window?
SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 20 19:23:01 2010
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table testr(test number(3), rollno varchar2(10));
Table created.
SQL> desc testr
Name Null? Type
TEST NUMBER(3)
ROLLNO VARCHAR2(10)Aman....
Edited by: Aman.... on Nov 20, 2010 7:24 PM -
COMMAND column in V$SESSION table
Is there any table which stores all the meaning of various values that can be stored in COMMAND column of V$SESSION table
Like 3 is for SELECT and 47 for Execute, I found some documentation in data dictionary but was wondering if there is some table that can be used when a trigger or procedure is running to pull the values on the fly.
ThxYou can find the various values for V$SESSION.COMMAND in Table 7-5 COMMAND Column of V$SESSION and Corresponding Commands found in the link below to build your own table.
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2088.htm#sthref3985 -
COMMAND column in V$SESSION just show s SELECT
Hi,
i queried command column in v$session, but it shows only 3(which is for SELECT) and 0 (which is for unknown), even i update some thing its not shown.
ThanksHi Pavan,
following is the list for that
Number Command Number Command
1 CREATE TABLE 2 INSERT
3 SELECT 4 CREATE CLUSTER
5 ALTER CLUSTER 6 UPDATE
7 DELETE 8 DROP CLUSTER
9 CREATE INDEX 10 DROP INDEX
11 ALTER INDEX 12 DROP TABLE
13 CREATE SEQUENCE 14 ALTER SEQUENCE
15 ALTER TABLE 16 DROP SEQUENCE
17 GRANT OBJECT 18 REVOKE OBJECT
19 CREATE SYNONYM 20 DROP SYNONYM
21 CREATE VIEW 22 DROP VIEW
23 VALIDATE INDEX 24 CREATE PROCEDURE
25 ALTER PROCEDURE 26 LOCK
27 NO-OP 28 RENAME
29 COMMENT 30 AUDIT OBJECT
31 NOAUDIT OBJECT 32 CREATE DATABASE LINK
33 DROP DATABASE LINK 34 CREATE DATABASE
35 ALTER DATABASE 36 CREATE ROLLBACK SEG
37 ALTER ROLLBACK SEG 38 DROP ROLLBACK SEG
39 CREATE TABLESPACE 40 ALTER TABLESPACE
41 DROP TABLESPACE 42 ALTER SESSION
43 ALTER USER 44 COMMIT
45 ROLLBACK 46 SAVEPOINT
47 PL/SQL EXECUTE 48 SET TRANSACTION
49 ALTER SYSTEM 50 EXPLAIN
51 CREATE USER 52 CREATE ROLE
53 DROP USER 54 DROP ROLE
55 SET ROLE 56 CREATE SCHEMA
57 CREATE CONTROL FILE 59 CREATE TRIGGER
60 ALTER TRIGGER 61 DROP TRIGGER
62 ANALYZE TABLE 63 ANALYZE INDEX
64 ANALYZE CLUSTER 65 CREATE PROFILE
66 DROP PROFILE 67 ALTER PROFILE
68 DROP PROCEDURE 70 ALTER RESOURCE COST
71 CREATE MATERIALIZED VIEW LOG 72 ALTER MATERIALIZED VIEW LOG
73 DROP MATERIALIZED VIEW LOG 74 CREATE MATERIALIZED VIEW
75 ALTER MATERIALIZED VIEW 76 DROP MATERIALIZED VIEW
77 CREATE TYPE 78 DROP TYPE
79 ALTER ROLE 80 ALTER TYPE
81 CREATE TYPE BODY 82 ALTER TYPE BODY
83 DROP TYPE BODY 84 DROP LIBRARY
85 TRUNCATE TABLE 86 TRUNCATE CLUSTER
91 CREATE FUNCTION 92 ALTER FUNCTION
93 DROP FUNCTION 94 CREATE PACKAGE
95 ALTER PACKAGE 96 DROP PACKAGE
97 CREATE PACKAGE BODY 98 ALTER PACKAGE BODY
99 DROP PACKAGE BODY 100 LOGON
101 LOGOFF 102 LOGOFF BY CLEANUP
103 SESSION REC 104 SYSTEM AUDIT
105 SYSTEM NOAUDIT 106 AUDIT DEFAULT
107 NOAUDIT DEFAULT 108 SYSTEM GRANT
109 SYSTEM REVOKE 110 CREATE PUBLIC SYNONYM
111 DROP PUBLIC SYNONYM 112 CREATE PUBLIC DATABASE LINK
113 DROP PUBLIC DATABASE LINK 114 GRANT ROLE
115 REVOKE ROLE 116 EXECUTE PROCEDURE
117 USER COMMENT 118 ENABLE TRIGGER
119 DISABLE TRIGGER 120 ENABLE ALL TRIGGERS
121 DISABLE ALL TRIGGERS 122 NETWORK ERROR
123 EXECUTE TYPE 157 CREATE DIRECTORY
158 DROP DIRECTORY 159 CREATE LIBRARY
160 CREATE JAVA 161 ALTER JAVA
162 DROP JAVA 163 CREATE OPERATOR
164 CREATE INDEXTYPE 165 DROP INDEXTYPE
167 DROP OPERATOR 168 ASSOCIATE STATISTICS
169 DISASSOCIATE STATISTICS 170 CALL METHOD
171 CREATE SUMMARY 172 ALTER SUMMARY
173 DROP SUMMARY 174 CREATE DIMENSION
175 ALTER DIMENSION 176 DROP DIMENSION
177 CREATE CONTEXT 178 DROP CONTEXT
179 ALTER OUTLINE 180 CREATE OUTLINE
181 DROP OUTLINE 182 UPDATE INDEXES
183 ALTER OPERATOR -
How to Read the one Source Column data and Display the Results
Hi All,
I have one PR_ProjectType Column in my Mastertable,Based on that Column we need to reed the column data and Display the Results
Ex:
Pr_ProjectType
AD,AM
AD
AM
AD,AM,TS,CS.OT,TS
AD,AM
like that data will come now we need 1. Ad,AM then same we need 2. AD also same we need 3. AM also we need
4.AD,AM,TS,CS.OT,TS in this string we need AD,AM only.
this logic we need we have thousand of data in the table.Please help this is urgent issue
vasuHi Vasu,
Based on your description, you want to eliminate the substrings (eliminated by comma) that are not AD or AM in each value of the column. Personally, I don’t think this can be done by just using an expression in the Derived Column. To achieve your goal, here
are two approaches for your reference:
Method 1: On the query level. Replace the target substrings with different integer characters, and create a function to eliminate non-numeric characters, then replace the integer characters with the corresponding substrings. The statements
for the custom function is as follows:
CREATE FUNCTION dbo.udf_GetNumeric
(@strAlphaNumeric VARCHAR(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @intAlpha INT
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
BEGIN
WHILE @intAlpha > 0
BEGIN
SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
END
END
RETURN ISNULL(@strAlphaNumeric,0)
END
GO
The SQL commands used in the OLE DB Source is like:
SELECT
ID, REPLACE(REPLACE(REPLACE(REPLACE(dbo.udf_GetNumeric(REPLACE(REPLACE(REPLACE(REPLACE([ProjectType],'AD,',1),'AM,',2),'AD',3),'AM',4)),4,'AM'),3,'AD'),2,'AM,'),1,'AD,')
FROM MyTable
Method 2: Using a Script Component. Add a Derived Column Transform to replace the target substrings as method 1, use Regex in script to remove all non-numeric characters from the string, add another Derived Column to replace the integer
characters to the corresponding substring. The script is as follows:
using System.Text.RegularExpressions;
Row.OutProjectType= Regex.Replace(Row.ProjectType, "[^.0-9]", "");
References:
http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/
http://labs.kaliko.com/2009/09/c-remove-all-non-numeric-characters.html
Regards,
Mike Yin
TechNet Community Support -
Hello,
This is the first time I am using this forum. I am stuck and need some help. I received this error message both on SQL 2005 and 2008. I am currently using SQL 2008 DEV for testing purposes and I am experiencing this error message when trying to connect to Database Engine Tuning Advisor. I am using the SA account so I should not have any security issues. Also this is a fresh install of SQL 2008 DEV on a fresh install of Windows XP Pro with all SP. Can some please help.
Error:
"Failed to initialize MSDB database for tuning (exit code: -1073741819). (DTAClient)"
===================================
Failed to open a new connection.
===================================
Failed to initialize MSDB database for tuning (exit code: -1073741819). (DTAClient)
Program Location:
at Microsoft.SqlServer.Management.DTA.Client.TuningServer.InitializeTuningParametersDatabase()
at Microsoft.SqlServer.Management.DTA.Client.TuningServer.InitializeConnection()
at Microsoft.SqlServer.Management.DTA.Client.TuningServer.Connect()
at Microsoft.SqlServer.Management.DTA.Shell.SessionMonitor.AddServerInternal(SqlConnectionInfo connectionInfo, SqlConnection connection)
at Microsoft.SqlServer.Management.DTA.Shell.SessionMonitor.AddServer(SqlConnectionInfo connectionInfo, SqlConnection connection)
at Microsoft.SqlServer.Management.DTA.Shell.SessionMonitor.OnConnect(Object sender, EventArgs e)I created the below MSDB SP and Tables. Now the issue is resolved.
http://www.devnewsgroups.net/sqlservertools/t67379-database-engine-tuning-advisor.aspx
USE [msdb]
GO
/****** Object: StoredProcedure [dbo].[sp_DTA_start_xmlprefix] Script
Date: 12/31/2008 10:56:11 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[sp_DTA_start_xmlprefix]
as
begin
declare @startTags nvarchar(128)
set @startTags = N'<DTAXML><DTAOutput><AnalysisReport>'
select @startTags
end
GO
/****** Object: Table [dbo].[DTA_input] Script Date: 12/31/2008 10:56:59
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_input](
[SessionName] [sysname] NOT NULL,
[SessionID] [int] IDENTITY(1,1) NOT NULL,
[TuningOptions] [ntext] NOT NULL,
[CreationTime] [datetime] NOT NULL DEFAULT (getdate()),
[ScheduledStartTime] [datetime] NOT NULL DEFAULT (getdate()),
[ScheduledJobName] [sysname] NOT NULL DEFAULT (''),
[InteractiveStatus] [tinyint] NOT NULL DEFAULT ((0)),
[LogTableName] [nvarchar](1280) NOT NULL DEFAULT (''),
[GlobalSessionID] [uniqueidentifier] NULL DEFAULT (newid()),
PRIMARY KEY CLUSTERED
[SessionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_progress] Script Date: 12/31/2008
10:57:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_progress](
[ProgressEventID] [int] IDENTITY(1,1) NOT NULL,
[SessionID] [int] NULL,
[TuningStage] [tinyint] NOT NULL DEFAULT ((0)),
[WorkloadConsumption] [tinyint] NOT NULL,
[EstImprovement] [int] NOT NULL DEFAULT ((0)),
[ProgressEventTime] [datetime] NOT NULL DEFAULT (getdate()),
[ConsumingWorkLoadMessage] [nvarchar](256) NULL,
[PerformingAnalysisMessage] [nvarchar](256) NULL,
[GeneratingReportsMessage] [nvarchar](256) NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_output] Script Date: 12/31/2008
10:57:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_output](
[SessionID] [int] NOT NULL,
[TuningResults] [ntext] NOT NULL,
[StopTime] [datetime] NOT NULL DEFAULT (getdate()),
[FinishStatus] [tinyint] NOT NULL DEFAULT ((0)),
PRIMARY KEY CLUSTERED
[SessionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_tuninglog] Script Date: 12/31/2008
11:01:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_tuninglog](
[SessionID] [int] NOT NULL,
[RowID] [int] NOT NULL,
[CategoryID] [nvarchar](4) NOT NULL,
[Event] [ntext] NULL,
[Statement] [ntext] NULL,
[Frequency] [int] NOT NULL,
[Reason] [ntext] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_database] Script Date:
12/31/2008 10:57:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_database](
[DatabaseID] [int] IDENTITY(1,1) NOT NULL,
[SessionID] [int] NOT NULL,
[DatabaseName] [sysname] NOT NULL,
[IsDatabaseSelectedToTune] [int] NULL,
PRIMARY KEY CLUSTERED
[DatabaseID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_query] Script Date: 12/31/2008
10:59:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_query](
[QueryID] [int] NOT NULL,
[SessionID] [int] NOT NULL,
[StatementType] [smallint] NOT NULL,
[StatementString] [ntext] NOT NULL,
[CurrentCost] [float] NOT NULL,
[RecommendedCost] [float] NOT NULL,
[Weight] [float] NOT NULL,
[EventString] [ntext] NULL,
[EventWeight] [float] NOT NULL,
CONSTRAINT [DTA_reports_query_pk] PRIMARY KEY CLUSTERED
[SessionID] ASC,
[QueryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_querydatabase] Script Date:
12/31/2008 11:00:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_querydatabase](
[QueryID] [int] NOT NULL,
[SessionID] [int] NOT NULL,
[DatabaseID] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_table] Script Date: 12/31/2008
11:00:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_table](
[TableID] [int] IDENTITY(1,1) NOT NULL,
[DatabaseID] [int] NOT NULL,
[SchemaName] [sysname] NOT NULL,
[TableName] [sysname] NOT NULL,
[IsView] [bit] NOT NULL DEFAULT ((0)),
PRIMARY KEY CLUSTERED
[TableID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_partitionfunction] Script Date:
12/31/2008 10:58:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_partitionfunction](
[PartitionFunctionID] [int] IDENTITY(1,1) NOT NULL,
[DatabaseID] [int] NOT NULL,
[PartitionFunctionName] [sysname] NOT NULL,
[PartitionFunctionDefinition] [ntext] NOT NULL,
PRIMARY KEY CLUSTERED
[PartitionFunctionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_partitionscheme] Script Date:
12/31/2008 10:59:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_partitionscheme](
[PartitionSchemeID] [int] IDENTITY(1,1) NOT NULL,
[PartitionFunctionID] [int] NOT NULL,
[PartitionSchemeName] [sysname] NOT NULL,
[PartitionSchemeDefinition] [ntext] NOT NULL,
PRIMARY KEY CLUSTERED
[PartitionSchemeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_tableview] Script Date:
12/31/2008 11:01:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_tableview](
[TableID] [int] NOT NULL,
[ViewID] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_querytable] Script Date:
12/31/2008 11:00:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_querytable](
[QueryID] [int] NOT NULL,
[SessionID] [int] NOT NULL,
[TableID] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_index] Script Date: 12/31/2008
10:58:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_index](
[IndexID] [int] IDENTITY(1,1) NOT NULL,
[TableID] [int] NOT NULL,
[IndexName] [sysname] NOT NULL,
[IsClustered] [bit] NOT NULL DEFAULT ((0)),
[IsUnique] [bit] NOT NULL DEFAULT ((0)),
[IsHeap] [bit] NOT NULL DEFAULT ((1)),
[IsExisting] [bit] NOT NULL DEFAULT ((1)),
[Storage] [float] NOT NULL,
[NumRows] [int] NOT NULL,
[IsRecommended] [bit] NOT NULL DEFAULT ((0)),
[RecommendedStorage] [float] NOT NULL,
[PartitionSchemeID] [int] NULL,
[SessionUniquefier] [int] NULL,
PRIMARY KEY CLUSTERED
[IndexID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_column] Script Date: 12/31/2008
10:57:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_column](
[ColumnID] [int] IDENTITY(1,1) NOT NULL,
[TableID] [int] NOT NULL,
[ColumnName] [sysname] NOT NULL,
PRIMARY KEY CLUSTERED
[ColumnID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_queryindex] Script Date:
12/31/2008 11:00:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_queryindex](
[QueryID] [int] NOT NULL,
[SessionID] [int] NOT NULL,
[IndexID] [int] NOT NULL,
[IsRecommendedConfiguration] [bit] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_querycolumn] Script Date:
12/31/2008 10:59:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_querycolumn](
[QueryID] [int] NOT NULL,
[SessionID] [int] NOT NULL,
[ColumnID] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DTA_reports_indexcolumn] Script Date:
12/31/2008 10:58:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DTA_reports_indexcolumn](
[IndexID] [int] NOT NULL,
[ColumnID] [int] NOT NULL,
[ColumnOrder] [int] NULL,
[PartitionColumnOrder] [int] NOT NULL DEFAULT ((0)),
[IsKeyColumn] [bit] NOT NULL DEFAULT ((1)),
[IsDescendingColumn] [bit] NOT NULL DEFAULT ((1))
) ON [PRIMARY]
GO
/****** Object: StoredProcedure [dbo].[sp_DTA_check_permission] Script
Date: 12/31/2008 10:53:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[sp_DTA_check_permission]
@SessionID int
as
begin
declare @retcode int
declare @dbname nvarchar(128)
declare @sql nvarchar(256)
declare @dbid int
set nocount on
-- Check if SA
if (isnull(IS_SRVROLEMEMBER(N'sysadmin'), 0) = 1)
begin
return(0)
end
-- if not yukon return
if (patindex('%9.00.%',@@version) = 0)
begin
return (1)
end
-- declare and open a cursor and get all the databases specified in the input
declare db_cursor cursor for
select DatabaseName from DTA_reports_database
where SessionID = @SessionID and IsDatabaseSelectedToTune = 1
-- open
open db_cursor
-- fetch first db name
fetch next from db_cursor
into @dbname
-- loop and get all the databases selected to tune
while @@fetch_status = 0
begin
-- build use db string
select @dbid = DB_ID(@dbname)
-- In Yukon this masks the error messages
set @sql = N'begin try
dbcc autopilot(5,@dbid) WITH NO_INFOMSGS
end try
begin catch
set @retcode = 1
end catch'
execute sp_executesql @sql
, N'@dbid int output, @retcode int OUTPUT'
, @dbid output
, @retcode output
-- if caller is not member of dbo
if (@retcode = 1)
begin
-- close and reset cursor,switch context to current
-- database and return 1
close db_cursor
deallocate db_cursor
return(1)
end
fetch from db_cursor into @dbname
end
-- close and reset cursor,switch context to current
-- database and return 1
close db_cursor
deallocate db_cursor
return(0)
end
GO
/****** Object: StoredProcedure [dbo].[sp_DTA_index_usage_helper_xml]
Script Date: 12/31/2008 10:54:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[sp_DTA_index_usage_helper_xml]
@SessionID int,
@IsRecommended int
as
begin
select 1 as Tag,
NULL as Parent,
'' as [IndexUsageReport!1!!ELEMENT],
case when @IsRecommended = 1 then 'false'
else 'true' end as [IndexUsageReport!1!Current],
NULL as [Database!2!DatabaseID!hide],
NULL as [Database!2!Name!ELEMENT] ,
NULL as [Schema!3!Name!ELEMENT] ,
NULL as [Table!4!TableID!hide],
NULL as [Table!4!Name!ELEMENT],
NULL as [Index!5!IndexID!hide],
NULL as [Index!5!Name!ELEMENT],
NULL as [Index!5!NumberOfReferences!ELEMENT],
NULL as [Index!5!PercentUsage!ELEMENT]
union all
select 2 as Tag,
1 as Parent,
NULL as [IndexUsageReport!1!!ELEMENT],
NULL as [IndexUsageReport!1!Current],
D.DatabaseID as [Database!2!DatabaseID!hide],
D.DatabaseName as [Database!2!Name!ELEMENT] ,
NULL as [Schema!3!Name!ELEMENT] ,
NULL as [Table!4!TableID!hide],
NULL as [Table!4!Name!ELEMENT],
NULL as [Index!5!IndexID!hide],
NULL as [Index!5!Name!ELEMENT],
NULL as [Index!5!NumberOfReferences!ELEMENT],
NULL as [Index!5!PercentUsage!ELEMENT]
from [msdb].[dbo].[DTA_reports_database] as D
where
D.SessionID = @SessionID and
D.DatabaseID in
(select D.DatabaseID from
[msdb].[dbo].[DTA_reports_queryindex] as QI,
[msdb].[dbo].[DTA_reports_index] as I,
[msdb].[dbo].[DTA_reports_table] as T,
[msdb].[dbo].[DTA_reports_database] as D
where
QI.IndexID = I.IndexID and
I.TableID = T.TableID and
T.DatabaseID = D.DatabaseID and
D.SessionID = @SessionID and
QI.IsRecommendedConfiguration = @IsRecommended
GROUP BY D.DatabaseID)
union all
select 3 as Tag,
2 as Parent,
NULL as [IndexUsageReport!1!!ELEMENT],
NULL as [IndexUsageReport!1!Current],
D.DatabaseID as [Database!2!DatabaseID!hide],
D.DatabaseName as [Database!2!Name!ELEMENT] ,
R.SchemaName as [Schema!3!Name!ELEMENT] ,
NULL as [Table!4!TableID!hide],
NULL as [Table!4!Name!ELEMENT],
NULL as [Index!5!IndexID!hide],
NULL as [Index!5!Name!ELEMENT],
NULL as [Index!5!NumberOfReferences!ELEMENT],
NULL as [Index!5!PercentUsage!ELEMENT]
from [msdb].[dbo].[DTA_reports_database] as D,
select D.DatabaseID,T.SchemaName from
[msdb].[dbo].[DTA_reports_queryindex] as QI,
[msdb].[dbo].[DTA_reports_index] as I,
[msdb].[dbo].[DTA_reports_table] as T,
[msdb].[dbo].[DTA_reports_database] as D
where
QI.IndexID = I.IndexID and
I.TableID = T.TableID and
T.DatabaseID = D.DatabaseID and
QI.IsRecommendedConfiguration = @IsRecommended and
D.SessionID = @SessionID
GROUP BY D.DatabaseID,T.SchemaName
) R
where
D.SessionID = @SessionID and
D.DatabaseID = R.DatabaseID
union all
select 4 as Tag,
3 as Parent,
NULL as [IndexUsageReport!1!!ELEMENT],
NULL as [IndexUsageReport!1!Current],
D.DatabaseID as [Database!2!DatabaseID!hide],
D.DatabaseName as [Database!2!Name!ELEMENT] ,
R.SchemaName as [Schema!3!Name!ELEMENT] ,
R.TableID as [Table!4!TableID!hide],
T.TableName as [Table!4!Name!ELEMENT],
NULL as [Index!5!IndexID!hide],
NULL as [Index!5!Name!ELEMENT],
NULL as [Index!5!NumberOfReferences!ELEMENT],
NULL as [Index!5!PercentUsage!ELEMENT]
from [msdb].[dbo].[DTA_reports_database] as D,
[msdb].[dbo].[DTA_reports_table] as T,
select D.DatabaseID,T.SchemaName,T.TableID from
[msdb].[dbo].[DTA_reports_queryindex] as QI,
[msdb].[dbo].[DTA_reports_index] as I,
[msdb].[dbo].[DTA_reports_table] as T,
[msdb].[dbo].[DTA_reports_database] as D
where
QI.IndexID = I.IndexID and
I.TableID = T.TableID and
T.DatabaseID = D.DatabaseID and
D.SessionID = @SessionID and
QI.IsRecommendedConfiguration = @IsRecommended
GROUP BY D.DatabaseID,T.SchemaName, T.TableID
) R
where
D.SessionID = @SessionID and
D.DatabaseID = R.DatabaseID and
R.TableID = T.TableID and
T.DatabaseID = D.DatabaseID
union all
select 5 as Tag,
4 as Parent,
NULL as [IndexUsageReport!1!!ELEMENT],
NULL as [IndexUsageReport!1!Current],
D1.DatabaseID as [Database!2!DatabaseID!hide],
D1.DatabaseName as [Database!2!Name!ELEMENT] ,
T1.SchemaName as [Schema!3!Name!ELEMENT] ,
T1.TableID as [Table!4!TableID!hide],
T1.TableName as [Table!4!Name!ELEMENT],
I1.IndexID as [Index!5!IndexID!hide],
I1.IndexName as [Index!5!Name!ELEMENT],
R.Count as [Index!5!NumberOfReferences!ELEMENT],
CAST(R.Usage as decimal(38,2)) as [Index!5!PercentUsage!ELEMENT]
from
[msdb].[dbo].[DTA_reports_database] as D1 ,
[msdb].[dbo].[DTA_reports_index] as I1,
[msdb].[dbo].[DTA_reports_table] as T1,
select D.DatabaseID,T.TableID ,
I.IndexID ,SUM(Q.Weight) as Count,
100.0 * SUM(Q.Weight) /
( 1.0 * ( select CASE WHEN SUM(Q.Weight) > 0 THEN SUM(Q.Weight)
else 1
end
from [msdb].[dbo].[DTA_reports_query] as Q
where Q.SessionID = @SessionID ))
as Usage
from
[msdb].[dbo].[DTA_reports_index] as I
LEFT OUTER JOIN
[msdb].[dbo].[DTA_reports_queryindex] as QI ON QI.IndexID = I.IndexID
LEFT OUTER JOIN
[msdb].[dbo].[DTA_reports_query] as Q ON QI.QueryID = Q.QueryID
JOIN
[msdb].[dbo].[DTA_reports_table] as T ON I.TableID = T.TableID
JOIN
[msdb].[dbo].[DTA_reports_database] as D ON T.DatabaseID = D.DatabaseID
and Q.SessionID = QI.SessionID and
QI.IsRecommendedConfiguration = @IsRecommended and
Q.SessionID = @SessionID
GROUP BY I.IndexID,T.TableID,D.DatabaseID) as R
where R.DatabaseID = D1.DatabaseID and
R.TableID = T1.TableID and
R.IndexID = I1.IndexID and
D1.SessionID = @SessionID and
R.Count > 0
order by
[Database!2!DatabaseID!hide],[Schema!3!Name!ELEMENT],[Table!4!TableID!hide],
[Index!5!NumberOfReferences!ELEMENT] , [Index!5!IndexID!hide]
FOR XML EXPLICIT
end
GO
/****** Object: StoredProcedure
[dbo].[sp_DTA_index_usage_helper_relational] Script Date: 12/31/2008
10:54:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[sp_DTA_index_usage_helper_relational]
@SessionID int,
@IsRecommended int
as begin select D1.DatabaseName as 'Database Name' ,T1.SchemaName as
'Schema Name' ,T1.TableName as 'Table/View Name' ,I1.IndexName as 'Index
Name' ,R.Count as 'Number of references' ,CAST(R.Usage as decimal(38,2)) as
'Percent Usage' from
DTA_reports_database as D1 ,
DTA_reports_index as I1,
DTA_reports_table as T1,
select D.DatabaseID,T.TableID ,
I.IndexID ,SUM(Q.Weight) as Count,
100.0 * SUM(Q.Weight) /
( 1.0 * ( select CASE WHEN SUM(Q.Weight) > 0 THEN SUM(Q.Weight)
else 1
end
from [msdb].[dbo].[DTA_reports_query] as Q
where Q.SessionID = @SessionID ))
as Usage
from
[msdb].[dbo].[DTA_reports_index] as I
LEFT OUTER JOIN
[msdb].[dbo].[DTA_reports_queryindex] as QI ON QI.IndexID = I.IndexID
LEFT OUTER JOIN
[msdb].[dbo].[DTA_reports_query] as Q ON QI.QueryID = Q.QueryID
JOIN
[msdb].[dbo].[DTA_reports_table] as T ON I.TableID = T.TableID
JOIN
[msdb].[dbo].[DTA_reports_database] as D ON T.DatabaseID = D.DatabaseID
and Q.SessionID = QI.SessionID and
QI.IsRecommendedConfiguration = @IsRecommended and
Q.SessionID = @SessionID
GROUP BY I.IndexID,T.TableID,D.DatabaseID) as R
where R.DatabaseID = D1.DatabaseID and
R.TableID = T1.TableID and
R.IndexID = I1.IndexID and
D1.SessionID = @SessionID and
R.Count > 0
order by R.Count desc end
GO
/****** Object: StoredProcedure [dbo].[sp_DTA_database_access_helper_xml]
Script Date: 12/31/2008 10:53:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[sp_DTA_database_access_helper_xml]
@SessionID int
as
begin
select 1 as Tag,
NULL as Parent,
'' as [DatabaseAccessReport!1!!ELEMENT],
NULL as [Database!2!Name!ELEMENT] ,
NULL as [Database!2!NumberOfReferences!ELEMENT],
NULL as [Database!2!PercentUsage!ELEMENT]
union all
select 2 as Tag, 1 as Parent,NULL,D1.DatabaseName ,
R.Count ,
CAST(R.Usage as decimal(38,2)) from
[msdb].[dbo].[DTA_reports_database] as D1 ,
select D.DatabaseID,SUM(Q.Weight) as Count,
100.0 * SUM(Q.Weight) /
( 1.0 * ( select CASE WHEN SUM(Q.Weight) > 0 THEN SUM(Q.Weight)
else 1
end
from [msdb].[dbo].[DTA_reports_query] as Q
where Q.SessionID = @SessionID ))
as Usage
from
[msdb].[dbo].[DTA_reports_database] as D
LEFT OUTER JOIN
[msdb].[dbo].[DTA_reports_querydatabase] as QD ON QD.DatabaseID =
D.DatabaseID
LEFT OUTER JOIN
[msdb].[dbo].[DTA_reports_query] as Q ON QD.QueryID = Q.QueryID
and Q.SessionID = QD.SessionID and
Q.SessionID = @SessionID
GROUP BY D.DatabaseID
) as R
where R.DatabaseID = D1.DatabaseID and
D1.SessionID = @SessionID and
R.Count > 0
order by Tag,[Database!2!NumberOfReferences!ELEMENT] desc
FOR XML EXPLICIT
end
GO
Maybe you are looking for
-
Nokia 603, doesnt switch on and shutdown after Nok...
respected sir, i have recently bought a new nokia 603 ( march 2012 ) and didint used it much uptill now just 1 hour talk counter it runned uptill now, i upgrade it as soon as i bought it in the month of march, till 10th april it showed that your phon
-
Photoshop Elements 7 Organizer crashing
Recently upgraded from Windows Vista 32 bit to Windows 7 64 bit. Organizer was working fine but yesterday started to crash soon after opening. I followed the John Rellis instructions but this did not help. Before the crash I get a strange message tha
-
My iPad apps updates are not downloading
I have updates coming up on my apps but when I go to download they are not installing can anyone help out
-
Q: Accessing lower level classes
I'm having trouble even phrasing this question, so please bear with me. I have several classes in a hierarchy (5 levels deep). All have empty constructors and each has an addXXXX method to populate the required internal attributes. The addXXXX method
-
A former colleague set up OSB on a server several months ago. Now I am trying to sign in the "file system backup and restore" area, and need the user name and password that was created. This must be a different user name than OSB Admin -- and of cour