Is there a LookupSet equivalent in SQL Server 2008 ... NOT r2? - sql-server-2008

Just spent the day figuring out how to properly use the LookupSet method only to find out it isn't supported on my production database which is NOT running SQL Server 2008 R2 (it is just running ol' SQL Server 2008).
So, is there a way to re-produce the functionality so it will work with old SQL Server 2008?
Thanks - wg

As Gordon Linoff points out in the comments, this can usually be implemented in the SQL query. If the datasource for your target of the LookupSet is similar enough to the the main query, then you can accomplish this with a Common Table Expression or a correlated subquery in SQL.

Your could write custom code - which I wouldn't recommend because it's probably simpler to combine the data relationally first in your query. If one of the data sources is non-relational, then use SSIS to get it into a table and then use a query to combine the two sets of data.

Related

Querying data by joining two tables in two databases (different database types) on different servers

I have a MS SQL (SQL Server 2008) database with some data in it and a postgresql (9) database with other data. I need to do some queries to find related data. I know how to link two MS SQL databases together but not sure how to even start with the mixed database types.
The new company I work for has postgresql, I have not worked with it before. The guy I replaced was really the only one here who knew much about it. So no internal resources.
I'm not ready to build a solution in code at this point (.NET), just hoping to have a tool to do some queries.
Postgresql has table
Company
Company_id, Company_name, ....
MS SQL had table
Companies
company_name, postgresql_company_id, company_id, ....
If you ever need to run queries from Postgres that pulls data from SQL-Server, you can use foreign data wrappers. The ODBC driver should work fine:
http://wiki.postgresql.org/wiki/Foreign_data_wrappers
I'm not familiar enough with SQL-Server to give an authoritative answer on how to do it the other way around, but since Postgres speaks ODBC, I'm guessing it's close enough to how you make a SQL-Server talk with another one.
Related thread: SQL Server 2012: Add a linked server to PostgreSQL

T-SQL connector for MySQL

Is there any way to use T-SQL queries with MySQL database, like having a data connector that understand TSQL and can connect to MySQL?
Short answer, no.
By the time you've developed or found an interface that could translate T-SQL syntax into MySQL (correctly); you might as well have learnt the syntax required to write the MySQL you need.
It's not all that different to be honest; and it will broaden your knowledge and make you flexible for other types of database query languages.

How to create a query in Data Method to select from OLAP cube in moxl reports?

I can without any problems run a sql query in DataMethods in Business Intelligence when I use DynamicsReports.
Question: How to use the same way for MDX query?
I want to run a MDX query in DataMethod because I need to work with the results - to use Linq to Datatable.
Is any way to do that, or to run a DataSet in DataMethod?
I assume that you want data access methods similar to SQL for MDX as well.
You can created linked server for SSAS and use openquery to exec MDX.
SELECT * FROM OPENQUERY(linked_server_olap, mdx_query)
You can execute this as sql statement / store procedure
Other alternative would be using ADOMD.NET

How can I query XML data in SSRS / VS 2008?

I have a report query using a lot of WITH XMLNAMESPACES to query some XML data in SQL Server 2008. It doesn't look like i can create a report in VS 2008 using this query because of the xml querying. If I'm reading MS's whitepaper correctly, you have to pull the XML out and then do a separate query against it? Anyone have any experience with this, or is there a better way?
And this is an issue of misinterpreting errors. The real issue in my query wasn't the use of WITH XMLNAMESPACES, but the use of "sql:variable("#varName") in the WHERE of my XSL. Easy way to solve that is to add a DECLARE #varName in the query and set it to the passed in parameter. After that, it worked like a champ.

MySQL to SQL Server migration

I have a mysql database full of data which I need to keep but migrate to SQL Server 2008.
I know end to end where the data should go, table to table but I have no idea how to go about moving the data. I've looked around the web but it seems there are 'solutions' which you have to download and run. I'd rather if possible do something myself in terms of writing scripts or code.
Can anyone recommend the best way to do this please?
You have several options here:
On the sql server side, you can set up a connection to your old mysql db using something called a linked server. This will allow you to write sql code for sql server that returns data from the mysql tables. You can use this to build INSERT or SELECT INTO statements.
You can write queries for mysql to export your data as csv, and then use the BULK INSERT features of sql server to efficiently import the csv data.
You can use Sql Server integration services to set move the data over from mysql.
Regardless of which you choose, non-data artifacts like indexes, foreign keys, triggers, stored procedures, and security will have to be moved manually.
Have you tried tool from MSFT called SQL Server Migration Assistance for MySQL ???
https://www.microsoft.com/download/en/details.aspx?id=1495
Try this tutorial it is very easy to perform migration to SQL Server from Mysql and is straightforward as mentioned
http://www.codeproject.com/Articles/29106/Migrate-MySQL-to-Microsoft-SQL-Server
Thanks
You can use the Import/Export Wizard that comes with SQL Server Standard Edition.
Select your 'data source' from MySQL using the ODBC data source. Note: You will need to first install the from ODBC driver for MySQL (ODBC Connector). Then, select your SQL Server destination. Select all tables, and fire it up. You will need to add your primary and foreign keys, and indexes manually.
A bit more automated means would be by using the SQL Server Migration Assistant for MySQL, also free. It has the benefit of recreating the relationships and indexes automatically for you. Probably your best bet.
I did it once, some time ago. First you could couple your mssql server to the mysql server using the odbc mysql connector
http://dev.mysql.com/downloads/connector/
After the connection is made you can write you database procedure as you would if it were two mssql db's. Probably easiest to write some sql batch scripts including a cursor where you run through every every row of a table an decide on a field basis where you will need the field in the future.
example of a cursor: http://www.mssqltips.com/tip.asp?tip=1599
If you decide to go with the cursor, you can play with the parameter to increase performance. I especially remember the FORWARD_ONLY parameter giving a big boost.