Hi,
How to write a SQL query to update custom field data to jira “description” field?
The custom field name = Issue Description
Filed Type = Free Text Field unlimited text
How do I update from above mention custom field to jira “description” field for a "selected Project" by using with SQL query.?
Could you please provide the SQL script, so that I can use that query to update the data from custom field to description field.
Thanks
Ganga S
Hi Ganga,
The following works on MySQL but i'm not sure if other databases understand that as well
update jiraissue,customfieldvalue set jiraissue.description = customfieldvalue.textvalue where customfield = 12345 and jiraissue.id = customfieldvalue.issue and jiraissue.project = xxxxx;
12345 is the id of your unlimited text area custom field, xxxxx is the id of your project
Please always follow Nics hints for such operations
Hi Dieter,
Thanks for the SQL query. It is really useful.
I am using MS SQL 2008 R2, first I will try on our test environment and let you know the status.
Sure, I will follow the @Nic instructions before proceed and also I took the table backup using with
Select *into jiraschema.jiraissue_bak fromjiraschema.jiraissue
It means, for a test, I am going to run the update query on the backup table instead actual table
Ganga S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic/Dieter.
Firstly: Thanks for the help....
It works. I used outer join query to update data from custom field to jira issue description field on a SQL 2008 R2 database. Outer join updates only matching records.
update jiraschema.jiraissue
set jiraschema.jiraissue.description = jiraschema.customfieldvalue.textvalue
from jiraschema.jiraissue left join jiraschema.customfieldvalue
on jiraschema.customfieldvalue.issue = jiraschema.jiraissue.id
where jiraschema.customfieldvalue.customfield = 12345
and jiraschema.jiraissue.project = xxxxx;
Ganga S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's not a simple script. To get the data out, you need to read "jiraissue where project = xxxxx" (xxxxx being the project you're interested in - read table "project" to find that), then for each jiraissue record found, read "customfieldvalue.text where issue = jiraissue.id and customfield = yyyyy" (where yyyyy = the custom field id for your free text field). Finally, to write the data, you update jiraissue.description with the value you've just read.
Please remember that when you do this, you absolutely MUST
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nic,
I am nerves with complex query, but I will try on my test machine….
Ganga S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Always a good idea to test first :-)
The SQL Dieter gives looks correct to me, with a couple of minor points:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the second consideration....
#1. I wanted to overwrite all the issues description for a particular "Project". It means not for other project issues description.
#2. It is an interesting point.... I will try on test machine first..... and update the status.
Ganga S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
due date is not a custom field.
I would very strongly recommend not using SQL to change data in Jira. To do it, you need Jira backed up, shut down and fully re-indexed after restart, so it's slow, clunky and inefficient.
What are you really trying to achieve?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.