Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
DECLARE @Temptable AS TABLE
(
 cusname nvarchar(250),
 mobno bigint,
 address1 nvarchar(350),
 address2 nvarchar(350),
 state nvarchar(150),
 country nvarchar(150),
 arrdate nvarchar(150),
 depdate nvarchar(150)
)

INSERT INTO @Temptable

--Table 1
SELECT cusname,mobno,address1,address2,state,country FROM cusdetails

--Table 2
SELECT arrdate,depdate FROM roombooked WHERE rid=@rid 
and arrdate=(SELECT max(arrdate) FROM roombooked)


SELECT * FROM @Temptable



Error
All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
Posted
Updated 10-Oct-12 20:53pm
v2

Just join thoses 2 tables.

If you cant, there is something wrong with you data.
 
Share this answer
 
SQL
INSERT INTO @Temptable

SELECT cusname,mobno,address1,address2,state,country,arrdate,depdate FROM cusdetails cd
join roombooked rb on cd.CustId=rb.CustId  WHERE rid=@rid
and arrdate=(SELECT max(arrdate) FROM roombooked)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900