Click here to Skip to main content
15,888,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai Sir,

In my database I have a table with columns col1,col2,col3.

I want to give the fourth column i.e..,col4 from the front end(when I click add column button in my front end).

Now the updated table should be like col1,col2,col3,col4 after altering the fourth column.

Is it possible to alter a column from Frontend? If possible what is the stored procedure/query for that?

Thanks in Advance...
Posted
Updated 26-May-15 2:57am
v2
Comments
ZurdoDev 26-May-15 9:04am    
It depends on what you want to do. Just google it. For example, google sql alter column and there are tons of examples.

Read SQL ALTER TABLE Statement[^] and buld the sql statement based on user inputs and excute the sql statement. How you take the inputs, build sql statement and execution depends on which programming language technologies you are using.
 
Share this answer
 
XML
Yes.
<pre lang="sql">ALTER TABLE MyTable
ADD newIntegerColumnName INT DEFAULT 666</pre>
It's a good idea to provide a default value if you already have existing rows.
 
Share this answer
 
Yes you can add new column from the front end. You have to pass the sql statements
SQL
ALTER TABLE TableName ADD ColumnName DataType
 
Share this answer
 
you can use EXEC statement for this requirement

pass your coulmn name and table name as parametr from front end ]

Run your SQl querry like this


example

SQL
EXEC ('alter table tb1 add col1 varchar(1) null')
EXEC ('update tb1 set col1 = ''Y''')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900