Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Search two different tables, same table design?

Author  Topic 

slboytoy
Starting Member

30 Posts

Posted - 2004-11-03 : 11:02:38
I have two tables with names and passwords. One table is Managers, another Table is Floor. Same column names, and everything. When I do searches, how can I make them act as one?

if exists(SELECT UserName, Password FROM dbo.Floor Where UserName = @UserName)
begin
if exists (SELECT Active FROM dbo.Floor Where UserName = @UserName And Password = @Password and Active = 1)
begin
SELECT @FullName = FirstName + ' ' + LastName, @VMNum = VoiceMailNumber, @UserType = TerritoryType FROM dbo.Floor Where UserName = @UserName
return(5)
end
else
return(1)
end

if exists(SELECT UserName, Password FROM dbo.Managers Where UserName = @UserName)
begin
if exists (SELECT Active FROM dbo.Managers Where UserName = @UserName And Password = @Password and Active = 1)
begin
SELECT @FullName = FirstName + ' ' + LastName, @VMNum = VoiceMailNumber, @UserType = TerritoryType FROM dbo.TerritoryManagers Where UserName = @UserName
return(5)
else
return(1)
end



rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-11-03 : 11:37:30
You could use a view that unions the 2 tables, and query the view.
Also why have 2 tables, it would probably better to have one table Employees with common info,
then Floor+Manager tables related to the Employee table which contain the columns that are only applicable to Floor/Manager.

rockmoose
Go to Top of Page
   

- Advertisement -