Solved

Incorrect syntax near 'outdated'.

Posted on 2004-09-13
9
535 Views
Last Modified: 2008-01-09
I am using a BCP to write out information.  The problem I am having is that when I go to write out the information I get the error  
 Incorrect syntax near 'outdated'.

I know I have my sytax wrong, can someone tell me were?

thanks


 Set @script = 'BCP "SELECT distinct docsdb.dbo.vtab0010.val, docsdb.dbo.vtab0010.modified FROM docsdb.dbo.vtab0010, docsdb.dbo.temp where docsdb.dbo.vtab0010.val = docsdb.dbo.temp.val and  docsdb.dbo.temp.pdate <  docsdb.dbo.vtab0010.modified and  docsdb.dbo.temp.problem = 'outdated' "  queryout c:\' + @TabName + '.txt -U sa -P cfds -S -c'
0
Comment
Question by:running32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 12045981
do you need the single quote in front of BCP?
0
 
LVL 18

Expert Comment

by:ShogunWade
ID: 12045988
you need to double up the quotes

ie:

instead of 'outdated'
put ''outdated''     (two single quotes each side)
0
 

Author Comment

by:running32
ID: 12046066
Yes, I need the single quote

and

No, the double quotes do not work when you put them around the word outdated.  When I do that I get:

usage: BCP {dbtable | query} {in | out | queryout | format} datafile
  [-m maxerrors]            [-f formatfile]          [-e errfile]
  [-F firstrow]             [-L lastrow]             [-b batchsize]
  [-n native type]          [-c character type]      [-w wide character type]
  [-N keep non-text native] [-V file format version] [-q quoted identifier]
  [-C code page specifier]  [-t field terminator]    [-r row terminator]
  [-i inputfile]            [-o outfile]             [-a packetsize]
  [-S server name]          [-U username]            [-P password]

I'm not sure why it will not work it works when run just as a select statment.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:ShogunWade
ID: 12046132
" double quotes "    no dont use double quotes  i said 2 or these  '  together
0
 
LVL 18

Expert Comment

by:ShogunWade
ID: 12046140
after the assignment do PRINT @sql

and post the string
0
 
LVL 18

Expert Comment

by:ShogunWade
ID: 12046163
ok i think i see now.   there are two problems, one was masking the other.

try this

 Set @script = 'BCP "SELECT distinct docsdb.dbo.vtab0010.val, docsdb.dbo.vtab0010.modified FROM docsdb.dbo.vtab0010, docsdb.dbo.temp where docsdb.dbo.vtab0010.val = docsdb.dbo.temp.val and  docsdb.dbo.temp.pdate <  docsdb.dbo.vtab0010.modified and  docsdb.dbo.temp.problem = ''outdated'' "  queryout "c:\' + @TabName + '.txt" -U sa -P cfds -S -c'
0
 
LVL 6

Accepted Solution

by:
mcp111 earned 500 total points
ID: 12046457
Try this. You cannot use double quotes when embedding a string.

Set @script = 'BCP ''SELECT distinct docsdb.dbo.vtab0010.val, docsdb.dbo.vtab0010.modified FROM docsdb.dbo.vtab0010, docsdb.dbo.temp where docsdb.dbo.vtab0010.val = docsdb.dbo.temp.val and  docsdb.dbo.temp.pdate <  docsdb.dbo.vtab0010.modified and  docsdb.dbo.temp.problem = ''outdated''  queryout c:\' + @TabName + '.txt -U sa -P cfds -S -c'
0
 

Author Comment

by:running32
ID: 12046475
This is the output I receive when I use your example above.
with a print command

(556 row(s) affected)

BCP "SELECT distinct docsdb.dbo.vtab0010.val, docsdb.dbo.vtab0010.modified FROM docsdb.dbo.vtab0010, docsdb.dbo.temp where docsdb.dbo.vtab0010.val = docsdb.dbo.temp.val and  docsdb.dbo.temp.pdate <  docsdb.dbo.vtab0010.modified and  docsdb.dbo.temp.proble

0
 
LVL 7

Expert Comment

by:ChrisFretwell
ID: 12046550
Either your delcared length of @script is too short or you're only displaying the first 255 characters of the output.
If @script is more than 255 characters, then its just a setting in QA.

Go to tools , options, results and change Maximum characters per column to more than 255

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question