By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

how to build tables at run time in sql server 2005

P: 21
Hi,

Hi to all, I am manivel.. i have two tables in sql server 2005.. now i want to select some items from this two tables and want to save in new table.. please any one help me, how to create tables at run time..

Thanks inadvance..

Cheers,
Manivel. K.
Mar 3 '08 #1
Share this Question
Share on Google+
2 Replies


P: 1
Hi,

Hi to all, I am manivel.. i have two tables in sql server 2005.. now i want to select some items from this two tables and want to save in new table.. please any one help me, how to create tables at run time..

Thanks inadvance..

Cheers,
Manivel. K.
Hi.
I am not getting u fully..i guess like

select table1.field1, table2.field into newtablename from table1, table 2 where table1.field= table2.field

By
Gandhi M K
Mar 3 '08 #2

P: 92
Hi.. You can do something like this

DECLARE @MyTable AS TABLE (Column1 INT, Column2 VARCHAR(10))
INSERT INTO @MyTable (Column1, Column2)
VALUES (
(SELECT Num1 FROM Table1 WHERE TableID = '1'),
(SELECT Name FROM Table2 WHERE TableID = '1')
)

This, however, won't retain the created table when the query execution ends.
Mar 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.