How to get numbers of code line change in TFS? - tfs

I'm looking for a way in TFS, I need to get the numbers of Code line change for individual developer between 2 dates, do you think it is doable via TFS?
Any help is appreciate, thanks!

Look in the TFS data warehouse. There is a FactCodeChurn table that should contain the data you're after.

You can use below SQL query statement:
SELECT TeamProjectProjectNodeName
,checkedinbyname
,SUM([LinesAdded]) AS
,SUM([LinesModified]) AS
,SUM([LinesAdded]+[LinesModified]) AS
,CONVERT(VARCHAR(10), MIN(DateTime),120) AS
,CONVERT(VARCHAR(10),MAX(DateTime),120) AS
FROM [Tfs_Warehouse].[dbo].[CodeChurnView] WHERE TeamProjectProjectNodeName='xxx' AND ChangesetTitle NOT LIKE 'xx' AND FilenameFileExtension IN('.css','.cs','.aspx','.sql','js','.ascx') AND (LinesDeleted <>0 OR LinesModified<>0 OR FilenameFilePath LIKE '$/XX' AND FilenameFileExtension IN('.sql')) AND NetLinesAdded>=0 GROUP BY TeamProjectProjectNodeName, checkedinbyname
ORDER BY DESC
Note: You must have permission to access the Tfs_Warehouse database to execute the above statement.

Related

Can Firedac handle conditional SQL statements

Is there a way to use Firedac to handle conditional scenarios.
Master Table has a column called INVOICESCOUNT.
When an invoice is deleted successfully, then the INVOICESCOUNT is decreased.
For example, a SQL psuedo-code statement like this:
Delete From Invoices where INVOICE=500;
Update Customers SET INVOICECOUNT=INVOICECOUNT-1 WHERE Customer=1 (if prior statement returns 1 affected row);
I need it to be embedded within the same SQL statement instead of having the Delphi source code handling executing the 2 statements separately, after the first FDQuery returns a successful execution.
Thanks for any advice.
That's fine ?
I understood, lack of attention from me, in this case I could use the information from the DBMS itself, an example, if the DBMS is SQL server.
Delete From Invoices where INVOICE=500
IF ##ROWCOUNT=1
begin
Update Customers SET INVOICECOUNT=INVOICECOUNT-1
WHERE Customer=1
end.
If your DBMS doesn't allow it, I recommend you to use a stored procedure.

Is there any way to get the syntax of an SQL statement when using SQLPlus?

I have an exam using SQLPlus and sometimes I don't remember the exact syntax of SQL statements, so I was wondering if there is any way to get some nice inline help from inside SQLPlus.
For instance, say I forgot how to use INSERT INTO, and I want some reminder like this:
INSERT INTO table-name (column-names)
VALUES (values)
Is this possible?
I tried HELP command but none of that seems to suits my needs.
I Googled it with no success.
No. SQL is a standardized language (at least ANSI SQL) and SQLPlus "just" uses that syntax, so it's not covered by internal help. Internal help lists only SQLPlus specific commands (ex. SET, CONNECT, SPOOL).
It is possible to workaround that in some way, but very limited. You can call dbms_metadata.get_ddl function for some existing object. Some of those DDLs could have statements you are intrested in. For example - you'd like to see select statement - then you could call dbms_metadata.get_ddl for some existing view:
select dbms_metadata.get_ddl('VIEW', 'USER_TABLES', 'SYS')
from dual;
Be aware - it works only for Oracle 11G and lower, in the newest one SYS objects are not accessible in that way (I'm not sure about Oracle 12.1).
The more interesting are tiggers, procedures, functions, and packages. You cannot use dbms_metadata to get DDLs of packages owned by SYS, but maybe you can connect to some sample schemas like HR (Human Resources), AD (Academic), SH (Sales History).
In HR schema there is stored procedure ADD_JOB_HISTORY, which has inside insert statement, so it looks like that:
select dbms_metadata.get_ddl('PROCEDURE', 'ADD_JOB_HISTORY')
from dual;
CREATE OR REPLACE EDITIONABLE PROCEDURE "HR"."ADD_JOB_HISTORY"
( p_emp_id job_history.employee_id%type
, p_start_date job_history.start_date%type
, p_end_date job_history.end_date%type
, p_job_id job_history.job_id%type
, p_department_id job_history.department_id%type
)
IS
BEGIN
INSERT INTO job_history (employee_id, start_date, end_date,
job_id, department_id)
VALUES(p_emp_id, p_start_date, p_end_date, p_job_id, p_department_id);
END add_job_history;
There are better ways and better tools to achieve your goal - see below.
Are you allowed to use SQL Developer instead of SQLPlus? SQL Developer has nice feature to drag-and-drop table icon into worksheet, then you will be nicely prompted to choose what kind of example statement you are looking for (SELECT, INSERT, UPDATE etc.) - after choosing one you will get sample statement.
But the best way is just open in browser Database SQL Language Reference:
https://docs.oracle.com/database/121/SQLRF/toc.htm

Add more than current iteration to your queries view (TFS 2018)

Anybody who knows if it possible to configure the queries view to show more than the current iteration.
Yes, it possible. You can do next:
Create new folder for queries.
Edit existing query.
Save that query to new destination.
Also you can use Group clauses
Additional information you can find here: https://learn.microsoft.com/en-us/vsts/work/track/using-queries

TFS Build data from TFS_Analysis

I need to fetch all build records with following fields, BuildName, VersionNo, BuildDate & BuildStatus from TFS_Analysis. Can someone help me to write MDX query for this.
Am unable to see BuildStatus field in TFS_Warehouse DB hence trying to get it from TFS_Analysis.
It looks a little bit like sql but the way things work are a world apart from sql. The following is complete guess work as there is not much detail in your question!...
SELECT
[Measures].[SOMEMEASUREINCUBE] ON 0
,
[BuildName].[BuildName].MEMBERS*
[VersionNo].[VersionNo].MEMBERS*
[BuildDate].[BuildDate].MEMBERS*
[BuildStatus].[BuildStatus].MEMBERS ON 1
FROM TFS_Analysis;

Query work items directy on sql database incase wiql

Because fetch work items from wiql that is very low. I would like to fetch them from database directly but I don't know which table should I get them?
there are 9 views that are intended for creating reports in TFS 2012:
CurrentWorkItemView
WorkItemHistoryView
BuildChangesetView
BuildCoverageView
BuildDetailsView
BuildProjectView
CodeChurnView
RunCoverageView
TestResultView
Please find more info at http://blogs.msdn.com/b/granth/archive/2010/05/09/tfs2010-how-to-query-work-items-using-sql-on-the-relational-warehouse.aspx

Resources