Sunday, February 19, 2012

C# and SQL Help

i am trying to grab all records from table 1 (TAB1) that exists in table 2 (TAB2) but TAB1 exists in database 1 (DB1) and TAB2 exists in database 2 (DB2)...

i need all the records from TAB1 where the WHERE clause is valid with the corresponding record from TAB2 (for each TAB1 record pulled there is a one for one shot on TAB2)

my SQL code looks like this: @."SELECT dbo.DB1.TAB1.*, dbo.DB2.TAB2.firstname+' '+ dbo.DB2.TAB2.lastname as fullname

FROM dbo.DB1.TAB1 RIGHT OUTER JOIN dbo.DB2.TAB2 ON dbo.DB1.TAB1.EmpID = dbo.DB2.TAB2.EmpID

WHERE dbo.DB1.TAB1.ID = @.ID"

but this isn't working... i keep getting the error messege of:

Invalid object name 'dbo.ConflictResolutionSystem.Comments'

any and all help GREATLY appreciated... Thanks!!!

VinnyPip:

dbo.DB1.TAB1

I think it should be DB1.dbo.TAB1, change in all occurances. If this doesn't work, try a stored procedure.http://forums.asp.net/p/1139888/1831338.aspx#1831338

|||

Hey,

Yes, should be in the format of Server.Database.schema.table.column; ensure it's that order. Oh, and of course you don't have to specify server and database name if you don't want to, only if you need to.

No comments:

Post a Comment