Display user friendly msg on UI in case of error in SQL Server operation - sql-server

I have a query. When we are dealing with Oracle DB and if any error appears, the system error message will contain an ORA "marker". Is there anything similar for SQL Server error messages?
My requirement is I need to display user friendly error message in the UI in case of an issue with a database operation.
For Oracle databases, I am checking in code like shown here:
if (error.message.includes('ORA').toLowerCase()) {
return res.send("DB related issue occurred while performing an operation."))
}
I need to do something equivalent for SQL Server. Please help. Thanks in advance.

Related

Getting a Login Timeout Expired: A network related or instance specific... While trying to export data from one server to another

I am trying to export data from a table in a server to another server that has the same table. The table contains about 500 Million records, Generating a script requires memory that our server doesnt seem to have since it gives us an error midway. I was trying to use the export data wizard tool. I chose native client 11.0 as the source and specified the server. But when i specify the the destination server it gives me an error.
Login timeout expired: A network related or instance specific error has occured while establishing a connection to the server. Server is not found or accessible...
I am also worried I might have to deal with duplicate data if I use this tool.
Is there a way I can copy/backup/restore a specific table in SQL server and simply restore it on the other server?
I am looking for the most efficient solution to this.
Thank you for your help.

There is one error when I am trying to move TFS report to a new server

I try to debug a problem related to tfs report,I don't know why and really need help.
Recently I export one report from the old tfs server and deploy to the new server, I also copy the store procedures which related to this report in the old server database to the new server database.
But the report just doesn't work. The error is as following, The report rdl file and store processors in new tfs server are exactly same like the old server, just didn't work for the new one.
An error occurred during client rendering.
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'DataSet1'.
(rsErrorExecutingCommand) Query (1, 16) Parser: The syntax for
'#TFS_Date' is incorrect.
First of all, I would suggest you to check your reporting service log files from below path,
C:\Program Files\Microsoft SQL Server\MSRS11.SQLEXPRESS\Reporting Services\LogFiles
Usually the error messages here in log file shows us a perfect solution.
In your case, try to check that user has access to dataset1's database. (server database) by going to SQL Server Security tabs.
Also, check your store procedure. If you have joined with some other database's table then user must have access of that database too.
Note: This type of error messages you can find there in log file. So read it to solve the issue.

Handling a SQL Server Login error msg with VBA?

I'm working in a VBA module for Access that queries linked tables, generates reports based off the data, and then uses a PDF printer to save the reports to disk. There's a timer in the primary form that will, every N seconds, run an Access query against a "JOBQUEUE" table to see if there are new jobs.
If the database server becomes unavailable, this operation will of course time out. The run-time error of 3051 is being logged, and the loop will try to continue. The loop can't finish, however, because the following error comes right after the VB Run-Time error;
Title is "Microsoft SQL Server Login", so it's not within VB as far as I can tell.
Connection Failed:
SQLState: '01000'
SQL Server Error: 53
[Microsoft][ODBC SQL Server Driver][DBNETLIB][ConnectionOpen(Connect()).
Connection Failed:
SQLState: '08001'
SQL Server Error: 17
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not
exist or access is denied.
In every forum & discussion I've found that mentions this error, the asker is concerned with the cause of the error. In this case, I can assume that the error is temporary, and that it needs to continue trying to connect because the installation is unattended. Access goes into a "Not Responding..." state when it's timing out against the DB, and that's OK too, if connection is restored before it goes into the MsgBox described above, it will pick up where it left off and soldier on.
Does anyone know of a way that I can either mute that msgbox, preferably programatically, but I'd take anything at this point that can be done remotely that isn't an RDP session.
Edit: Link to image
The error I was getting was indeed not a run-time error that could be caught from code. Rather, it was SQL timing out after I already swallowed & dismissed time-outs in run-time in my VBA module.
The error does not seem to ever appear now that I have introduced a new timer that resets the loop that runs a query against my linked tables. It can't be logged & swallowed, but it can be prevented by being smarter about how I handle timeouts in run-time.

SSRS Query execution failed for dataset

Have just deployed my Project on to my reporting Server.
I have multiple datasets which are referencing views which exist on the db on that server.
When I try to go into any report part I am getting this message:
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'dataset1'. (rsErrorExecutingCommand)
For more information about this error navigate to the report server on the local server machine, or enable remote errors
Can anyone help?
I enabled remote errors to pinpoint the problem.
I identified that a column in a particular dataset (one of my views) was throwing an error.
So using a tool "SQL Delta", I compared the development version of the database with the live version on the reporting server. I noticed that one of the views had an extra column on the development server, that was not on the live version of the db.
SQL Delta generated the script I needed to run to update the view on my live db.
I ran this script, re-ran the report, everything worked.
I encountered a similar error message. I was able to fix it without enabling remote errors.
In Report Builder 3.0, when I used the Run button to run the report, an error alert appeared, saying
An error has occurred during report processing. (rsProcessingAborted)
[OK] [Details...]
Pressing the details button gave me a text box where I saw this text:
For more information about this error navigate to the report server
on the local server machine, or enable remote errors
----------------------------
Query execution failed for dataset 'DataSet1'. (rsErrorExecutingCommand)
I was confused and frustrated, because my report did not have a dataset named 'DataSet1'. I even opened the .rdl file in a text editor to be sure. After a while, I noticed that there was more text in the text box below what I could read. The full error message was:
For more information about this error navigate to the report server
on the local server machine, or enable remote errors
----------------------------
Query execution failed for dataset 'DataSet1'. (rsErrorExecutingCommand)
----------------------------
The execution failed for the shared data set 'CustomerDetailsDataSet'.
(rsDataSetExecutionError)
----------------------------
An error has occurred during report processing. (rsProcessingAborted)
I did have a shared dataset named 'CustomerDetailsDataSet'. I opened the query (which was a full SQL query entered in text mode) in SQL Server Management Studio, and ran it there. I got error messages which clearly pointed to a certain table, where a column I had been using had been renamed and changed.
From that point, it was straightforward to modify my query so that it worked with the new column, then paste that modification into the shared dataset 'CustomerDetailsDataSet', and then nudge the report in Report Builder to recognise the change to the shared dataset.
After this fix, my reports no longer triggered this error.
Like many others here, I had the same error. In my case it was because the execute permission was denied on a stored procedure it used. It was resolved when the user associated with the data source was given that permission.
I experienced the same issue, it was related to security not being granted to part of the tables. review your user has access to the databases/ tables/views/functions etc used by the report.
The solution for me came from GShenanigan:
You'll need to check out your log files on the SSRS server for more detail. They'll be somewhere like: "C:\Program Files (x86)\Microsoft SQL Server\MSRS10_50.DEV\Reporting Services\LogFiles\"
I was able to find a permissions problem on a database table referenced by the view that was not the same one as the where the view was. I had been focused on permissions on the view's database so this helped pinpoint where the error was.
I just dealt with this same issue. Make sure your query lists the full source name, using no shortcuts. Visual Studio can recognize the shortcuts, but your reporting services application may not be able to recognize which tables your data should be coming from. Hope that helps.
I had the similar issue showing the error
For more information about this error navigate to the report server on
the local server machine, or enable remote errors Query execution
failed for dataset 'PrintInvoice'.
Solution:
1) The error may be with the dataset in some cases, you can always check if the dataset is populating the exact data you are expecting by going to the dataset properties and choosing 'Query Designer' and try 'Run', If you can successfully able to pull the fields you are expecting, then you can be sure that there isn't any problem with the dataset, which takes us to next solution.
2) Even though the error message says "Query Failed Execution for the dataset", another probable chances are with the datasource connection, make sure you have connected to the correct datasource that has the tables you need and you have permissions to access that datasource.
In my situation, I created a new SSRS report and new stored procedure for the dataset. I forgot to add the stored procedure to the database role that had permission to execute it. Once I added the permissions to SQL database role with EXECUTE, all was fine!
The error message encountered by the user was "An error occurred during client rendering. An error has occurred during report processing (rsProcessingAborted). Query execution failed for dataset "DataSet1'. (rsErrorExecutingCommand) For more information..."
Very grateful I found this great post. As for my case, the user executing the stored procedure did not have EXECUTE permissions. The solution was to grant EXECUTE permissions for the user within the stored procedure by adding below code to the end of the stored procedure.
GRANT EXECUTE ON dbo.StoredProcNameHere TO UsernameRunningreports
GO
I also had a very similar issue with a very similar error message. My issue was that the database could not be connected to. In our case, we have mirrored databases and the connection string did not specify the Failover Partner. So when the database couldn't connect, it never went to the mirror and was throwing this error. Once I specified the Failover Partner in the connection string for my datasource, it resolved the issue.
BIGHAP: A SIMPLE WORK AROUND FOR THIS ISSUE.
I ran into the same problem when working with SharePoint lists as the DataSource, and read the blogs above which were very helpful. I had made changes in both the DataSource and Data object names and query fields in Visual Studio and the query worked in visual Studio. I was able to deploy the report to SharePoint but when I tried to open it I received the same error.
I guessed that the issue was that I needed to redeploy both the DataSource and the DataSet to SharePoint so that that changes in the rendering tools were all synced.
I redeployed the DataSource, DataSet and the Report to sharePoint and it worked.
As one of the blogs stated, although visual studio allowed the changes I made in the dataset and datasource, if you have not set visual studio to automatically redeploy datasource and dataset when you deploy the report(which can be dangerous, because this can affect other reports which share these objects) this error can occur.
So, of course the fix is that in this case you have to redeploy datasource, dataset and Report to resolve the issue.
I was also facing the same issue - I checked below things to fix this issue,
If you have recently changed pointing database-name in data-source
then first check that all the store procedures for that report exist
on changed database.
If there are multiple sub reports on main report then make sure each
report individually running perfectly.
Also check security panel - user must have access to the databases/
tables/views/functions for that report.
Sometimes, we also need to check dataset1 - store procedure. As if you are trying to show the report with user1 and if this user doesn't have the access(rights) of provided (dataset1 database) database then it will throw the same error as above so must check the user have access of dbreader in SQL Server.
Also, if that store procedure contains some other database (Database2) like
Select * from XYZ inner join Database2..Table1 on ... where...
Then user must have the access of this database too.
Note: you can check log files on this path for more details,
C:\Program Files\Microsoft SQL Server\MSRS11.SQLEXPRESS\Reporting Services
I got same error but this worked and solved my problem
If report is connected to Analysis server then give required permission to the user (who is accessing reporting server to view the the reports) in your model of analysis server.
To do this add user in roles of model or cube and deploy the model to your analysis server.
Using SSRS, Report Builder 3.0, MSSQL 2008 and query to an Oracle 11G database,
I found that the oracle stored procedure ran well, produced consistent results with no errors. When I tried bringing the data into SSRS, I got the error as listed in OP's query. I found that the data loaded and displayed only if I removed the parameters (not a good idea).
On Further examination, I found that under dataset properties>parameters I had set the start date to parameterName P_Start and parameter Value to #P_Start.
Adding the Parameter value as [#P_Start] cleared the problem, and the data loads well, with parameters in place.
This problem was caused by an orphaned SQL Login. I ran my favorite sp_fixusers script and the error was resolved. The suggestion above to look at the logs was a good one...and it led me to my answer.
This might be the permission issue for your view or store procedure
In addition to the above answers, it could be due to a missing SQL stored-procedure or SQL function. For example, this could be due to the function not migrating from a non-prod region to the production (prod) region.
Removing all comments from the Select Query fixed this for me. My dataset was working in the Preview but when I went to Design/Query Designer and and tried the query there I was getting ORA-01006;bind variable does not exist. After removing all comments from the select it worked.

How can I fix "SQL03042: The ALL clause is not supported"?

I have just recently added our db schema into a VSTSDB project and one of the sp's is coming up with a strange error on the line:
revoke all from StatsReports
Now I've taken a look at the Sql docs for the "revoke" command and according to that it is valid sql. Also searching for the error number or text brings up nothing!
Anyone have any ideas?
It is valid TSQL, but the error message is - I assume - coming from VSTSDB, not from SQL Server. Running your query directly against a SQL 2008 database gives the following message:
The ALL permission is deprecated and maintained only for compatibility. It DOES NOT imply ALL permissions defined on the entity.
My guess is that VSTSDB shows an error on this syntax in order to 'remind' you to update your code. The deprecation is documented under the main page for the REVOKE command.

Resources