Hi, Everybody!

I have one problem, I want to use same sql query in MySql and SqlServer. In case of Sql Server generally you have to write query in this way- select * from databasename.dbo.tablename but in case of MySql you have to write query in this way- select * from databasename.tablename. There is no problem if you write in this way- select * from tablename for both the database. But I have two tables of same name say 'employee' are in two different database and both having some relationship. So there is a need of writing database name while executing the table.

I want to write in such a way so that the query will run for both the database in MySql and SqlServer.

Help needed

Thanks in Advance.

You may use schema in MSSQL:

select * from schemaname.tablename.

Thus your query would look the same.

You may use schema in MSSQL: Thus your query would look the same.

But, would you suggest me how to write the schema for this?

Just create the schema and use SCHEMA TRANSFER to move objects to your newly created schema. After you have your table(s) in the schema you will be able to issue absolutely the same (syntactically) query against both sql servers.

Just create the schema and use SCHEMA TRANSFER to move objects to your newly created schema. After you have your table(s) in the schema you will be able to issue absolutely the same (syntactically) query against both sql servers.

If I create schema then I have to move all records of the table in any xml file, right?. Without doing it, is it possible?

What xml files?!? This is new to this thread! Just type SCHEMA TRANSFER in SSMS (Sql Server Management Studio) followed by the tablename. That's all you have to do.

This article has been dead for over six months. Start a new discussion instead.