Solved

Incorrect syntax near 'outdated'.

Posted on 2004-09-13
9
534 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

734 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