What syntax does Cognos use? - sql

Can we use SQL Server or MySQL syntax in Report Studio?

There is one MAJOR advantage in relying on built-in SQL generator, instead of using pass-through SQL option available for every query: when your back-end database changes, as along as you did not utilize database-specific features, your report will continue to execute without any changes. So YES, you can provide your own SQL, but there is no reason to.

Related

convert (Translate ) from one sql syntax to another (from mssql to oracle,h2...)

The application that I started working on uses several databases with different SQL syntax for different clients (MsSQL,MySQL, oracle,h2 for JUnit tests...). Updating all databases(adding a new table) is a manual task.
I have tried several free tools that I found online to do the conversion from one syntax to another
http://www.sqlines.com/online
https://www.jooq.org/translate/
but they don't work well for triggers and datatypes.
My question is what would be the best way to automate this process of maintaining multiple databases for a single app, write SQL in just one syntax and convert to all others?
It is an older project so I cant use hibernate to generate the SQL for me.
Try This:
https://www.jooq.org/translate/
OR
There are a number of database tools that help migrating data from one to another database, for example:
Flyway
SQuirreL DB Copy Plugin

Configure MS SQL Server to log query and its execution time

I had a program using SQLconnector to connect to MS SQL 2012, I want know SQL query execution time. I am aware there is a SQL Server Profiler, but I can't configure it correctly to capture any query execution time. I am also aware that I can add timer within program but i can not change code easily.
All advice welcome. thanks
AFAIK SQLConnector is for MySQL, so I don't understand how you can work with SQLServer 2012.
If you need profiling in SQLServer - there is nothing better than SQL Server Profiler.
I can't configure it correctly to capture any query execution time
It must be easy:
Event Selecion - you need SQL:Stmt Completed (uncheck everything else). You need to select duration.
Column Filters - create filter by Login Name (make special login if you need it), TextData, Spid (if you can figure out how to obtain it)
This is not supported by default but you can do this using several techniques depending on what are your needs.
Do you need to capture every statement including SELECT? If yes then I suggest you still use SQL Server Profiler or SQL Server Traces
If you only need to capture DML statements (excluding SELECT) you can try setting up triggers on tables you want to audit.
There are also DDL triggers that can help you catch DDL statements (as far as I know there is no way to capture all DDL statements using DDL triggers).
So, there are many options here but it all depends on what are your needs.

Hiding statements from SQL Server Profiler (or other observers)

In SQL Server 2008 R2, I would like to execute a statement that I want to be invisible to the SQL Profiler or other means of observing user queries. Is there a way to control what is displayed by SQL profiler?
I would like to execute something like:
SELECT 'MyPassword' INTO #passwordTable
I don't want to show 'MyPassword' through SQL Server Profiler or other means. Any ideas?
Essentially, no, you can't. You used to be able to do this by adding a comment like this into the batch or statement:
-- sp_password
But this no longer works. Why aren't you hashing your password?
Well, you have to be a server administrator to run the SQL Profiler, so even if you could prevent it from seeing the command, the user could just go grab the password table anyway. Ideally you would be storing hashes of the passwords rather than the passwords, making any viewing from the profiler useless.
If you really want to try and keep the profiler from seeing the statements, you could try a third party tool like this: http://www.dbdefence.com/support/dbdefence-documentation/
I have no idea if it works though, or how reputable that company is.
Denis, Aaron is correct, there is nothing like an "invisible statement", you can't tweak SQL Profiler to NOT show statements: once aboard, one can see all statements running in the DB.
You need to obfuscate this sensible data before submitting it to the DB. There are some obfuscated methods available (one-way hash, symmetric algoritms, home-made methods), you need to choose the more suitable method to your needs and implement it. Unfortunatelly, there is no free-lunch to your case...
I have seen a product called DBDefence.
It hides SQL statements from the profiler completely. I do not know how do they do it.
I use free version because I have small database.
In earlier versions of SQL Server it was possible to add a comment --sp_password
but not in SQL Server 2008 and above.
I don't see the point, really. If one is able to view a query with SQL profiler, surely he could access the database to view the actual data.
The key is to not store sensitive data (like passwords) in clear text.
Preventing people to use SQL profiler will come down to applying the proper security configuration on your SQL Server.

Faking SQL Server

I have application that requires SQL Server 2000 as database storage.
I do not really want to use SQL Server 2000, but I can user MySQL Server instead.
Application uses ODBC to connect to SQL Server Database.
I would like to know if it is possible to make fake SQL Server which will send and receive data to/from MySQL Server
application <---> odbc manager <---> fake SQL Server driver <---> mysql server
Any one if such thing is possible to make?
If your application simply uses vanilla SQL via the ODBC driver, you should be able to use MySQL with few problems. If it uses specific features of SQLServer, then you need SQLServer - you cannot realistically fake it.
I wouldn't.
You're going to spend so long persuading the two to play nicely to no real benefit. You'll have to do most code the SQL Server way to work in this scenario. Given these, you might as well just bite the bullet and learn to use SQL Server directly rather than trying to tie the two together somehow, I'm afraid.
You can use a provider model and just switch out which provider your using at run time.
Of course, the biggest issue will be in the differing SQL code support. So you will have to take care that all of your SQL is located inside of each provider and stay away from any sort of embedding it in your application logic.. which you should be doing anyway.
Another way is to simply change the ODBC data source at deployment time, but again, you will have to make sure the SQL code actually works in both environments; which is tough.
Typically supporting multiple database back ends is a art form in itself. Simple things like SELECT TOP 100 for SQL Server 2k versus MySql's LIMIT command are enough to keep people from doing this.
There's no real way of "faking" it because the database servers are fundamentally different. You would end up writing a fair amount of code just to translate a sql call from one to the other... Which is a waste of time.
I'd suggest you just bite the bullet and learn MS SQL Server.
This site shows a very simple example of how SQL Server, Oracle, and MySql differ on just one implementation of a select statement.
Not sure why you "do not really want to use SQL Server 2000" but, if you decide you need to and you have a PC with Windows available, you can use the Microsoft Database Engine 2000 Release A (MSDE2000A.exe). It is the real thing and free to use on a desktop.
http://msdn.microsoft.com/en-us/library/ms811304.aspx
I do not think it is available for download from Microsoft anymore but you might be able to find it somewhere else. If you can't find it, your next best option may be to use the 2005 version (SQL Server 2005 Express Edition) and make sure you do not use any new features since 2000:
http://www.microsoft.com/Sqlserver/2005/en/us/express.aspx

Get SQL statement after parameters added

Is there a way (in MySQL) to get the pure SQL statement after parameters have been added? I'm having issues with one of my statements once I start using parameters, and I want to see what's being executed. Of course it has to do with dates.
Using MySQL .NET Connector. I have access to MySQL server, and I use SQLYog to administrate.
Thanks!
-Steve
You can use the query logs option to have all queries issued to the server logged.
See http://dev.mysql.com/doc/refman/5.1/en/server-logs.html for information about the log types and how to enable and configure them.