I try to create a WIQL query that compares field contents of a work item and its related (linked) work items, e.g. where the 'state' of the work item is different from the 'state' of the related work item.
SELECT [System.Id], ... FROM WorkItemLinks WHERE ...
[Source].[System.State] <> [Target].[System.State])
ORDER BY [System.CreatedDate] desc, [System.AssignedTo] mode(MayContain)
(The ... above only indicate the parts that I have ommitted here for clarity.)
When I try to apply the query, I get this error message from TFS:
The link query can not mix expression with different prefixes
Is there a way to compare source and target fields with WIQL?
No, just as the error message indicates, you cannot mix expression with different prefixes. So you cannot compare the field in Source and Target directly. Refer to this link from MSDN for details: http://blogs.msdn.com/b/team_foundation/archive/2010/07/02/wiql-syntax-for-link-query.aspx
However, for the fields with pre-defined list values, you can write the query like following to achieve the feature you want.
SELECT [System.Id] FROM WorkItemLinks WHERE
([Source].[System.State] = ‘New’ and [Target].[System.State] <> ‘New’)
OR ([Source].[System.State] = ‘Resolved’ and [Target].[System.State] <> ‘Resolved’)
OR ([Source].[System.State] = ‘Active’ and [Target].[System.State] <> ‘Active’)
OR ([Source].[System.State] = ‘Closed’ and [Target].[System.State] <> ‘Closed’)
ORDER BY [System.CreatedDate] desc, [System.AssignedTo] mode(MayContain)
Related
Trying to leverage the WIQL Editor feature:
'ever contains tag'
Searching Syntax, Trial and Error
Select
[System.Id],
[System.Title],
[System.State],
[System.Tags]
From WorkItems
Where [System.WorkItemType] = 'Change Request'
AND [State] <> 'Closed'
AND [State] <> 'Cancelled'
AND EVER [Tags] CONTAINS 'My Tag'
order by [Microsoft.VSTS.Common.Priority] asc,
[System.CreatedDate] desc
Expect it to return all work items that ever had a specific tag.
No, it's not able to do this through work item query at present.
Even though TFS supports a “Was Ever” operator for work item queries. But this operator is not applicable to all fields. As you can see, unlike assign to filed, the tag field only have Contians and Does Not Contain two operators.
So according to your Syntax AND EVER [Tags] CONTAINS 'My Tag'. This will not return all work items that ever had a specific tag.
For your requirement, you need to use Rest API or Client API to fetch the history of a work item and filter the tag value you have ever added in the record of all history info. It's a little bit complicated.
I have a dataset created from a stored procedure by passing it a multi-value parameter. What I now need is to check whether all values from the parameter came back in a specific column of my result set or not, and if not, then display those values in the report.
So, for example, if I'm passing values 'a', 'b', 'c' and 'd' to my parameter, and if my dataset column only contains 'a' and 'd', then I need a way to display 'b' and 'c' on the report.
Thanks,
Pratik
First, you'll need a query that is supplying the values for your parameter. The query might look something like this:
select 'a' as ParamValue
union all
select 'b' as ParamValue
union all
select 'c' as ParamValue
union all
select 'd' as ParamValue
Set you parameter values to be populated by this query:
Now Add a table that can list your parameter values.
Next, you can check if each value exists in your main dataset using a Lookup function like this:
=IIf(IsNothing(Lookup(Fields!PARAMVALUE.Value,Fields!COLVALUE.Value,Fields!COLVALUE.Value, "MainDataSet")), True, False)
You can use this as a filter to just show the parameter values where this function doesn't return a value:
Can you change the stored procedure (or make a new one based on the old one for this report)? If so, then you could change from an INNER JOIN to an OUTER JOIN and get that result. For example, if your stored procedure showed how much clients were billed last month and looked like:
SELECT ClientName, SUM(BillAmount) AS TotalBilled
FROM Clients
INNER JOIN Bills ON Clients.ClientId = Bills.ClientId AND Bills.BillDate >= DateAdd(m, -1, GetDate())
WHERE ClientId IN #ClientIds
GROUP BY ClientName
ORDER BY ClientName
then this would exclude any clients not billed. If you change to an OUTER JOIN like so:
SELECT ClientName, SUM(BillAmount) AS TotalBilled
FROM Clients
LEFT OUTER JOIN Bills ON Clients.ClientId = Bills.ClientId AND Bills.BillDate >= DateAdd(m, -1, GetDate())
WHERE ClientId IN #ClientIds
GROUP BY ClientName
ORDER BY ClientName
then clients with no bills would still show with a Null amount for the amount billed
We have a Team Project Collection Source Control Setting for Check-in Notes that requires each check-in to capture a "Tracking Number". This number is external to TFS. I need to search for all the changesets that have a specific Tracking number.
The resulting changeset list tells me what to get latest version on, for a monthly deployment.
We don't use Work Items.
Question 1) Where in tfs_default_collection are the notes stored? One way to easily look would be to query with .SQL. I don't see "Note" in any of the database schemas.
Question 2) If I can't use .SQL to search, what object reference in Microsoft.TeamFoundation.VersionControl.Client.dll will give me the details of the Check-in Notes?
If I know what the changeset number is, then I can do something like this to give me the list.
-- these are all the .slq objects checked in $Release on '2013-01-28'
SELECT
chg_set.CreationDate,
chg_set.ChangeSetId,
v.FullPath
FROM dbo.tbl_ChangeSet (nolock)AS chg_set
INNER JOIN dbo.tbl_Version (nolock)AS v ON chg_set.ChangeSetId = v.VersionFrom
LEFT OUTER JOIN dbo.tbl_File (nolock) AS f ON v.FileId = f.FileId
WHERE chg_set.CreationDate >= '2013-01-31'
and FullPath like '%Tracker\Releases\2013.02.31%'
and FullPath like '%.sql%'
ORDER BY chg_set.CreationDate, v.FullPath
After some more digging into TFS_DefaultCollection I found it.
I can join these results with the query above and see exactly what I am looking for.
SELECT ReleaseNoteId, FieldName, BaseValue
from Tfs_DefaultCollection.dbo.tbl_ReleaseNoteDetails
where ReleaseNoteId in (SELECT ReleaseNoteId
FROM Tfs_DefaultCollection.dbo.tbl_ReleaseNote
where DateCreated between '2013-01-18' and '2013-02-22')
and FieldName = 'Tracker #'
and BaseValue <> '0' -- base value of zero is a merge from $Main
Thank you, in advance.
I have 14 fields which are similar and I search the string 'A' on each of them. I would like after that order by "position" field
-- some set in order to remove a lot of useless text
def col='col01'
select '&col' "Fieldname",
&col "value",
position
from oneTable
where &col like '%A%'
/
-- then for the second field, I only have to type two lines
def col='col02'
/
...
def col='col14'
/
Write all the fields which contains 'A'. The problem is that those field are not ordered by position.
If I use UNION between table, I cannot take advantage of the substitution variables (&col), and I have to write a bash in unix in order to make the replacement back into ksh. The problem is of course that database code have to be hard-coded in this script (connection is not easy stuff).
If I use a REFCURSOR with OPEN, I cannot group the results sets together. I have only one request and cannot make an UNION of then. (print refcursor1 union refcursor2; print refcursor1+refcursor2 raise an exception, select * from refcursor1 union select * from refcursor2, does not work also).
How can concatenate results into one big "REFCURSOR"? Or use a union between two distinct run ('/') of my request, something like holding the request while typing new definition of variables?
Thank you for any advice.
Does this answer your question ?
CREATE TABLE #containingAValueTable
(
FieldName VARCHAR(10),
FieldValue VARCHAR(1000),
position int
)
def col='col01'
INSERT INTO #containingAValueTable
(
FieldName , FieldValue, position
)
SELECT '&col' "Fieldname",
&col "value",
position
FROM yourTable
WHERE &col LIKE '%A%'
/
-- then for the second field, I only have to type two lines
def col='col02'
INSERT INTO...
/
def col='col14'
/
select * from #containingAValueTable order by postion
DROP #containingAValueTable
But I'm not totally sure about your use of the 'substitution variable' called "col" (and i only have SQL Server to test my request so I used explicit field names)
edit : Sorry for the '#' charcater, we use it so often in SQL Server for temporaries, I didn't even know it was SQL Server specific (moreover I think it's mandatory in sql server for creating temporary table). Whatever, I'm happy I could be useful to you.
I have a scenario in which I want to show the following columns defined in the query but when I bind the workitems collection to the grid it is getting some columns defined in the query and some are missing, also I am seeing some extra columns which i have not define in the query.
const string wiqlQuery = #"SELECT [System.Id],
[System.Title],
[System.AssignedTo],
[Microsoft.VSTS.Scheduling.CompletedWork],
[Microsoft.VSTS.Scheduling.RemainingWork]
FROM WorkItems
WHERE [System.WorkItemType] = 'Document'
and [Tyler.Document.Type] = '03-Design Document'
ORDER BY [System.Title]";
var workItems = workItemStore1.Query(wiqlQuery);
dataGridView1.DataSource = workItems;
If the fields are custom fields, you are going to have to get them explicitly and bind them explicitly. Only the standard "system" fields are exposed as properties. The rest you have to get through an array.
When your grid has 'autofinding' columns, it could be possible that the returned result shows only the fields that have data.