.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

how to check multiple values from two tables

Posted By: parthiban     Posted Date: November 08, 2012    Points:5   Category :Sql Server
i got a registration form in which we have to check username and companyname from two tables...[username from table1,companyname from table2]..if name already exists it should throw error,else insert records into table 3..

TABLE1:

USERNAME
COMPANYNAME
PASSWORD
ADMINISTRATOR

TABLE2:

COMPANYNAME
ADDRESS
CONTACT
LICENSE

TABLE3:

USERNAME
PASSWORD
COMPANYNAME
CONTACT



Responses
Author: Narayanan             
Posted Date: November 10, 2012     Points: 20   

Hi ,
try this way
alter procedure sp_insertlogin
@companyname varchar(20),
@username varchar(20)

as
if exists (select companyname,username from tbl_login where companyname=@companyname and username=@username)

begin
return 1
end

else
begin
insert into tbl_login(companyname,username)values(@companyname,@username)
end


Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: border louis             
Posted Date: November 17, 2012     Points: 20   

hi
when we are going to attend an interview is their any chance of asking this type of questions please give me reply..

http://job-des-criptions.com/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend