Keyboard Face

when you find QWERTY imprinted on your cheek - it's time to go to bed.

Tags

asp CSS css menus dreamweaver flash gallery2 hosting iis7 Javascript jquery jquery ui left mac mssql os9 php printer rdp SEO sql sql server windows wordpress

Getting PHP and Microsoft SQL Server (MSSQL) to play nice

August 24, 2011 by Tom Leave a Comment

I have a Windows Server 2008 with IIS7 installed. I’ve been pounding my head against a Microsoft constructed brick wall for the past day trying to get PHP to interact with SQL Server 2008.

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=20098

A brief Google search pulls up a download page from Microsoft with the newest SQL Server drivers for PHP:

In the package you download, there are about 9 different files. You only need to install 1 or 2 and there are no instructions as to which one is the one to install.

In my case, even installing ALL of them didn’t work. My PHPInfo() said there was sql server support, but it wouldn’t connect to the sql server.

FINALLY, I found a single post that explained it. Turned out my PHP version which was installed by IIS7 was too old! For SqlServer to work – you have to have PHP 5.2.4 or newer.
The help instructions that come with it aren’t specific enough.

http://social.msdn.microsoft.com/Forums/en/ssdsgetstarted/thread/5fa1215f-5104-40f3-ac5c-872c4812f416

Lastly, here’s a great link that goes over how to actually use the sqlserver connection. Good god!

http://social.technet.microsoft.com/wiki/contents/articles/whitepaper-accessing-sql-server-databases-from-php.aspx

One other thing to note if you’re used to working with .NET or Classic ASP. In PHP the field names are case sensitive.

Filed Under: PHP, SQL Server Tagged With: php, sql server

MSSQL: Joining another server in a select statment

April 21, 2009 by Tom Leave a Comment

I’ve often wondered if I could have a select statement that retrieved data from two databases at a time. I just got a SQL Server tip in the mail this morning that walks you through the steps. It’s awesome! Does everything and more. The keyword is OPENROWSET.

Here’s the link:
http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1353663_mem1,00.html

Example from above article:
SELECT e1.EmployeeID, e2.FirstName, e2.LastName, e1.JobTitle
FROM OPENROWSET(
'SQLNCLI',
'Server=SqlSrv1;Trusted_Connection=yes;',
'SELECT EmployeeID, FirstName, LastName, JobTitle
FROM AdventureWorks.HumanResources.vEmployee'
) AS e1
INNER JOIN OPENROWSET(
'Microsoft.Jet.OLEDB.4.0',
'C:\Data\Employees.mdb'; 'admin';' ',
'SELECT EmployeeID, FirstName, LastName, JobTitle
FROM Employees'
) AS e2
ON e1.EmployeeID = e2.EmployeeID
ORDER BY e2.LastName, e2.FirstName

Here’s the MSDN link on OPENROWSET.
http://msdn.microsoft.com/en-us/library/ms190312.aspx

Filed Under: SQL Server Tagged With: sql

MSSQL Large Sub Query Impossibility

January 2, 2009 by Tom Leave a Comment

I recently had to query to find out how many records from one table were not in another really large table. When you do a select statement like this in MSSQL it overflows and gives you a response of 0. Not very helpful:

select count(*) from Table1 where Field Not In (Select Field from Table2)

All other ideas failing, I finally resorted to writing a query using a temp table variable:
set nocount on;
declare @Tables table (
PK int IDENTITY(1,1),
Field1 varchar(100), Field2 varchar(100)
);
insert into @Tables(Field1 , Field2 )

select t1.Field, t2.Field from Table1 t1
left outer join Table2 t2 on
t1.Field = t2.Field;

set nocount off;
select count(*) as Count, Field1 from @Tables
where Field2 is Null
Group by Field1
Having Count(*) < 2;

Talk about complicated! If you have any other better ways of doing this – please let me know!

Filed Under: SQL Server

  • 1
  • 2
  • 3
  • …
  • 5
  • Next Page »

Pages

  • About Me
  • WordPress Permalinks in IIS using Custom 404 Redirect

Archives

  • May 2019
  • February 2019
  • January 2018
  • May 2016
  • April 2016
  • December 2015
  • November 2015
  • May 2015
  • April 2015
  • January 2013
  • March 2012
  • February 2012
  • December 2011
  • September 2011
  • August 2011
  • November 2010
  • October 2010
  • June 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • September 2009
  • August 2009
  • July 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • November 2008
  • September 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • December 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • January 2007
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • May 2005

ASP.NET Resources

  • Keven Roth’s Code Library
  • Lemon Law

Blogroll

  • Arin Morfopoulos
  • Jamie
  • Physical Therapists

Code Search Engines

  • Koders
  • Krugle

CSS & Design Resources

  • CSS Basics

Other

  • Amazon
  • Car Repair Questions
  • Cool Quizzes
  • Delphi LA
  • Physical Therapy Clinic Directory
  • Quickbooks Questions
  • Secret Santa Game

Site\'s I\'ve Designed or Helped With

  • Area Rugs
  • Dental Implants
  • Dental Website Design
  • FHA Loans
  • Secret Santa Gift Ideas