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.
Author |
Topic |
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-04-17 : 03:06:58
|
/* SELECT Name, dept_id, col_Name FROM temp_mainSELECT Name FROM temp_dynamicexec sp_alter_table_column (Name,dept_id,salary,Age)*/create procedure sp_alter_table_column (@csv_column nvarchar(max))as declare @str_col_main nvarchar(max), @str_col_dynamic nvarchar(max) , @str_sql varchar(max) begin Select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='temp_main' Select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='temp_dynamic' --if the new column name are not found in temp_main, add new column in temp_dynamic . make sure temp_dynamic also doesnot have the new column @str_sql = "Alter table temp_dynamic Add Column Dept_Id int NOT NULL, Desig_Id int NOT NULL" exec @strsqlendTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-04-17 : 08:55:03
|
Duplicate of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=184613 |
|
|
|
|
|