- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 01:17 AM
Hello,
I want to know what sql query is being generated for a database view in servicenow. How can I do that?
Thanks,
Rajnandini
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 01:25 AM
Enable debug mode "Debug Detailed SQL", go to Database Views, enter the your database view record, and click Try It. At the bottom of the page there you will find the SQL. Disable the debug mode after the test.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 01:45 AM
If you post the output, I can locate the query for you probably.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 01:57 AM
Hello,
I found that, there are two queries in the debug output. What is the second query for? The queries are
- SELECT ... FROM (sys_user_grmember grmember INNER JOIN sys_user user ON grmember.user = user.sys_id AND user.user_name = 'Admin' )
- SELECT ... FROM (((sys_user_grmember grmember INNER JOIN sys_user user ON grmember.user = user.sys_id AND user.user_name = 'Admin' ) LEFT JOIN sys_user_group sys_user_group1 ON grmember.`group` = sys_user_group1.`sys_id` ) LEFT JOIN sys_user sys_user2 ON grmember.`user` = sys_user2.`sys_id` )
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 02:08 AM
For a list view there are usually two queries: one for the count (to see how many rows are matching the condition) and a second one to get the data itself (usually limited by the rowcount, first 20/50 rows). In your case if you just hover the mouse over the dots between the SELECT and FROM (SELECT ... FROM) you will see if it's a count or a data query.