I need to create a SCCM 2007 report to check the time zone over a specific collection. I found something to do this, but is not working when i insert it in the Report SQL Statement.
select SMS_R_System.Name, SMS_R_System.SMSAssignedSites, SMS_R_System.IPAddresses, SMS_R_System.IPSubnets, SMS_R_System.OperatingSystemNameandVersion, SMS_R_System.ResourceDomainORWorkgroup, SMS_R_System.LastLogonUserDomain, SMS_R_System.LastLogonUserName, SMS_R_System.SMSUniqueIdentifier, SMS_R_System.ResourceId, SMS_R_System.ResourceType, SMS_R_System.NetbiosName, SMS_G_System_COMPUTER_SYSTEM.CurrentTimeZone from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.CurrentTimeZone != -360 order by name
For a report you need to use the database views, see below for a quickly modified query which should do what you need:
select
v_R_System.Name0,
v_GS_COMPUTER_SYSTEM.CurrentTimeZone0
from v_R_System
inner join v_GS_COMPUTER_SYSTEM on v_GS_COMPUTER_SYSTEM.ResourceID = v_R_System.ResourceId
join v_FullCollectionMembership ON v_FullCollectionMembership.ResourceID = v_R_System.ResourceID
where
v_GS_COMPUTER_SYSTEM.CurrentTimeZone0 != -360
AND v_FullCollectionMembership.CollectionID = '<yourcollectionid>'
order by Name0
Just replace "<yourcollectionid>" with the id you want to query.
Related
Can someone identify why this multi-table join is not accepted? When I bring in the third table, it then fails with invalid table alias. I am not seeing what is wrong:
This works (two table):
select
a.ri as `R_ID`
,oc3.name as `RET`
,a.rch as `RC`
from dev.sl a join dev.codes oc3
on (a.pk_business = oc3.pk_business
and a.pk_data_source = oc3.pk_data_source
and a.pk_frequency = oc3.pk_frequency
and oc3.pk_data_state = '123'
and oc3.code = a.ri and oc3.codeset = 'xyz')
Then add a third table and it fails:
(Three table):
select
a.ri as `R_ID`
,oc3.name as `RET`
,a.rch as `RC`
from dev.sl a join dev.codes oc3
on (a.pk_business = oc3.pk_business
and a.pk_data_source = oc3.pk_data_source
and a.pk_frequency = oc3.pk_frequency
and oc3.pk_data_state = '123'
and oc3.code = a.ri and oc3.codeset = 'xyz') join dev.items b
on (b.pk_business = a.pk_business
and b.pk_data_source = a.pk_data_source
and b.pk_frequency = a.pk_frequency
and b.pk_data_state = '123'
and a.ii = b.item_id
and a.cc = b.country_code)
SemanticException [Error 10009]: Line 1:2920 Invalid table alias 'a':
I have an update - it seems that this was caused by having one table created as an updatable table (TBLPROPERTIES ('transactional'='true')), and one without, and with my session settings of:
SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
SET hive.support.concurrency=true;
SET hive.enforce.bucketing=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
This caused the problem. On another session without the settings AND repointing to an identical table "a" created as a non-ACID type table, the multi-table join worked fine. I don't know enough about HIVE to know why - I suspect that a transactional and non-transactional table cannot be joined in the same "transaction" (select statement).
One more update - It may not be due to the transactional table. With additional testing, I now also see it happens with non-transactional tables as well. It seems that the three table join works when I execute it from a putty session directly on the server, but when I use SQL Developer, it will produce the aforementioned error. It appears to be an issue with SQL Developer, but why still is unknown.
I want to create basically an update query on Open Office Base (the same way with Ms ACCESS).
Base does not typically use update queries (but see below). Instead, the easiest way to do an update command is to go to Tools -> SQL. Enter something similar to the following, then press Execute:
UPDATE "Table1" SET "Value" = 'BBB' WHERE ID = 0
The other way is to run the command with a macro. Here is an example using Basic:
Sub UpdateSQL
REM Run an SQL command on a table in LibreOffice Base
Context = CreateUnoService("com.sun.star.sdb.DatabaseContext")
databaseURLOrRegisteredName = "file:///C:/Users/JimStandard/Desktop/New Database.odb"
Db = Context.getByName(databaseURLOrRegisteredName )
Conn = Db.getConnection("","") 'username & password pair - HSQL default blank
Stmt = Conn.createStatement()
'strSQL = "INSERT INTO ""Table1"" (ID,""Value"") VALUES (3,'DDD')"
strSQL = "UPDATE ""Table1"" SET ""Value"" = 'CCC' WHERE ID = 0"
Stmt.executeUpdate(strSQL)
Conn.close()
End Sub
Note that the data can also be modified with a form or by editing the table directly.
Under some circumstances it is possible to create an update query. I couldn't get this to work with the default built-in HSQLDB 1.8 engine, but it worked with MYSQL.
In the Queries section, Create Query in SQL View
Click the toolbar button to Run SQL Command directly.
Enter a command like the following:
update mytable set mycolumn = 'This is some text.' where ID = 59;
Hit F5 to run the query.
It gives an error that The data content could not be loaded, but it still performs the update and changes the data. To get rid of the error, the command needs to return a value. For example, I created this stored procedure in MYSQL:
DELIMITER $$
CREATE PROCEDURE update_val
(
IN id_in INT,
IN newval_in VARCHAR(100)
)
BEGIN
UPDATE test_table SET value = newval_in WHERE id = id_in;
SELECT id, value FROM test_table WHERE id = id_in;
END
$$
DELIMITER ;
Then this query in LibreOffice Base modifies the data without giving any errors:
CALL update_val(2,'HHH')
See also:
https://forum.openoffice.org/en/forum/viewtopic.php?f=5&t=75763
https://forum.openoffice.org/en/forum/viewtopic.php?f=61&t=6655
https://ask.libreoffice.org/en/question/32700/how-to-create-an-update-query-in-base-sql/
Modifying table entries from LibreOffice Base, possible?
SETUP:
asp.net MVC
SQL SERVER 2008 R2
I have a procedure to get a list of messages to send. I want to update the results records so I cannot accidentally pull the same records twice. Regardless of how I approach it, SSMS produces the correct list of messages. However, if I update the records in the same procedure, C# does not get any results.
I have tried using a DataAdapter like this:
var da = new SqlDataAdapter(cmd);
da.Fill(table);
and DataReader like this:
var dataReader = cmd.ExecuteReader();
table.Load(dataReader);
dataReader.Close();
to populate my DataTable, neither seems to affect the results.
My procedure looks like this:
ALTER PROCEDURE [dbo].[MnxNoticeGetMessages]
#sessionId uniqueidentifier = null
AS
BEGIN
SET NOCOUNT ON;
DECLARE #Output TABLE (messageid uniqueidentifier)
INSERT INTO #Output
SELECT messageid FROM MnxTriggerEmails WHERE dateSent is null
SELECT * FROM MnxTriggerEmails WHERE messageid IN (SELECT messageid FROM #Output)
UPDATE MnxTriggerEmails SET dateSent=GETDATE()
WHERE messageid IN (SELECT * FROM #Output)
END
This produces results in SSMS but not in C#.
If I comment out the UPDATE like this (no other changes):
--UPDATE MnxTriggerEmails SET dateSent=GETDATE()
-- WHERE messageid IN (SELECT * FROM #Output)
I get the expected results in both SSMS and C#.
What am I missing? What would cause this? How do I update the records AND get the results at the same time?
Your code looks fine. It should work. It almost sounds like you are calling the sp twice. The first time changes the dates and the second returns no results. This would cause ssms to produce the desired results and c# to be empty.
Check the code you haven't posted and see if you make that call again before populating the DataTable.
i am developing report plugin for jira where i need to get assignee for given duration.it could be diffrent than current assignee in given duration.
now i am building my query in report like below.
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
query = queryBuilder.where().updatedBetween(stdate,endDate).and().assignee() in(status_val).buildQuery();
return searchProvider.searchCount(query, remoteUser);
i want to get the count for prior assigned issues for given duration.
please let me know how i can use Was clause with assignee and updatedbetween dates.
regards,
tousif shaikh.
Try reading this answer. In short, you'll need to define a new clause and use it in your query, like this:
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
WasClauseImpl wasClause = new WasClauseImpl("status", Operator.WAS, new SingleValueOperand("Resolved"), new TerminalHistoryPredicate(Operator.AFTER, new SingleValueOperand(3500000L)));
JqlClauseBuilder clauseBuilder = JqlQueryBuilder.newClauseBuilder(wasClause);
Query query = clauseBuilder.buildQuery();
I'd like to know which is parent/child relationship for task in th TFS datawarehouse or db.
For example the parentID=15662 and childID=15667, where I can find this information in the DW or db?
I think this will get you close to what you need. It just pulls the parent UserStory with a particular ID and all of it's children. The work item types may need to be changed based on your team project template. You can look at the different link types in DimWorkItemLinkType and adjust the query accordingly to get the desired result.
USE Tfs_Warehouse
GO
SELECT story.System_ID AS StoryID
, story.System_Title AS StoryTitle
, task.System_ID AS TaskID
, task.System_Title AS TaskTitle
, linkType.ReferenceName
, linkType.LinkName
FROM CurrentWorkItemView story
LEFT JOIN dbo.vFactLinkedCurrentWorkItem linkToStory
ON story.WorkItemSK = linkToStory.SourceWorkItemSK
LEFT JOIN CurrentWorkItemView task
ON linkToStory.TargetWorkitemSK = task.WorkItemSK
AND task.System_WorkItemType = 'Task'
LEFT JOIN dbo.DimWorkItemLinkType linkType
ON linkToStory.WorkItemLinkTypeSK = linkType.WorkItemLinkTypeSK
WHERE story.System_WorkItemType = 'User Story'
AND story.System_ID = 15662