SQL Server guide

Update an issue


Updates an existing issue. Set the columns you want to change (Summary, Description, Labels, DueDate, etc.) and identify the issue with IssueIdOrKey in WITH or in a WHERE clause. Optional WITH parameters control notifications and security overrides.

Standard SQL query example

This is the base query accepted by the connector. To execute it in SQL Server, you have to pass it to the Data Gateway via a Linked Server. See how to accomplish this using the examples below.

UPDATE Issues
SET Summary = 'This is my summary'
   ,Description = 'Lot''s of stuff to describe'
   ,Labels = '[ "bugfix" ]'
   ,DueDate = '2029-10-10'
--WHERE Id=1234   
--WHERE Id='ISSKEY'   
WITH (
	IssueIdOrKey='ISSKEY', --or use Id in where clause 
	Output=1,
	NotifyUsers=0,
	OverrideScreenSecurity=0,
	OverrideEditableFlag=0,
	ContinueOn404Error=0
)'

Using OPENQUERY in SQL Server

SELECT * FROM OPENQUERY([LS_TO_JIRA_IN_GATEWAY], 'UPDATE Issues
SET Summary = ''This is my summary''
   ,Description = ''Lot''''s of stuff to describe''
   ,Labels = ''[ "bugfix" ]''
   ,DueDate = ''2029-10-10''
--WHERE Id=1234   
--WHERE Id=''ISSKEY''   
WITH (
	IssueIdOrKey=''ISSKEY'', --or use Id in where clause 
	Output=1,
	NotifyUsers=0,
	OverrideScreenSecurity=0,
	OverrideEditableFlag=0,
	ContinueOn404Error=0
)''')

Using EXEC in SQL Server (handling larger SQL text)

The major drawback of OPENQUERY is its inability to incorporate variables within SQL statements. This often leads to the use of cumbersome dynamic SQL (with numerous ticks and escape characters).

Fortunately, starting with SQL 2005 and onwards, you can utilize the EXEC (your_sql) AT [LS_TO_JIRA_IN_GATEWAY] syntax.

DECLARE @MyQuery NVARCHAR(MAX) = 'UPDATE Issues
SET Summary = ''This is my summary''
   ,Description = ''Lot''''s of stuff to describe''
   ,Labels = ''[ "bugfix" ]''
   ,DueDate = ''2029-10-10''
--WHERE Id=1234   
--WHERE Id=''ISSKEY''   
WITH (
	IssueIdOrKey=''ISSKEY'', --or use Id in where clause 
	Output=1,
	NotifyUsers=0,
	OverrideScreenSecurity=0,
	OverrideEditableFlag=0,
	ContinueOn404Error=0
)'''
EXEC (@MyQuery) AT [LS_TO_JIRA_IN_GATEWAY]