cancel
Showing results for 
Search instead for 
Did you mean: 

How do I fix SQL SQLSTATE '52W09'?

3,762

I have a Quickbooks POS database which is a SAP SQL database. I am trying to use a odbc driver QODBC that is supposed to access the database but something is wrong with my database. A quickbooks provided database test connection utility log gives the following error:

Login procedure 'sp_login_environment' caused SQLSTATE '52W09' Procedure 'sp_login_environment' not found

I have contacted Quickbooks POS tech support but they say they cant help. Any ideas would be greatly appreciated.

Accepted Solutions (0)

Answers (1)

Answers (1)

Breck_Carter
Participant

(chances are, someone's futzed around inside your database, which may be the reason Quickbooks folks are taking a hands-off attitude... but really, they're the ones who created the database so they should support it.)

Since you are using ODBC, you probably don't need sp_login_environment at all; run this command in ISQL to disable it:

SET OPTION PUBLIC.login_procedure = NULL;

Alternatively...

This is the default login procedure setup for a new empty SQL Anywhere 17.0.9.4803 database (which AFAIK is the same for all earlier versions):

CREATE PROCEDURE "dbo"."sp_tsql_environment"()
begin
  if "db_property"('IQStore') = 'Off' then
    set temporary option "close_on_endtrans" = 'OFF'
  end if;
  set temporary option "ansinull" = 'OFF';
  set temporary option "tsql_variables" = 'ON';
  set temporary option "ansi_blanks" = 'ON';
  set temporary option "chained" = 'OFF';
  set temporary option "quoted_identifier" = 'OFF';
  set temporary option "allow_nulls_by_default" = 'OFF';
  set temporary option "on_tsql_error" = 'CONTINUE';
  set temporary option "isolation_level" = '1';
  set temporary option "date_format" = 'YYYY-MM-DD';
  set temporary option "timestamp_format" = 'YYYY-MM-DD HH:NN:SS.SSS';
  set temporary option "time_format" = 'HH:NN:SS.SSS';
  set temporary option "date_order" = 'MDY';
  set temporary option "escape_character" = 'OFF'
end;

CREATE PROCEDURE "dbo"."sp_login_environment"()
begin
  if "connection_property"('CommProtocol') = 'TDS' then
    call "dbo"."sp_tsql_environment"()
  end if
end;

SET OPTION PUBLIC.login_procedure='sp_login_environment';

You could try running all those commands in ISQL to see if they restore anything's that missing.

You could also try running this command to see if the "dbo." qualification helps:

SET OPTION PUBLIC.login_procedure='dbo.sp_login_environment';