Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Executing two command in one string
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01568990
Message ID:
01569023
Vues:
26
>>>>>Hi,
>>>>>
>>>>>I think I can sent two command to SQL Server from VFP app (using SQLEXEC()) but I am not sure what separator to use. Should it be semi colon? For example if I want to alter a column and then set a value into this column, can I do the following:
>>>>>
>>>>>
>>>>>cSqlCmd = "alter table MyTable alter column MyFld1 char(30); update MyTable set MyFld1 = repl('0',30) where len(MyFld1) = 0"
>>>>>nRetunr = SQLEXEC(nConn, cSqlCmd)
>>>>>
>>>>>
>>>>>Will the above work? TIA
>>>>>
>>>>>UPDATE. I ran it and it works.
>>>>
>>>>Yes, you can and should use semicolon. You can also use text endtext to put commands in multiple lines to improve readability.
>>>
>>>What would be an exmaple of my string above using 'text / endtext'?
>>
>>text to lcSQL noshow
>>alter table MyTable alter column MyFld1 char(30); 
>>update MyTable set MyFld1 = replicate('0',30) where len(MyFld1) = 0;
>>endtext
>
>I see. I thought that you meant that a key words 'text' and 'endtext' could be passed in the string to the SQL Server. So the separator is still a semi colon. By the way, is there a max length of the string (e.g. lcSql) to pass to SQL server?
>Thank you.

I am not sure of the max length of the SQL command. I passed relatively long scripts (~30+ lines) OK. New versions of SQL Server will make ; to be required so it's a good idea to use ; at the end of SQL commands.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform