Wednesday, February 15, 2012

error S0022 while deleting

Hi,
I have this query to delete a company and it goes like
this:
<cfquery ......>
delete from companies
where companyname = '#url.object#'
</cfquery>
I end up getting the error code S0022 column not found
and it goes on to say
Invalid column name 'companyname'.
I went to SQL server and typed in a query:
delete from companies
where companyname = 'somecompany'
it still gave me the same error.
I used to have companyname as the PK but now it's
companyid.
so i tried using companyid in the where clause and it
still gave me the same error even
in sql server. Usually this error has to do with quotes
but since i'm typing the query straight
into sql server and running it properly and it doesn't
work, it must be something else.
Please advise.
Thanks,
PremSQL Server doesn't have errors like S0022. What do you mean that you went to
SQL Server? Do you mean to the SQL Server machine? Or do you mean Query
Analyzer, which is a client tool for communicating with SQL Server? Can you
please post the exact error message that you copy and paste from Query
Analyzer.
If you meant 50022, then it is a user defined error, and my guess would be
that there is delete trigger on the table.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"premzero" <premzero@.hotmail.com> wrote in message
news:031301c39126$aad38700$a401280a@.phx.gbl...
> Hi,
> I have this query to delete a company and it goes like
> this:
> <cfquery ......>
> delete from companies
> where companyname = '#url.object#'
> </cfquery>
> I end up getting the error code S0022 column not found
> and it goes on to say
> Invalid column name 'companyname'.
> I went to SQL server and typed in a query:
> delete from companies
> where companyname = 'somecompany'
> it still gave me the same error.
> I used to have companyname as the PK but now it's
> companyid.
> so i tried using companyid in the where clause and it
> still gave me the same error even
> in sql server. Usually this error has to do with quotes
> but since i'm typing the query straight
> into sql server and running it properly and it doesn't
> work, it must be something else.
> Please advise.
> Thanks,
> Prem
>|||When I run it on the SQL Server machine it simply gives
me the message:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid
column name 'companyname'.
When I run it on SQL query analyser it says:
Server: Msg 207, Level 16, State 3, Procedure
trigger_delete_companyname, Line 6
Invalid column name 'companyname'.
So it must be the trigger as mentioned above. I'm not too
familiar with SQL server. Where are the triggers
accessible from? I'm looking under stored procedures in
sql enterprise manager and can't see it under there.
>--Original Message--
>SQL Server doesn't have errors like S0022. What do you
mean that you went to
>SQL Server? Do you mean to the SQL Server machine? Or do
you mean Query
>Analyzer, which is a client tool for communicating with
SQL Server? Can you
>please post the exact error message that you copy and
paste from Query
>Analyzer.
>If you meant 50022, then it is a user defined error, and
my guess would be
>that there is delete trigger on the table.
>--
>HTH
>--
>Kalen Delaney
>SQL Server MVP
>www.SolidQualityLearning.com
>
>"premzero" <premzero@.hotmail.com> wrote in message
>news:031301c39126$aad38700$a401280a@.phx.gbl...
>> Hi,
>> I have this query to delete a company and it goes like
>> this:
>> <cfquery ......>
>> delete from companies
>> where companyname = '#url.object#'
>> </cfquery>
>> I end up getting the error code S0022 column not found
>> and it goes on to say
>> Invalid column name 'companyname'.
>> I went to SQL server and typed in a query:
>> delete from companies
>> where companyname = 'somecompany'
>> it still gave me the same error.
>> I used to have companyname as the PK but now it's
>> companyid.
>> so i tried using companyid in the where clause and it
>> still gave me the same error even
>> in sql server. Usually this error has to do with quotes
>> but since i'm typing the query straight
>> into sql server and running it properly and it doesn't
>> work, it must be something else.
>> Please advise.
>> Thanks,
>> Prem
>
>.
>|||Ok I figured it out. Just right click a table and manage
triggers. I've changed it and it works fine now.
thanks alot!
>--Original Message--
>SQL Server doesn't have errors like S0022. What do you
mean that you went to
>SQL Server? Do you mean to the SQL Server machine? Or do
you mean Query
>Analyzer, which is a client tool for communicating with
SQL Server? Can you
>please post the exact error message that you copy and
paste from Query
>Analyzer.
>If you meant 50022, then it is a user defined error, and
my guess would be
>that there is delete trigger on the table.
>--
>HTH
>--
>Kalen Delaney
>SQL Server MVP
>www.SolidQualityLearning.com
>
>"premzero" <premzero@.hotmail.com> wrote in message
>news:031301c39126$aad38700$a401280a@.phx.gbl...
>> Hi,
>> I have this query to delete a company and it goes like
>> this:
>> <cfquery ......>
>> delete from companies
>> where companyname = '#url.object#'
>> </cfquery>
>> I end up getting the error code S0022 column not found
>> and it goes on to say
>> Invalid column name 'companyname'.
>> I went to SQL server and typed in a query:
>> delete from companies
>> where companyname = 'somecompany'
>> it still gave me the same error.
>> I used to have companyname as the PK but now it's
>> companyid.
>> so i tried using companyid in the where clause and it
>> still gave me the same error even
>> in sql server. Usually this error has to do with quotes
>> but since i'm typing the query straight
>> into sql server and running it properly and it doesn't
>> work, it must be something else.
>> Please advise.
>> Thanks,
>> Prem
>
>.
>

No comments:

Post a Comment