pkrieg
Mr or Mrs. 500
Points: 538
More actions
November 11, 2005 at 9:12 pm
#92026
I need to update several client databases.
How do I check table x for a column z to determine if I need to ADD column z?
In other words if column z does not exist, I want to ADD it to table x; if column z exists I want to bypass the ADD.
Thanks in advance.
Phil K
AMIT GUPTA-263376
SSCarpal Tunnel
Points: 4244
November 11, 2005 at 10:39 pm
#603540
you may use the following command:
if not exists (select * from information_schema.columns where table_name=<tbl_name> and column_name=<col_name>
begin
alter table table_name add col_name <type>
end
use it and ask if any problem.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply