Information: We are in the process of Testing our upgrade from SQL Server 2005 to SQL server 2012 on staging. In reading the documentation on features that will no longer be supported, COMPUTE (Transact-SQL) going away is going to be an issue for us.
Question: Is there any way to write out our own procedure that will take the place of the compute builtin on SQL Server 2012 that will make it seamless so when Compute is called it will function like SQL Server 2005? The alternative is we will we need to update all the SQL files, UDF's, Triggers, and stored procedures that use this built in with alternative code?
Note I have never tried to recreate a built in function before so any information on this will be very helpful for me and anyone else trying to do this in the future. Also knowing if it can be done is a plus.
Clenup: As always if this is a duplicate post indicate the link below and i will remove my post.
COMPUTE BY is not a function. I don't see how it's effects (generating additional result sets) can be replicated easily.
Replacing COMPUTE BY with a temp table and some looping should be kind of straight forward but it will be a laborious task. It's probably better to change the application so that it does not depend on multiple result sets.
I have made the recommendation of moving to SQL Server 2008 first, this will give us 4 years or so to update all the code and then we can move up to SQL Server 2012.
That sounds reasonable. By then there will be at least SQL Server 2016 so you'll have to see what other features are deleted at that point :)
Related
This is not directly a programming question but I ask it anyway because it's related to debugging.
I wonder if it's possible to see exactly what SQL statements that are being executed within a procedure in Microsoft SQL Server Profiler?
For now I just see the procedures being called but due to complicated procedures causing a tricky bug somewhere I would like to see exactly what SQL statement being executed. So it would be nice if anyone has any tip on this.
Yes this is possible.
Add SP:StmtStarting and/or SP:StmtCompleted to the events you are tracing.
I am trying to run a query that will pull information from multiple servers. Let me explain a little bit. The machine that makes a certain product stores that information on a server. So when we do reports we have to run a query on the accounting side and then run a query on the first server. I was just wondering if anyone could point me in the right direction, or help me out a little with constructing this query.
Since you didn't technically specify, I'm assuming you're running the query in MS SQL Server and the other databases are either MSSQL or MySQL, guessing based on your tags.
If that's the case you have a couple options. If you're going to be running these queries frequently you can use a linked server or if you're only wanting to do them sparingly you can use OPENROWSET.
Other options would be to create a SQL Server Integration Services (SSIS) package to extract the data from various sources and compile it into a single report or alternatively SQL Server Reporting Services (SSRS).
I would like to use some mechanism within SQL Server (or one of its services) to push change messages out (via UDP, for example, but TCP is OK, too) when rows get inserted into a table. I would like for these messages to be more than notifications of change, but to actually contained the changed data. Is there a mechanism that comes with SQL Server 2008 R2 to do this? I've heard of Service Broker and Extended Events, but am not sure that these are the right tools for the job when it comes to getting near real time data pushed out of SQL Server to another app that needs to update its internal state when data in SQL Server changes, without having to query SQL Server (i.e., I want the data to be strictly pushed out of SQL Server).
I the worst case, I can write SQLCLR code that unicasts UDP messages containing changes, but I would like to reuse an existing service, if available.
Since you are using SQL 2008, Change Tracking is built right in.
MSDN provides extensive information on enabling and implementing the feature. This overview article provides a high level view and this article is a great place to start on the implementation.
Unfortunately, because SQL Server Notification Services was removed from 2008 and later, there really isn't a good built-in way to do this. Microsoft's official party line is that Reporting Services can fill the gap, but practical experience proves otherwise.
You're stuck with either a 3rd party solution or rolling your own. Good luck!
Can someone guide me on how can I compare schemas in SQL Server 2008.
I want to do so to check if sql objects already exists and if they exists is there any change between the existing and the new one.
You can compare schemas in SQL Server 2008 and any new SQL Server with ApexSQL Diff and it has free Community edition.
It has user friendly UI, where you can easily pick your databases (or other data sources as backups, source control projects, script folders) compare them, get results with differences and to synchronize from source to destination database.
If you just want to compare objects to only see differences and create a merge script, you can check out a free tool - ApexSQL Compare.
One more tool that can do a job that you want is dbForge Schema Compare
Get a tool such as Red Gate's SQL Compare.
You'll need to pay for it, but it pays for itself through time saved.
It is available on a trial basis if you have an immediate need.
I don't recommend you do that if you can avoid it.
If you just want to compare two SQL Server databases, I recommend a low cost alternative http://cdttools.com/sql-diff-erence/. (caveat: I wrote it).
However for what you are referring to I recommend a different approach. you should already know the different version of the various schemas for your product that you have already shipped. So build a change script based on upgrading each of them completely to your latest version. That way you installer only has to detect a single version number and chooses its sql actions based on that.
If you really really really want to do SQL comparisons during an installer yoo might want to take a look at the SMO (Shared Management Objects) that are part of the SQL server feature pack. But you will most likely have to install those before you can use them.
Then you can use them to generate the scripts for each SQl object and do a comparison in your installer. However I honestly don't recommend this.
It will tell you if they exist, and allow you to generate either "alter" or "create" script versions. Alternatively you can go directly to the INFORMATION_SCHEMA database system objects that will allow you to query directly for objects existence.
In Visual Studio 2012, go to SQL (menu item) -> Schema Compare. Click on Select Source on the left, and select the dev database. Select the production database on the right.
Then click on the generate script icon (next to the Update icon, it looks more or less like a music icon). That will generate the update script. You may also untick any of the changes that you do not want to include in the script. And it is ... 'free' if you happen to own Visual Studio 2012
I'm trying to create a completely new database from an existing MySQL database, bringing over both data and schema, but so far the only way I've been able to do this is to first import the MySQL database into MS Access, and then into SQL Server 2005? Crazy right? Surely, there is a way that doesn't involve a tedious, custom time-consuming programming, right (perhaps using SSIS)?
A few additions to my original description above:
Its a pretty good size database (easily a few gigs).
I'm working in an MS environment (asp.net, C#)
I'm under a tight deadline so I'm looking for an automated process that requires little to no effort in the conversion process.
SSIS would be the preferred way via BIDS (VS 2005)
Thanks for all the great input!
I believe that using the phpMyAdmin tool you can script the MySQL database structure and data into a sql script. Then you simply run those two scripts on your SQL Server 2005 database and it should, in most cases, create the database and fill it with data. It's been a couple years since I had to do it myself, but as I recall that was the process I used to transfer a MySQL database to SQL Server in the past. You will probably have to alter the structure script to change some of the data types to their SQL Server equivalents, but the data should load just fine once you've got the data types all sorted.
I think you can use SQLYog to generate some fairly standard SQL which will dump out and recreate your db, with data. You may have to massage its output for SQL Server's dialect of SQL a bit, though...
The responses I received were certainly helpful, but the solution it would seem is to do a mysqldump and then run that script from SSIS, massaging the output as needed; however, AFAIK it is not possible to use VS 2005 BIDS to create an SSIS package that completely transfers a MySQL database to a SQL Server 2005 database (data and schema) using Windows Vista 64. I said AFAIK, but who knows the interwebs have much to reveal :)