MySQL: Selecting data from MS SQL Server - sql

How do I select data from a MS SQL Server from MySQL? We have a system of linked server in SQL Server. I have also heard that you can do a linked server to Mysql from sql server. But I want to know the reverse.
The mssql server is what we use mainly for production. So one main reason we'd want to do this is simply to get the exact mssql server's time.

I dont think it will be possible, reverse is possible with only .Net scripting support. However, you may setup a time synchronization mechanism between two servers.

Related

How to connect to an Oracle db using a stored procedures within a Microsoft SQL server?

I need to verify data between and Oracle db and a Microsoft SQL server db to verify that if there differences between the two and then update the Microsoft SQL server with any changes there may be
You can use/create database links. That means that you have to have oracle client installed on your sql server though.
You may configure connection to Oracle as linked server in SQL Server and use MERGE to synchronize date in SQL Server agent's job, for example. Fetching data from linked server could not the fastest thing in the world, but it is very easy to configure and use.
Use OPENQUERY with TNS alias already configured in tnsnames.ora file

When to use .mdf and when .sdf?

After seeing a lot of things in the internet I haven't found any explanation between the two file types: .mdf and .sdf.
.sdf would be a compact version of SQL Server (.mdf) I believe. Still they appear utterly different.
Have followed the two tutorials on msdn, i.e. MVC Movie App and the Musicstore. Both use .sdf.
Partial quote (full): 'First of all it should be "|DataDirectory|ASPNETDBContext.mdf" (notice the extension difference). Your applic...'
Both tutorials have the connection string to .sdf, i.e.:
<add name ="MovieDBContext"
connectionString ="Data Source=|DataDirectory|Movies.sdf"
providerName ="System.Data.SqlServerCe.4.0"
/>
<add name ="MusicStoreEntities"
connectionString ="Data Source=|DataDirectory|MvcMusicStore.sdf"
providerName ="System.Data.SqlServerCe.4.0"
/>
Question:
My question is what to use where and when? More over why to use which where.
SQL Server Compact (sdf files) popular in Windows phone for storing some data (small count of data), also it could be used in web sites, but it has poor performance, even SQLite is better.
SQL Server (mdf files) used in big sites with a lot of data. Its more powerful, but cant be used in phones and must be installed on servers.
Look this: Comparison of SQL Server Compact, SQL Server Express 2012 and LocalDB
SQL Server Compact Edition is indeed quite different from "regular" SQL Server.
SQL Server CE is a stand-alone, one-user database that gets loaded by your application on the machine where your code runs; it has all data in the one single .sdf file and support only a small subset of the "regular" SQL Server (and its features). SQL Server CE is great for simple, stand-alone, one-user apps (like phone apps).
"Real" SQL Server is a server product - you install it on a server, your clients only connect to it (typically, the client machines don't have SQL Server itself installed). It's a full-blown RDBMS with everything - stored proc, triggers etc. and thus best optimized to handle structured, large-scale data - think enterprise applications, such as order handling, invoicing, accounting, large-scale databases for multiple users of any kind.
First, the sql server database file is not a full sql server database, if you're creating it in this fashion it's a sql server express. Sql Server Express databases aren't terribly fantastic to use since most hosts don't run sql server express and publishing them is tricky if you then try to get them running on a sql server database. Better to start with sql server first then express and migrate.
the local db is actually sql server compact edition. http://en.wikipedia.org/wiki/SQL_Server_Compact
For connection strings, go to http://www.connectionstrings.com/sql-server/ There is pretty much every connection string available there. To work with SQL Server Express you will need to have it installed, and to manage it you will need to download the sql server express management tools. Generally, most sql express instances are designed to be used with local accounts but if I remember correctly you can use the management tools to create a sql server login.

Linking SQL Server 2000 and SQL Server 2008, is this possible?

I am writing stored procs for a new system in SQL Server 2008 but I need to also update data in an older db - SQL Server 2000. I have searched but haven't found any solution to this. Is it possible? What are my choices?
Thank you!!
If you mean connect to and query against a SQL Server 2000 database, then yes, this is possible through the use of linked servers assuming that the two database servers are able to communicate with each other on the same network.
See Linked Servers for more.
This has been asked and answered in another thread, but here's a great link to get you on your way:
http://msdn.microsoft.com/en-us/library/ms188279.aspx
The concept you're looking for is called a "linked server", which allows SQL Server to send SQL commands to a remote 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

New project sql server 2005 or 2008

I'll be starting a new project (asp.net) and I'll be using sql server express. Is there a reason NOT to use sql server 2008?
P.S: I was considering Postgres 8.3 until I did some benchmarking and found out that sql server 2005 express is much faster for my needs (better integration I guess).
If the choice is between SQL Server 2005 and SQL Server 2008 with no legacy compatibility issues, you should probably go with SQL Server 2008. The jump from 2005-2008 is much smaller than the jump from 2000-2005 was and you get three years extra lifespan for your application for free. A similar question was asked in this Stackoverflow post, with a more in-depth discussion of the subject.
A reason you might not have considered: will the production hosting location support SQL Server 2008?
Otherwise there's no reason. In fact, if your still stuck using SQL Server 2005, you should be using the 2008 version of management studio! which still works against older db's
I'd prefer Sql Server 2008 because there are too many "killer" enhancements like table valued parameters, merge statement, on the fly encryption, new datetime parameters etc. Table valued parameter is a life saver improvement. If you ever had to deal with multi row insert operations, you know how painful is to do it with xml nodes or openxml methods. On the other hand, you can pass your recursive datatable as a parameter ( SqlDbType.Structured ) and the pain is gone. It's so obvious that the most exciting feature for me is new table valued parameter.
As a sidenote: DiscountASP is selling, for the same price, 300Mb on SQL2005 and 500Mb on SQL2008. So it turns out that SQL2005 is on a statup path to be considered "old legacy" software.
And it is always good to skip future migrations.
I would go with SQL2008.
I am currently using SQL Server 2008 Express for my dev machine. You could use the new T-SQL and save some good time writing those stored procedures. I have this version of SQL Server 2008 Express installed.
It depends on a lot of factors:
Will you sell installable copies to customers? If so, what kind of database engines does your customer demography have? 2000? 2005? 2008?
Are you going to host it yourself? If so, use whatever you'd like
Are you going to use a 3rd party hosting company? If so, what do they support, and how much does it cost?
Unless you're explicitly going to use 2008 features, I wouldn't worry too much about it since generic T-SQL works on all the versions. It's when you start using the new features you might get into trouble.
Update: It seems that they DO allow sql server 2008 (sales people aren't very good at technical stuff) so I'll be using sql server 2008.
Well I asked my host (I have a vps) and they allow only sql server 2005 express, not sql server 2008 express (which is kinda strange). So I'll go with 2005 for now... Thank you all for your opinions.