Querying an Oracle linked server fails

The other day, I needed to pull some data from an Oracle server on our network. The oracle server was set up as a linked server on my SQL Server 2005 machine. For some reason, the query didn’t work. Now, when working with an oracle linked server, you have to include the linked server name, the schema name and the table name. Also, you can use an alias just like any SQL Server table. But, the key thing is to include the schema and table name. The query looks something like this: select col1 from [OracleServer]..[schema_name].[table_name] For some reason, the … Continue reading Querying an Oracle linked server fails

Great Circles in SQL Server 2005 and SQL Server 2000

Recently, I had a request to calculate the distance between 2 GPS coordinates. Now, the system I am working with is SQL Server 2005. SQL Server 2008 gives us the geography data type, which is great and has a lot of powerful features. But, if you’re using SQL Server 2000 or 2005, you won’t have access to any spatial data types. Now, the table i was working with had the city name along with the Latitude and Longitude information. So, I went over to wikipedia and got the formula for calculating distance using great circles. I won’t go into the … Continue reading Great Circles in SQL Server 2005 and SQL Server 2000

Automatic Index Rebuilding

While working on a large project, I found that the queries were running slower and slower as the days went on. We were working with current and historical data and were only joining about 3-5 tables at a time. Each join was bringing back between only about 50K rows or so, and the results were aggregated and tossed up on an SSRS page. Since things were going well at first and started slowing down over time, I figured the indices were probably the cause. If you don’t know much about indices, or you need to brush up on your knowledge, … Continue reading Automatic Index Rebuilding

Importing Data into SQL Server – Using Excel Shortcuts

I’ll be the first to say, the switch from DTS to SSIS was painful. DTS would go through a lot of implicit conversions so you didn’t have to worry or think about them. But SSIS was not as merciful. From different fields lengths to different encodings, SSIS wants you to be specific. Sometimes, it is just quicker to use some excel trickery than figuring out that you should have defined a column as a String 65 instead of the default String 50. We will use the CountryList.csv file and CountryList table from the original Importing Data in SQL Server post. … Continue reading Importing Data into SQL Server – Using Excel Shortcuts