ServiceNow SNC - Find Underlying Report SQL - mysql

Is there a way to locate the underlying SQL in a ServiceNow (SNC) instance using MySQL as the database platform? My user account doesn't have access to watch the PROCESSLIST, so I was looking for a table possibly that stored an SNC based report's SQL.
For example, I've created a report in SNC and execute it manually. I would like to be able to go out to some table in the database to see if the SQL for which that report is based upon is available outside of watching the PROCESSLIST.

Ignoring the question of "why?" (normal hosted instances don't expose direct database connectivity to end users, so I'm curious what you plan to do with the raw sql), you can get the sql that was used anywhere in the platform by activating sql debugging. This requires the admin role in the appliation.
To activate sql debugging, in the left nav, go to System Diagnostics > Session Debug > Debug SQL
This will cause sql statements for every transaction in your session to be written to the bottom of every page load. It also includes the sql for the previous transaction, so if you need to get the sql for an AJAX transaction or something, just trigger it, and then navigate to some other page (/ui_page.do is an easy one that doesn't load anything, but still gives you your sql debug output)

Related

Connecting Microsoft Access to Sql Managed Instance

So we have a writable database that a lot of our product / data people use. This database has recently been migrated to Managed Instance.
We're working on getting them connected to be able to write/update DB records via Access, a functionality they've had before.
Currently, we're looking at starting them from scratch.
We can't seem to find a way to create a connection that allows for updating or changing records. The connection we're setting up allows them to insert / create new records, but the second that create goes through, even the newly created record can't be edited. We get a standard MSAccess writelock error. This is the case on EVERY table we open. Even ones that are essentially never touched.
Here's how we're connecting:
Network: The machines running msAccess are on our "main office" connection, which is peered with a vnet to the Sql Managed Instanfce. We CAN connect to the sql managed instance via ssms from this place, so it shouldn't be a networking issue (we can also insert records, so same thing)
Permissions: I've made sure that I have full sysadmin permissions via our az-sqlprod01-admin AAD group. I can do this same action in SSMS
Method:
Access > External Data > Linked Table Manager > Add:
Next Screen is Table Import, So that once that's finished we have the full table import list. We import those tables without issue.
Once there, I can bring up any table, try to edit anything, and it gives me the write-lock error at the top of this screen.
My Need: is there a way to connect MSAccess to a SQL Managed Instance without getting write-locks 100% of the time?

Is there a way for Access pass through queries to be a part of the initial login to the SQL server?

I'm in a situation where I need to use a SQL server as a back end to Access 2010 database. The problem is that the server is only accessible with a SQL login. This isn't a big problem for the table part of the database - one login to the server connects all of the tables. The problem is with stored procedures that must be called. Since these are not under the ODBC umbrella, each query requires a login. I can't seem to find a way around that. Currently, I'm trying setting up pass through queries in Access, but once again - each query has to be logged in to individually. Is there a way to set up something (query setting, ODBC setting, VB structure or anything!) that will get around this problem of having to log in every time an SP is called?
I'm trying to avoid writing a whole big wrapper that handles the login and holds the password for later connections...

Access loses table relationships when

I need to update an MS Access app that connects to a SQL Server database. I copied the app and SQL database to my development computer, opened Access and linked the tables (100+ of them). I can see the data via Access, but all of the table relationships are lost, and the forms are giving me 3146 connection errors.
How do I straighten out the data so I can add features to the app (and eventually give the app to the client to reconnect with the original SQL Server)?
Complication: I haven't used Access in 15 years, so I'm a little rusty with it...
The relationships are NOW handled by SQL server. They have ZERO to do with Access, or a web site, or VB6, or some .net program that simply connects to SQL server. The .net program, the VB6 program, or the software you develop using MS Access has zero to do with how the relationships are setup with the given database system (in this case SQL server).
So that web site software, or .net program, or even MS Access does not change, or control the relationships you setup on SQL server. If this were the case, then which of the programs such as .net, web site, VB6, and MS access all using the SQL server at the SAME TIME would control relationships then??
So it is not possible or practical to have the client software control or set the relationships used by SQL server, since then it would be the client software controlling this, and every program that connects to SQL server could then be different!!! (and thus no enforced relationships would be possible as all programs would have differing ideas as to how the relationships are supposed to be!!!).
Any relationships settings you have in Access are thus ignored by SQL server, since it is now SQL server that is managing the database – not Access.
Access is just a developer’s tool like VB6, or say vb.net – those programs are free to connect to SQL server. Since many different programs are able to connect to SQL server, then the programs connecting are not the ones that control relationships – it all has to be done and set on SQL server.
Access will still allow you to use the relationships diagram. You can thus still draw out relationships in that window if you want, but you note how the options to “enforce” the relationships are now gray out – they can’t be used. So it still can be a documentation tool, or a means to make a cute diagram, but as such, it will not affect the operation of SQL server.
As for you errors? Well, before you attempt to open any form, you want to click on a linked table, and see if that works first. No use to try code, forms, reports if you not FIRST sure that the table links are active and working. ONLY until such time that you can click on, and open a linked table should you be concerned with trying to use forms, code, reports etc.
I would suggest you use the linked table manager, and re-link the tables. Now, I suppose you could delete the links, but I do NOT recommend that as a first try, since the table names will likely have a dbo prefix in front of them, and this will result in all your table names being changed, and that will break near everything in your application. So really try the refresh approach, since if you have lots of tables, then you have to re-name them all if you delete the links and re-link (so try to avoid my suggesting to delete the table links and recreating them – it will save a lot of work).
So first step:
Make sure the table links works. (don’t try code, don’t try forms, don’t try reports).
You need to ensure that a simple linked table works, and that you can simply open these linked tables. Skipping this step means everything else you attempt is folly and a waste of time.
So click on a linked table and see if you can then open + view that linked table data.
If not?
Then I would launch the linked table manager, and select all linked tables, and then force a re-fresh. (make sure you click on the box to [x] “Always prompt for new location” in the lower left corner of the linked table manager.

Reporting services error trying to access a object that isn't called in the report

have a strange one. We are running Sql Server 11.0.3000. The report is giving an error
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'Audit_Detail'. (rsErrorExecutingCommand)
Invalid object name 'dbAudit.tblRangeReport'.
The thing is, the report uses 3 stored procs to go after data in a database called dbSalarySurvey. The three sp's do not mention the dbAudit.tblRangeReport. There are no functions or views in the 3 sp's that access that table. Further more, if i run the report in VS 2012 the report runs. If i run profiler on the dbAudit table when VS runs the report, the report does not query the dbAudit table. Only when running the report from the web browser do i get this error. This more detailed version of the error come from running the report on the Sql Server REporting services computer.
I have tried restarting the reporting services service. We have also deleted this one report from the reporting services server and republished it. Have also tried to republish the dataset. Other reports in this project that use the datasource and the same tables run.
Anyway, was wondering if anyone had any sugguestions.
Thanks
shannon
It's fixed. it was a pebkak error in the stored proc. It's really strange though. Honest to goodness, the proc was running in my dev env but not when running from a browser. I had already checked profiler like was suggested below and done the xml scan too. In the end.. just missed it i guess.
You need to trace the SQL to determine.
Are you connecting to the right database?
Are the procs you expecting to see, the ones actually being run?
The procs you are running are correct?
Open SQL Server Profiler
Start New Trace
Click Event Selection, Select the following events
Click - Show All columns
Go into Column Filters
and filter on your DB, and possibly even your login name (the login name of the SSRS server)
Once you've done that, call your report and look to make sure all the procs are called that you expect. Track issues from there.

Use Database Insert Trigger to Publish Reports

Is it possible to distribute reports based on a database insert trigger, using the standard edition of SQL Server 2008 R2? The trigger will be looking for a certain column to have a certain value, which will indicate that it is time to fire off a report. This will not happen very often, probably a couple of times a day.
This must be a common scenario, and yet I can't find any information on it, which must mean that I'm asking the wrong question. (I am completely new to SQL Server.)
TSQL using FireEvent?
Thanks,
Mike
Is there any aversion to checking for the value in the application, then execute and deliver the report from there using the report execution webservice? I don't like the idea of database triggers kicking off external processes. Too many clunky configuration dependencies and opportunities for failure for my taste.
If you really want to pursue this, this seems to be least complicated way (it requires reporting services and application database to on same instance):
Create reporting services subscription that delivers report in desired format
Open the SQL Server agent job list and get the unique identifier of the job name that corresponds to the subscription that was created (you'll have to look at job creation and last/next run datetime to find which job relates to your subscription)
Create trigger that executes the msdb.dbo.sp_start_job procedure, passing the job name that matches your subscription
See what I mean about clunky dependencies? I would definitely stick with checking values and delivering the report in the application layer if at all possible.
The reason you do not want to use a trigger for this is that you will not be able to insert/update/delete if reporting is down.
Can you have some slack time (5 minutes or so)? If so do a trigger to send to a differnt table that the change was made and have a job to look at that table for the change every five minutes.