Syntax error on executing a script in Sybase database - sql

I created a Sybase database emp_details using SQL Anywhere and Sybase Central. I had given emp/emp as dba username/password while creating.
The db got created and the files were generated in the given folder.
When I tried running the below script using Ineractive SQL:
use master
go
if exists (select 1 from master..sysdatabases where name='emp_details')
checkpoint emp_details
go
It threw the following exception
Could not execute statement.
Syntax error near 'checkpoint' on line 2
SQLCODE=-131, ODBC 3 State="42000"
Line 4, column 1
Haven't been able to figure out what exactly the syntax issue is and have been stuck up with this for a while.
Any ideas?

First of all, you may want to think about posting your SQL Anywhere questions to the http://sqlanywhere-forum.sap.com/ forum. It's a forum dedicated to the SQL Anywhere product line.
Is there any possibility that the two periods together might be causing your syntax issue?
Normally you're not going to get an exact area where the error is coming from. See if that helps. Also check out the other forum as well.

Related

Identical SQL query works on some tables but errors out on other tables same in the same DB

I'm a finance person (little programming background) so I maybe asking something obvious for database programming experts but will appreciate any advice
Background:
I'm accessing Oracle NetSuite database via ODBC from Microsoft SQL Management Studio
Connection as a Linked Server is established successfully
I'm trying to execute the following SQL statements:
select * from [NETSUITE_SB2].[SB-B].[Administrator].[VARIANCE] -- success
select * from [NETSUITE_SB2].[SB-B].[Administrator].[WTAX_JOB] -- "Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "NETSUITE_SB2" does not contain the table ""SB-B"."Administrator"."WTAX_JOB"". The table either does not exist or the current user does not have permissions on that table."
Upon some testing, it appears that whether the query is successfully run depends on whether the table name contains "_" (underscore) - for all tables without underscore I've tried, it worked, for all tables with underscore that I've tried, it failed.
Can anyone help me figure out how to overcome this?
Thanks in advance!
Instead of using a 4-part name in SQL Server and having SQL Server generate a query for the linked server, try using the OPENQUERY function and passing a query in the target system's SQL dialect directly. Something like:
select *
from OPENQUERY([NETSUITE_SB2], 'select * from [SB-B].[Administrator].[WTAX_JOB]' )
I just encountered this myself in a new instance that I just set up. I had been using Suite Connect for 4+ years without running into this issue before.
I believe the issue with the situation here is the "[SB-B]" part of the name because it contains the "-" dash. I found that a "," comma or "." period were the issue with my name [Acme, Inc.]. Ether the period or comma threw the error.
The second part of the 4-part name is the NetSuite [Company Name] under General Settings Company Info. I changed the name in NetSuite and removed the comma and period and the problem went away. Maybe most special characters cause the issue?
Just remember you'll have to update your second part name in each query you created before.
While using OPENQUERY is a solution, I just don't like the extra quotes needed so I prefer normal SQL.

#table in FROM clause

My manager (not currently working in an IT environment) sent me a chunk of code to run some data however one line confuses me. For some context, this is ORACLE SQL.
She has a line set as "FROM ma1 #proddb m1"
I'm not currently sure what it does or even trying to achieve. It's hard for me to visualize it since I do not have access to the database itself.
What's the proper syntax for that line as that's where I'm currently getting errors. Thank you!
What's the proper syntax for that line as that's where I'm currently getting errors.
# indicates a database link
The syntax is:
FROM table_name#dblink table_alias
So for you:
ma1 is the name of the table/view/materialized view.
proddb is the name of the database link.
m1 is the table alias.
The only thing that is wrong with your syntax is that you need to remove the space character between ma1 and #proddb. If you do that then it should work assuming that the database link and the remote table/view/materialized view exist.
"FROM ma1#proddb m1" -> ma1 is a table from a different DB, with #my_remote_DB you have access to objects on a remote database. In your case proddb is your remote database link.

Firebird select statement gives SQLSTATE = 42S02

I've made a very simple database and am trying
select * from klant;
I've verified the table exists, and last week was able to see data in it. Today however I keep getting
Statement failed, SQLSTATE = 42S02
Dynamic SQL Error
-SQL error code = -204
-Table unknown
-KLANT
-At line 1, column 15
The same select query in flameRobin gives the following error:
Error: *** IBPP::SQLException ***
Context: Database::Statistics
Message: isc_database_info failed
SQL Message : -902
can't format message 13:98 -- message file C:\WINDOWS\SYSTEM32\firebird.msg not found
Engine Code : 335544727
Engine Message :
Error writing data to the connection.
I have copied the firebird.msg to the system32 folder so it should be able to find it there.
Any pointers toward the solution would be greatly appreciated. Similar question all seem to point toward issues with transactions, I can't see that being the problem here.
Edit:
I'm using the included ISQL tool from firebird and start the session by connecting to the database that includes my table. Same for flamerobin, first connect to database, I can see the table that i want to select from but it gives this error.
Edit2:
Finally reinstalled Firebird making sure I gave it admin right, which I think it had before, but wasn't sure about. This seems to have fixed it.

Sql error on simple joins on table

Below is my simple select statement with join which gives me error
Query :
select a.*,r.* from answers a join respondents r on r.id = a.respondentid
Error:
Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ' '.
I've had strange issues like this when copying and pasting queries from MS OneNote into SSMS 2014. The solution was to copy the query into notepad or outlook first and then back into SSMS. I'm sure long term my issue can be resolved by looking at the page encoding for where I store my queries.
Not sure, but probably what you can try is, close the current session and open new session and type your query manually instead of copy and paste from somewhere (try to write clean and clear query). Since, same query I was able to run
SQL Fiddle Example
==Update==
Looking at your error, which is pointing at Line 2. It seems there is some extra blank character, which probably causing this error.

sp_notify_operator: The specified #operator_name does not exist (but it does!)

OK, so I think I'm going mad here! Here's where I am.
SQL Server 2008: I've set up Database Mail, and I've sent myself a test email. Simple, works fine.
I've created an operator, called 'Tom'. I've given it an email address (but nothing else).
However, when I run this command:
EXECUTE msdb.dbo.sp_notify_operator #name=N'Tom',#subject=N'Test Database Message',#body=N'Testy Test Test'
...I get this:
Msg 14262, Level 16, State 1, Procedure sp_verify_operator_identifiers, Line 51
The specified #operator_name ('Tom') does not exist.
Is that error message masking something else which I should be looking at? There's definately an operator shown in SSMS, but if there's a sproc which lists operators I'll happily run that to see if it's actually there.
I'm just kinda stuck as to where to go next. SQL Server seems convinced I don't exist!
Ignore this! There's a possibility that I was trying to execute sp_notify_operator whilst connected to the wrong server...the one without any operators....
Apologies!