Hi All,
Here i am give a code for add a new column into existing table using procedure.
Ex:
Table Name: tbl_Test
Existing Columns : Id,Name
New Column : Address
Here @sAddress='Address'
Create proc stp_AddNewColumn
(
@sAddress varchar(20)
)
AS
Declare @SqlQuery nVarchar(500) \\ DataType Must be declare as nVarchar (or) ntext (or) nChar
Set @SqlQuery='ALTER TABLE tbl_Test ADD ['+sAddress+'] varchar(50)'
exec sp_executesql @SqlQuery
I hope this code useful to Add a New Column in a Existing Table
Thanks :)