Sunday, March 11, 2012

Cannot use the OUTPUT option when passing a constant to a stor

I just checked the message today. I have tried the queryout method but
without any success because I keep getting a syntax error.
My Code:
bcp "Select Replace(Str(UNITNUM, 12, 0), ' ', '0') FROM PICUadmissions
WHERE Admit_Date>'2005-06-01' and Admit_Date<'2005-07-01'" queryout
"I:\sttr\STTRLabsIn.txt" -c -T
go
The Error: "incorrect syntax near queryout"
Thanks reading my message.
Chieko
"Dan Guzman" wrote:

> Since your BCP source is a query rather than a table/view, you need to
> specify 'queryout' instead of 'out'.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "chieko" <chieko@.discussions.microsoft.com> wrote in message
> news:A82B768C-9367-447E-81DE-8EBFFAFBD62C@.microsoft.com...
>
>BCP is a command-prompt utility, not a Transact-SQL statement. You need to
run the command from a Windows command line rather than Query Analyzer.
Hope this helps.
Dan Guzman
SQL Server MVP
"chieko" <chieko@.discussions.microsoft.com> wrote in message
news:1CADD6C5-9A7A-4CD7-BFC4-6FC2366756F9@.microsoft.com...
>I just checked the message today. I have tried the queryout method but
> without any success because I keep getting a syntax error.
>
> My Code:
> bcp "Select Replace(Str(UNITNUM, 12, 0), ' ', '0') FROM PICUadmissions
> WHERE Admit_Date>'2005-06-01' and Admit_Date<'2005-07-01'" queryout
> "I:\sttr\STTRLabsIn.txt" -c -T
> go
> The Error: "incorrect syntax near queryout"
> Thanks reading my message.
> Chieko
> "Dan Guzman" wrote:
>|||Thanks,
"Dan Guzman" wrote:

> BCP is a command-prompt utility, not a Transact-SQL statement. You need t
o
> run the command from a Windows command line rather than Query Analyzer.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "chieko" <chieko@.discussions.microsoft.com> wrote in message
> news:1CADD6C5-9A7A-4CD7-BFC4-6FC2366756F9@.microsoft.com...
>
>

No comments:

Post a Comment