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
 SQL Server Development (2000)
 Creating the table dynamically

Author  Topic 

vin
Starting Member

26 Posts

Posted - 2003-03-12 : 06:51:40

hi

Assume i have a table..

col1 col2
---- -----
xxx india
xxx us
xxx china


Based on the values in col2, i need to create
a temporary table, whose column names has to be
selected from col2. This has to be done dynamically
as the values in col2 can change and using those values create a temp table dynamically

eg.. create table #xxx (india varchar,us varchar, china varchar)

How should i go about this. ?

In my SP should i use a cursor to select and store the data in col2.?

If show, how would i substitue those values in create table
statement?

Please suggest me
regards
vin

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-03-12 : 06:53:38
Use Dynamic SQL.

Jay White
{0}
Go to Top of Page
   

- Advertisement -