I have a query as the below one:
alter table [toolDB].[dbo].[esn_sho] add esn_umts_sho_relation_key as Convert(nvarchar(50),[utrancell])+'_'+Convert(nvarchar(50),[utranrelation])
So All I need I want to replace esn_umts_sho_relation_key column if exist...
As I got this error:
[Microsoft][SQL Server Native Client 11.0][SQL Server]Column names in each table must be unique. Column name 'esn_umts_sho_relation_key' in table 'toolDB.dbo.esn_sho' is specified more than once
I tired to use the below code but it's doen't work:
IF NOT EXISTS (alter table [toolDB].[dbo].[esn_sho] add esn_umts_sho_relation_key as Convert(nvarchar(50),[utrancell])+'_'+Convert(nvarchar(50),[utranrelation]))
It gives me this error:
Incorrect syntax near the keyword 'alter'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'
So I want to add If Exist in this query any one knows how to solve this prolem...
The column I already exist in the table ,but I want to replace it if exist to escape from this error...
excelsfiles to thesqlI replace all the tables, and If I add add another columns So I'll replace the old columns with the new column with the new values, as this query is one of my queries