473,395 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Add coloumns dynamically in a table

I have a table tbl_tmp1

There are two fields

EmpId EmpName

I have another table tbl_Heads in this table ther are total 8 records

I want to add number of coloumns equal to the row count i.e 8 of table tbl_Heads in tbl_tmp1. The newly added coloumns name should be the same of the name of the value of the HeadName field in table tbl_Heads

How this is possible
Apr 11 '08 #1
4 1256
debasisdas
8,127 Expert 4TB
What about the column datatype ? From where will you get that ?
Apr 11 '08 #2
madankarmukta
308 256MB
Hi.
The solution to the problem stated by you is possible with executable query

as exec 'Alter table tablename add ' + cloumname + ' datatype'
in the above columnname can be accessed by using the cursor over your table with 8 rows i.e. tbl_header.

the cursor defination will be
declare cur cursor as select headername from tbl_header

As u will iterate through the cursor the next headername will be available to the above mentioned executable query.

Thus the Cloumns will be added dynamically.
Apr 11 '08 #3
madankarmukta
308 256MB
Hi
sqlvarient is datatype which is use to hold the data of any type .. you can use it.
Or else you can use IsNumeric to check for the numeric value.If it is non numeric the data might be string .This is the way how you can decide datatype of the values in the table.

Regards,
Mukta
Apr 11 '08 #4
ck9663
2,878 Expert 2GB
Pivot your table. If necessary, build your query dynamically.

-- CK
Apr 11 '08 #5

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

Similar topics

0
by: Binay Agarwal | last post by:
------=_NextPart_000_009E_01C36135.F4E3B2F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi While using OR in the query, Mysql doesn't use...
5
by: john_williams_800 | last post by:
Hi; I am just starting to use the DOM to do some more advanced javascripting so please be patient with my question if it is an ignorant question. I would like to use the DOM to dynamically...
3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
1
by: jaffar | last post by:
hi, i am developing an appllication, in this appllication i am using datagrid . in this datagrid coloumns header text i want to change coloumn header text in vertically it means datagrid...
1
by: suryar | last post by:
Great help if some one help me I have a excel file with 18 coloumns, I want to read all the coloumns in vb scrip and want to display in note pad
6
by: dhillarun | last post by:
Hi all, I need to update field three of first table with field three of second tables for all records that match field one of first table with field one of second table (both are primary key...
0
by: prakashamnkl | last post by:
i want to split the data grid coloumns into a sub header. And one more thing I want to insert the trackbar into the datagrid cells . Anybody have answers for my question plz reply me.
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
2
by: anuragvatsa | last post by:
Hi all, well am new to SQL. There is a scenario, where i have to add values from two coloumns selected on the basis on particular ID and then add the total or average values of the resulted column....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.