Stored Procedures between SQL 2000 and 2005

Hi,

I am moving from SQL 2000 - 2005 and have copied existing SP's over, however the example SP below works fine in 2000 but yields no results in 2005 even though the table structures and data are the same. If I remove the joins then I do get a result, does 2005 deal with joins differently?
CREATE PROCEDURE dbo.wbAdmin
(
 	@USERNAME VARCHAR(20),
	@PASSWORD VARCHAR(10)
)
 
AS
SET NOCOUNT ON
 
SELECT  ISNULL(B.EmpID,'0') AS EMPMGR, ISNULL(C.EmpID,'0') AS COSTMGR, COMPNAME,A.COSTID,A.CompID,[Password],A.EmpID,Email,Service,Personal,BillType
FROM  wbEmpl A  
LEFT OUTER JOIN wbEmplManager B ON A.EmpID = B.EmpID
LEFT OUTER JOIN wbCostManager C ON A.EmpID = C.EmpID
INNER JOIN wbCompany D ON D.COMPID = A.COMPID
 
WHERE EMAIL =  @USERNAME AND [PASSWORD] = @PASSWORD
GO

Open in new window

trojan_ukAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

f_o_o_k_yCommented:
Hello
First of all you should use Upgrade Advisor to check if there can be some problem with your database on 2005
http://www.microsoft.com/downloads/details.aspx?familyid=1470E86B-7E05-4322-A677-95AB44F12D75&displaylang=en

There is no difference in JOINs because they must be compilant with SQL-92

Did you try to run this code without WHERE

Use this qeuries to find out where problem is: (code below)

Best Regards
FooKy

SELECT  ISNULL(B.EmpID,'0') AS EMPMGR, ISNULL(C.EmpID,'0') AS COSTMGR, COMPNAME,A.COSTID,A.CompID,[Password],A.EmpID,Email,Service,Personal,BillType
FROM  wbEmpl A  
 
SELECT  ISNULL(B.EmpID,'0') AS EMPMGR, ISNULL(C.EmpID,'0') AS COSTMGR, COMPNAME,A.COSTID,A.CompID,[Password],A.EmpID,Email,Service,Personal,BillType
FROM  wbEmpl A  
LEFT OUTER JOIN wbEmplManager B ON A.EmpID = B.EmpID
 
SELECT  ISNULL(B.EmpID,'0') AS EMPMGR, ISNULL(C.EmpID,'0') AS COSTMGR, COMPNAME,A.COSTID,A.CompID,[Password],A.EmpID,Email,Service,Personal,BillType
FROM  wbEmpl A  
LEFT OUTER JOIN wbEmplManager B ON A.EmpID = B.EmpID
LEFT OUTER JOIN wbCostManager C ON A.EmpID = C.EmpID
 
SELECT  ISNULL(B.EmpID,'0') AS EMPMGR, ISNULL(C.EmpID,'0') AS COSTMGR, COMPNAME,A.COSTID,A.CompID,[Password],A.EmpID,Email,Service,Personal,BillType
FROM  wbEmpl A  
LEFT OUTER JOIN wbEmplManager B ON A.EmpID = B.EmpID
LEFT OUTER JOIN wbCostManager C ON A.EmpID = C.EmpID
INNER JOIN wbCompany D ON D.COMPID = A.COMPID

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
f_o_o_k_yCommented:
Sorry my mistake I forgot to remove some fields from SELECT but you can correct them.
0
trojan_ukAuthor Commented:
Thanks fooKy,

That did help me get to the bottom of it, basically it looks like when I imported the data accross it has reset all the identities instead of importing the existing ones, so where the original empid in the emp table was 114 and the compid was 12, the empid is now 107 and the compid is 2. so when the last inner join checked for a company id, it was 12 in the emp table but 2 in the company table, hence why the join failed.

Is there a way to import the existing identity fields?
0
f_o_o_k_yCommented:
Yes
You must set the identity_insert option to on and then use insert but you must specify column names in insert.
take a look.
http://msdn2.microsoft.com/en-us/library/ms188059.aspx


0
trojan_ukAuthor Commented:
Thanks fooKy, I did work it out in the end I did a Backup/Restore between 2000 and 2005 and that did the trick.

Thanks again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.