views:

41

answers:

1

I was wondering if these two queries could be combined into a single query?

Query 1: to get the @guidID to be plugged into Query 2:

DECLARE @guidID uniqueIdentifier
    SET @guidID = (SELECT guidID FROM dbo.table1 WHERE IntID = 1) 

Query 2: retrieves a combined table from a function and table1

SELECT o.guidID, IntID, Title, func.Name 
  FROM dbo.table1 o
 INNER JOIN dbo.func1(o.guidID) func ON func.guidID = o.guidID
 WHERE IntID = 1

func1 takes in a guidID object Returns a table of (guidID, IntID

Thanks for any help, this is as far as I've gotten, which give me the data that I need but in two separate queries.

+2  A: 
gbn
I'm getting an error: "Incorrect syntax near '.'." for the (o.guidID) on line 5. Any suggestions? I've been looking into it, but can't seem to solve the problem.
Brett
ah. You're on SQL Server 2000 or you have the db compat level at 80 (or lower). Use the 2nd form I gave please
gbn
I'm on SQL Server 2008, and I'm not sure what the db compat level is, as googling didn't tell me too much. But I get the same error when I attempt to run the second form.
Brett
http://stackoverflow.com/questions/1501596/how-to-check-sql-server-database-compatibility-after-sp-dbcmptlevel-is-deprecated and my 2nd form is wrong, sorry
gbn
@gbn - Well, I'm going to keep toying with the CROSS APPLY, because everything I read about it seems to point towards this application. If you have any other thoughts on how to get my script to work, let me know! Thanks for your help so far.
Brett