dbTalk Databases Forums  

ejecuting osql, Invalid Environment Variable Specified

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss ejecuting osql, Invalid Environment Variable Specified in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alfredo C3
 
Posts: n/a

Default ejecuting osql, Invalid Environment Variable Specified - 12-13-2004 , 09:39 PM






Hi all,

I have a DTS with "Execute Process Task" and I tried to execute
"osql.exe" with
the following parameters, and was executed correctly

/U roberto /P c3tech /w 1000 /Q "select * from Parts where ItemNumber = '' "
/o "c:\PartsPartNumber.txt"

but when I tried to execute with the following query the process raise an
error,
/U roberto /P c3tech /w 1000 /Q "select * from Parts where ItemNumber like '
%' or ItemNumber = '' " /o "c:\PartsPartNumber.txt"

the diference between the two parameters are the following
ItemNumber like ' %' or

I suppose % mean 'Environment Variable',
How can I write the - like ' %' - statement correctly?

Thanks in advance.

Alfredo (C3)





Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: ejecuting osql, Invalid Environment Variable Specified - 12-14-2004 , 01:53 AM






I am unclear about if you want to use an environment variable or you think
it is getting confused with an environment variable due to the syntax.

A simple test from a DOS prompt seems to work fine, when I use % as the
standard wildcard pattern in a LIKE filter, so can you clarify what you want
and also post any error messages.

My working test command was -
osql /E /Q "select * from sysobjects where name like 'a%' "

Why don't you use the Execute SQL Task over osql since that is really the
most appropriate method of executing some SQL in DTS.


--
Darren Green
http://www.sqldts.com


"Alfredo C3" <alfredo (AT) myhostserver (DOT) com> wrote

Quote:
Hi all,

I have a DTS with "Execute Process Task" and I tried to execute
"osql.exe" with
the following parameters, and was executed correctly

/U roberto /P c3tech /w 1000 /Q "select * from Parts where ItemNumber = ''
"
/o "c:\PartsPartNumber.txt"

but when I tried to execute with the following query the process raise an
error,
/U roberto /P c3tech /w 1000 /Q "select * from Parts where ItemNumber like
'
%' or ItemNumber = '' " /o "c:\PartsPartNumber.txt"

the diference between the two parameters are the following
ItemNumber like ' %' or

I suppose % mean 'Environment Variable',
How can I write the - like ' %' - statement correctly?

Thanks in advance.

Alfredo (C3)







Reply With Quote
  #3  
Old   
Alfredo C3
 
Posts: n/a

Default Re: ejecuting osql, Invalid Environment Variable Specified - 12-14-2004 , 12:23 PM



I need to execute a sql statement and store the result in a file.

so, I'm using osql with the parameter /o "c:\myOutputFile.txt",

I need that file because I need to send it through e-mail,

The query that I tried to execute using "Execute Process Task". I use the
osql, and the sql statement that I have is the following "select * from
Parts where ItemNumber like '
%' ", the error was raised.

In cmd or DOS window works correctly, but in the dts "Execute Process Task"
raise the error.

Alfredo



"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> escribió en el
mensaje news:ebUFzIb4EHA.3420 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Quote:
I am unclear about if you want to use an environment variable or you think
it is getting confused with an environment variable due to the syntax.

A simple test from a DOS prompt seems to work fine, when I use % as the
standard wildcard pattern in a LIKE filter, so can you clarify what you
want
and also post any error messages.

My working test command was -
osql /E /Q "select * from sysobjects where name like 'a%' "

Why don't you use the Execute SQL Task over osql since that is really the
most appropriate method of executing some SQL in DTS.


--
Darren Green
http://www.sqldts.com


"Alfredo C3" <alfredo (AT) myhostserver (DOT) com> wrote in message
news:u415a1Y4EHA.1564 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Hi all,

I have a DTS with "Execute Process Task" and I tried to execute
"osql.exe" with
the following parameters, and was executed correctly

/U roberto /P c3tech /w 1000 /Q "select * from Parts where ItemNumber =
''
"
/o "c:\PartsPartNumber.txt"

but when I tried to execute with the following query the process raise
an
error,
/U roberto /P c3tech /w 1000 /Q "select * from Parts where ItemNumber
like
'
%' or ItemNumber = '' " /o "c:\PartsPartNumber.txt"

the diference between the two parameters are the following
ItemNumber like ' %' or

I suppose % mean 'Environment Variable',
How can I write the - like ' %' - statement correctly?

Thanks in advance.

Alfredo (C3)









Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.