[dba-SQLServer] SQL in SP failing

Mark A Matte markamatte at hotmail.com
Thu Nov 30 13:45:39 CST 2006


The real mystery is that it ran the first few times after I created it.  
When it started failing I would change things, save, run, fail,change things 
back,save, and it would run correctly.

Like just now...I got it to run...here is the actual sql:

set @sql='insert into tblBrita_ID(case_id,Criteria) SELECT case_id, 
"'+ at ID+'" As Criteria FROM tblCase where creation_date > "1/1/2006" and'  + 
@ID

And this was what I started with that would NOT run...and what I finished 
with that did run(SAME CODE).  To clarify...The @ID is actually criteria 
used to isolate records.  I need to know what criteria picked a 
record...that is why I save it in the new table.

I got it to run...but am very confused as to why it does...sometimes?

Any and all feedback is appreciated.

Thanks,

Mark A. Matte


>From: "Elam, Debbie" <DElam at jenkens.com>
>Reply-To: dba-sqlserver at databaseadvisors.com
>To: "'dba-sqlserver at databaseadvisors.com'" 
><dba-sqlserver at databaseadvisors.com>
>Subject: Re: [dba-SQLServer] SQL in SP failing
>Date: Thu, 30 Nov 2006 13:34:58 -0600
>
>Hmm, I can get just the select statement to work correctly with single
>quotes.  Does the select work OK?  When I try to just run the select
>statement with double quotes, I get that test is an invalid column, so that
>sounds like the problem.
>
>Debbie
>
>-----Original Message-----
>From: Mark A Matte [mailto:markamatte at hotmail.com]
>Sent: Thursday, November 30, 2006 1:26 PM
>To: dba-sqlserver at databaseadvisors.com
>Subject: Re: [dba-SQLServer] SQL in SP failing
>
>
>If I use single quotes...SQL says it is a syntax error before I even run
>it...won't even let me save it that way.
>
>Thanks,
>
>Mark A. Matte
>
>
> >From: "Elam, Debbie" <DElam at jenkens.com>
> >Reply-To: dba-sqlserver at databaseadvisors.com
> >To: "'dba-sqlserver at databaseadvisors.com'"
> ><dba-sqlserver at databaseadvisors.com>
> >Subject: Re: [dba-SQLServer] SQL in SP failing
> >Date: Thu, 30 Nov 2006 13:23:00 -0600
> >
> >Use single quotes around test.  Double quotes will cause problems.
> >
> >Debbie
> >
> >-----Original Message-----
> >From: Mark A Matte [mailto:markamatte at hotmail.com]
> >Sent: Thursday, November 30, 2006 1:14 PM
> >To: dba-sqlserver at databaseadvisors.com
> >Subject: [dba-SQLServer] SQL in SP failing
> >
> >
> >Hello All,
> >
> >Any idea why the following SQL will fail in an SP?
> >
> >'insert into tblBrita_ID(case_id,Criteria) SELECT case_id, "test" As
> >Criteria FROM tblCase where case_id=1'
> >
> >The error is "Invalid column name 'test'."  It doesn't always
> >fail...normally 'test' is a parameter passed to the SP...I have modified 
>it
> >to the above for demo purposes...but using just the word 'test' as above
> >still gives the same error.
> >
> >Thanks,
> >
> >Mark A. Matte
> >
> >_________________________________________________________________
> >Get the latest Windows Live Messenger 8.1 Beta version. Join now.
> >http://ideas.live.com
> >
> >- JENKENS & GILCHRIST E-MAIL NOTICE - This transmission may be: (1) 
>subject
> >to the Attorney-Client Privilege, (2) an attorney work product, or (3)
> >strictly confidential. If you are not the intended recipient of this
> >message, you may not disclose, print, copy or disseminate this 
>information.
> >If you have received this in error, please reply and notify the sender
> >(only) and delete the message. Unauthorized interception of this e-mail 
>is
> >a
> >violation of federal criminal law.
> >This communication does not reflect an intention by the sender or the
> >sender's client or principal to conduct a transaction or make any 
>agreement
> >by electronic means.  Nothing contained in this message or in any
> >attachment
> >shall satisfy the requirements for a writing, and nothing contained 
>herein
> >shall constitute a contract or electronic signature under the Electronic
> >Signatures in Global and National Commerce Act, any version of the 
>Uniform
> >Electronic Transactions Act or any other statute governing electronic
> >transactions.
> >_______________________________________________
> >dba-SQLServer mailing list
> >dba-SQLServer at databaseadvisors.com
> >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> >http://www.databaseadvisors.com
> >
>
>_________________________________________________________________
>Stay up-to-date with your friends through the Windows Live Spaces friends
>list.
>http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spa
>ces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mk
>
>- JENKENS & GILCHRIST E-MAIL NOTICE - This transmission may be: (1) subject
>to the Attorney-Client Privilege, (2) an attorney work product, or (3)
>strictly confidential. If you are not the intended recipient of this
>message, you may not disclose, print, copy or disseminate this information.
>If you have received this in error, please reply and notify the sender
>(only) and delete the message. Unauthorized interception of this e-mail is 
>a
>violation of federal criminal law.
>This communication does not reflect an intention by the sender or the
>sender's client or principal to conduct a transaction or make any agreement
>by electronic means.  Nothing contained in this message or in any 
>attachment
>shall satisfy the requirements for a writing, and nothing contained herein
>shall constitute a contract or electronic signature under the Electronic
>Signatures in Global and National Commerce Act, any version of the Uniform
>Electronic Transactions Act or any other statute governing electronic
>transactions.
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>

_________________________________________________________________
Stay up-to-date with your friends through the Windows Live Spaces friends 
list. 
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mk




More information about the dba-SQLServer mailing list