mssql query modification

Last Post 21 Apr 2009 12:30 AM by SwePeso. 1 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
vinay789
New Member
New Member

--
18 Apr 2009 03:26 AM

Hi i am new bie to ms sql i want to place the data like this
for(int i=3;i<=5;i++)
{
select
adid,state,country
from
Tablei
}
Hi i want to place the data like this
Table1,Table2,Table3 tables i want to retrive data using select statement first i want to retrive data from Table1 after finishing Table1 now i want to retrive data for Table2 after combining Table1,Table2 i want to combine Table3 also so i think it is better to go with for loop Table1,Table2,Table3 contains similar fields.So no problem arises but it is not working any suggestions
SwePeso
New Member
New Member

--
21 Apr 2009 12:30 AM
SELECT adID,
State,
Country
FROM Table1

UNION ALL

SELECT adID,
State,
Country
FROM Table2

UNION ALL

SELECT adID,
State,
Country
FROM Table3

or use dynamic sql.


Acceptable Use Policy
---