Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

SQL server 2008 error

by l.frankline (Hermit)
on Aug 13, 2012 at 12:46 UTC ( #987106=perlquestion: print w/replies, xml ) Need Help??
l.frankline has asked for the wisdom of the Perl Monks concerning the following question:


In the SQL server 2008 database, I have a table named 'article_link' and it has a column name 'external'. Since the 'external' column is a predefined keyword in SQL server 2008, it is throwing error as below while connecting the database through perl script :

DBD::ODBC::db do failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the
keyword 'external'. (SQL-42000) [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be
prepared. (SQL-42000)(DBD: st_execute/SQLExecute err=-1)

There is a module named where the code has the table column details as below :

use Class::MethodMaker [ scalar => [qw/ id article_id link url external active rank /], new => 'new', ];

I have tried to change the 'external' keyword to [external], but it does not work.

Can you help me please, there is a problem with the Class::MethodMaker module syntax.

Thanks in advance

Don't put off till tomorrow, what you can do today.

Replies are listed 'Best First'.
Re: SQL server 2008 error
by Corion (Pope) on Aug 13, 2012 at 13:05 UTC

    Most likely, MS SQL Server does not like a column named external. You will need to find how to quote column names for MS SQL server. I suggest using a MS SQL console client to find the proper SQL to use.

    The easy approach would be to rename the column in your database and in your code to something that is not an MS SQL keyword.

Re: SQL server 2008 error
by Old_Gray_Bear (Bishop) on Aug 13, 2012 at 15:04 UTC
    Your error message tells you what the problem is: "Incorrect syntax near the keyword 'external' ". Change the name of your column to something that isn't a SQLServer keyword, 'external_link', perhaps.

    I Go Back to Sleep, Now.


Re: SQL server 2008 error
by Anonymous Monk on Aug 13, 2012 at 12:53 UTC

    Can you help me please, there is a problem with the Class::MethodMaker module syntax.

    What does MethodMaker have to do with SQL?

Re: SQL server 2008 error
by tobyink (Abbot) on Aug 13, 2012 at 15:24 UTC

    That is not the line where your problem lies. Perhaps not even the right file.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://987106]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2018-08-20 22:36 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (196 votes). Check out past polls.