PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

brackets in a sql statement

 
 
jnewl
Guest
Posts: n/a
 
      7th May 2010
have a field name that is separated by a spacethat i need to reference in a
sql statement. i know i can put brackets around the field name, but the sql
statement also has brackets. how can i code? i have tried putting quotes,
extra brackets, parens around the field name but nothing works. here is the
sql statement


sqlSelect = "SELECT AllClaims.* FROM[SELECT Src.*,
Nz(P2P.ProductionCode,'MISSING CODE') AS ProdCode FROM cntrlD_ITP" &
strthisgrpid & " AS Src LEFT JOIN PendToProduction AS P2P ON Src.[Pend code]
= P2P.PendCode]. AS AllClaims LEFT JOIN tbl_Assignments AS Asgnd ON
AllClaims.[Claim Number] = Asgnd.[Claim Number] WHERE Asgnd.Assignee Is Null"
sqlOrderBy = " ORDER BY Age DESC"


thanks for your help
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      7th May 2010
On Fri, 7 May 2010 14:38:01 -0700, jnewl <(E-Mail Removed)>
wrote:

>have a field name that is separated by a spacethat i need to reference in a
>sql statement. i know i can put brackets around the field name, but the sql
>statement also has brackets. how can i code? i have tried putting quotes,
>extra brackets, parens around the field name but nothing works. here is the
>sql statement
>
>
>sqlSelect = "SELECT AllClaims.* FROM[SELECT Src.*,
>Nz(P2P.ProductionCode,'MISSING CODE') AS ProdCode FROM cntrlD_ITP" &
>strthisgrpid & " AS Src LEFT JOIN PendToProduction AS P2P ON Src.[Pend code]
>= P2P.PendCode]. AS AllClaims LEFT JOIN tbl_Assignments AS Asgnd ON
>AllClaims.[Claim Number] = Asgnd.[Claim Number] WHERE Asgnd.Assignee Is Null"
>sqlOrderBy = " ORDER BY Age DESC"
>
>
>thanks for your help


Unfortunately, you can't! A Subquery cannot have any square brackets in it.

Your best bet would be to save the subquery as a query in its own right,
aliasing the fieldnames.
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      8th May 2010
This may help:
http://allenbrowne.com/ser-71.html
http://www.fontstuff.com/access/acctut15.htm

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"jnewl" wrote:

> have a field name that is separated by a spacethat i need to reference in a
> sql statement. i know i can put brackets around the field name, but the sql
> statement also has brackets. how can i code? i have tried putting quotes,
> extra brackets, parens around the field name but nothing works. here is the
> sql statement
>
>
> sqlSelect = "SELECT AllClaims.* FROM[SELECT Src.*,
> Nz(P2P.ProductionCode,'MISSING CODE') AS ProdCode FROM cntrlD_ITP" &
> strthisgrpid & " AS Src LEFT JOIN PendToProduction AS P2P ON Src.[Pend code]
> = P2P.PendCode]. AS AllClaims LEFT JOIN tbl_Assignments AS Asgnd ON
> AllClaims.[Claim Number] = Asgnd.[Claim Number] WHERE Asgnd.Assignee Is Null"
> sqlOrderBy = " ORDER BY Age DESC"
>
>
> thanks for your help

 
Reply With Quote
 
David W. Fenton
Guest
Posts: n/a
 
      8th May 2010
John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:(E-Mail Removed):

> On Fri, 7 May 2010 14:38:01 -0700, jnewl
> <(E-Mail Removed)> wrote:
>
>>have a field name that is separated by a spacethat i need to
>>reference in a sql statement. i know i can put brackets around the
>>field name, but the sql statement also has brackets. how can i
>>code? i have tried putting quotes, extra brackets, parens around
>>the field name but nothing works. here is the sql statement
>>
>>
>>sqlSelect = "SELECT AllClaims.* FROM[SELECT Src.*,
>>Nz(P2P.ProductionCode,'MISSING CODE') AS ProdCode FROM cntrlD_ITP"
>>& strthisgrpid & " AS Src LEFT JOIN PendToProduction AS P2P ON
>>Src.[Pend code] = P2P.PendCode]. AS AllClaims LEFT JOIN
>>tbl_Assignments AS Asgnd ON AllClaims.[Claim Number] =
>>Asgnd.[Claim Number] WHERE Asgnd.Assignee Is Null" sqlOrderBy = "
>>ORDER BY Age DESC"

>
> Unfortunately, you can't! A Subquery cannot have any square
> brackets in it.
>
> Your best bet would be to save the subquery as a query in its own
> right, aliasing the fieldnames.


Also, get rid of the practice of using spaces and non-alphanumeric
characters in object names!

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Whst does these brackets mean in the sql statement Tony Johansson Microsoft C# .NET 2 26th Sep 2010 02:21 PM
Date Brackets as an IIf statement Gary Microsoft Access Queries 3 22nd Apr 2010 06:15 AM
Access confused by its own SQL brackets Dan Williams Microsoft Access Queries 2 8th Apr 2009 04:11 PM
run SQL statement from same SQL statement for searching =?Utf-8?B?TWlrZQ==?= Microsoft Access VBA Modules 4 15th Apr 2005 06:47 PM
Using Brackets in SQL =?Utf-8?B?RnJlZCBIZXJyaW5n?= Microsoft ADO .NET 5 15th Dec 2004 08:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:58 PM.