Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored Procedure
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00791340
Message ID:
00791496
Views:
12
Hi Nathani,

Something like this may help you. But i am not sure about the datatypes you want to have in in table B. Change the @myDataType value according to need.
----------
declare @cur_row tinyint, @tot_records tinyint, @sqlstring varchar(1000), @myDataType varchar(50)

select @tot_records = count(*) from Table_A
if @tot_records=0
return
select @cur_row = 2, @myDataType = ' int '
select @sqlstring = 'create table Table_B (myCol1 ' + @myDataType
while @cur_row <= @tot_records
begin
select @sqlstring = @sqlstring + ', myCol'+convert(varchar,@cur_row)+
@myDataType
select @cur_row = @cur_row + 1
end
select @sqlstring = @sqlstring + ')'
exec(@sqlstring)
select * from table_b
-----------


Bye
Raj
Previous
Reply
Map
View

Click here to load this message in the networking platform