[MSSQL] osql.exe en isql.exe doen niet hetzelfde

Pagina: 1
Acties:
  • 472 views sinds 30-01-2008
  • Reageer

  • jvdmeer
  • Registratie: April 2000
  • Laatst online: 08:47
Ik heb enkele zeer grote en tijdrovende script. Als ik die via Delphi cq ADO verwerk, duurt dat ca. 20 minuten. (Lang leve ADO).
Daarom exporteer ik de scripts nu naar een temp.sql (kost 1,5 seconde) en verwerk het script middels osql.exe (ca 1 minuut). Resultaat 19 minuten winst.

Dit gaat goed, zolang er geen '!!' en 'go' staat aan het begin van regels. Voorbeeld:
SQL:
1
2
3
SELECT 'Deze regel bevat 2 ''uitroeptekens'':
!! Met daarachter nog wat tekst.
En die 2 worden in isql wel getoond, en in osql leveren ze een error op.'


levert in osql op:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
osql -E -S <server> -d <db> -i temp.sql

1> 2> Met wordt niet herkend als een interne
of externe opdracht, programma of batchbestand.
3> 4>

 -------------------------------------------------------------------------------

        ------------------------------
 Deze regel bevat 2 'uitroeptekens':
En die 2 worden in isql wel getoond, en in
         osql leveren ze een error op.

(1 row affected)


Terwijl het resultaat in isql (tekstmode) is:
code:
1
2
3
4
5
6
----------------------------------------------------------------------------------------------------------------------------------------------- 
Deze regel bevat 2 'uitroeptekens':
!! Met daarachter nog wat tekst.
En die 2 worden in isql wel getoond, en in osql leveren ze een error op.

(1 row(s) affected)


In grafische mode blijkt zelfs alles in 1 veld te staan met CRLF's erin.

Bovenstaande was maar een voorbeeld, de praktijk is dat er SP's worden aangeroepen met een zeer lange multi-regel tekst eraan vast.

Hoe kan ik de !! escapen zonder dat de inhoud van het veld veranderd?

Verwijderd

een '-teken voor elke ! knallen? :/

  • whoami
  • Registratie: December 2000
  • Laatst online: 01:05
There is a great deal of overlap between ISQL and OSQL. Both support input scripts, output scripts, and most of the same switch arguments. OSQL has no interface. It will only accept a typed command line, or a saved script. In spite of this disadvantage, sometimes ISQL and Query Analyzer cannot accomplish the required task. Working with MSDE is one example. Query Analyzer is not included with the Microsoft Desktop Engine. When developing an application on MSDE, or needing to do MSDE administration, the OSQL utility is the only tool included. Another key difference between ISQL and OSQL is the base library each tool was built on. ISQL is developed on the DB Library, as opposed to OSQL being developed on ODBC. The DB Library works at the SQL 6.5 standard. This difference means ISQL, or any application developed on the DB Library, dose not support some of the new SQL 2000 features. The entire list of unsupported features can found in Books on Line under the title "Connecting Early Version Clients to SQL Server 2000." Some of the main limitations of ISQL include char and varchars defined greater than 255 bytes will be non accessible, big ints will be converted to decimals, sql_variants will be converted to nvarchars, XML results may not be retrieved, and bit fields that are null will be reported as not null with a value of 0. OSQL and Query Analyzer will support all of the SQL 2000 features.
klik

Maar wat is het probleem nu juist ? Blijkbaar gaat het met isql dus wel goed ?

https://fgheysels.github.io/


  • jvdmeer
  • Registratie: April 2000
  • Laatst online: 08:47
whoami schreef op dinsdag 07 februari 2006 @ 20:21:
[...]


klik

Maar wat is het probleem nu juist ? Blijkbaar gaat het met isql dus wel goed ?
Het probleem is dat er midden in teksten met CRLF's wel eens regels beginnen met twee uitroeptekens. En deze worden alleen door osql geïnterpreteerd.

Maar op gang gezet door KoeNijn, vervang ik elke
{CRLF}!!
door
{CRLF}'+'!!
En dan is het probleem opgelost.

Nou ja, eigenlijk niet helemaal, want het liefst zou ik gewoon via ADO importeren

  • Annie
  • Registratie: Juni 1999
  • Laatst online: 25-11-2021

Annie

amateur megalomaan

Uit de BOL
Operating-System Commands
Operating-system commands can also be executed by starting a line with two exclamation points (!!) followed by the command. The command recall facilities of Windows NT can be used to recall and modify osql statements. The existing query buffer can be cleared by typing RESET.
Dit verhaal geldt voor zowel isql als osql. Gezien het feit dat isql (en ook sqlcmd van sql2005) het goed uitvoeren en osql niet, lijkt me dat dit een bugje in osql is (het is immers geen los command in dit geval, maar maakt deel uit van een string).

[ Voor 8% gewijzigd door Annie op 07-02-2006 22:02 ]

Today's subliminal thought is: