Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Linked server syntax fun
Message
 
À
10/12/2008 13:00:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01366470
Message ID:
01366495
Vues:
11
>>>>>>>Has someone come up with any kind of automation tool to build these sql strings with 1000000000000 number of single quotes?
>>>>>>
>>>>>>What strings are you referring to and what is the problem?
>>>>> Something like this:
>>>>>
>>>>>declare @sql_str char (4000)
>>>>>set @sql_str =
>>>>>'select * from openquery(VAMCPD,
>>>>>''select a.cItemno,a.nShipQty,a.nSalesAmt-a.nDiscAmt as Amt
>>>>> from aritrs a
>>>>>inner join arinvc b on a.cInvNo=b.cInvNo
>>>>>where a.cCustno+a.cInvNo like ''' + '''59002' + '%''' + ''' and cType= '''''
>>>>>+ ''''''')'
>>>>>--select @sql_str
>>>>>exec (@sql_str)
>>>>>
>>>>>it took just a couple hours, or even more. I am trying to add more parameters to a query and it is a nightmare.
>>>>
>>>>Sorry but I still do not understand what you're doing and where. Do you build the string in VFP or in SQL Server stored procedure? Where parameters comes from and how?
>>>
>>>I am going to have a SQL SP to run this code. Parameters will be sent into that procedure.
>>>The problem is building correct SQL string with all these quotes.
>>
>>Why you need Dynamic SQL ?
>Do you know another way of running non-SQL code from SQL Server?



You can't run non-SQL code in SQL Server no matter what you try:
select * from openquery(VAMCPD,'select a.cItemno,a.nShipQty,a.nSalesAmt-a.nDiscAmt as Amt
                                       from aritrs a
                                inner join arinvc b on a.cInvNo=b.cInvNo
                                where a.cCustno+a.cInvNo like '''59002%''' and cType= ''''')
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform