Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Added multiple columns from VFP app
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Titre:
Added multiple columns from VFP app
Divers
Thread ID:
01670715
Message ID:
01670715
Vues:
58
Hi,

I have a code in my VFP application that allows checking if a column exists in a table of a SQL Server database and then add it. The segment of the code that I execute from VFP is below:
TEXT TO cSqlCommand TEXTMERGE NOSHOW
	IF NOT exists (select COLUMN_NAME from INFORMATION_SCHEMA.columns where table_name = '<<tcTableName>>' and column_name = '<<tcFieldName>>' ) 
		BEGIN
			alter table <<tcTableName>> add <<tcFieldName>> <<tcFieldType>> null 
	        SELECT CAST(1 AS bit) AS col_added
	    END    
	ELSE 
		SELECT CAST(0 AS bit) AS col_added
ENDTEXT
The above works fine for one column.

Now I now I need to add more than one column to a table. I could run the above code, with different values of the field name (tcFieldName) and I am sure it will work. But the table is fairly large - almost a million records. So, I am thinking that the above code executed more than one time will take longer (I don't really know how much longer though).

I am thinking that it would be nice to add more than one column in one process. Is it possible? Can I "string" multiple "ALTER TABLE ... ADD " into one command?

TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform