[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Incorrect syntax near 'outdated'.

Posted on 2004-09-13
9
Medium Priority
?
540 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
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

834 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