Contains condition over clob in sybase db - sql

Can someone help me with the syntax of CONTAINS in Sybase, I have tried below two, and both didn't work :
Query1:
select * from test where column_1 CONTAINS('Set');
Exception:
[Code: 102, SQL State: 37000] Incorrect syntax near 'CONTAINS'.
Query2:
select * from test where CONTAINS(column_1, 'Set');
Exception:
[Code: 102, SQL State: 37000] Incorrect syntax near ')'.
Please help

you have to remove where from your statement and that will be like below
select * from test CONTAINS(column_1, 'Set');
more about contains in sybase read documentation

Related

How do I do select into from another table

Basically I want to run a SQL statement like this, but I can't due to errors.
Not sure why?
INSERT INTO allevent (eventname)
VALUES (select username from registered)
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.
No need of parentheses around the SELECT statement in your query.
INSERT INTO allevent (eventname)
SELECT username FROM registered
Parentheses with VALUES required, where some places like below:
INSERT INTO tablename (fieldname)
VALUES ('field 01'), ('field 02');
Please find the syntax for the INSERT statement.

Create a table with SQL from Query result in SSMS

I am trying to create a new table from a query result in SSMS
I have tried:
CREATE TABLE table2 AS
(SELECT * FROM table1
WHERE code = 'x'
ORDER BY code;)
However I am getting an error telling me:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'AS'.
Msg 156, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'ORDER'.
Can anyone help?
Try this:
SELECT *
INTO NEW_TABLE
FROM table1
WHERE code = 'x'
ORDER BY code;

SQL Error: 904, SQLState: 42000 ORA-00904: : invalid identifier

Can below scenario of duplicate alias lead to an error when executed from JDBC or hibernate:
SQL Error: 904, SQLState: 42000 ORA-00904: : invalid identifier
select * From table_master VW
LEFT OUTER JOIN TABLE(test_func(1, 300)) vw
ON VW.table_key = vw.function_key
Facing this in production only. It works fine in test environment.
In my case the DB field didn't exist, and it was returning
SQL Error: 904, SQLState: 42000 ORA-00904: : invalid identifier
After Creating the field, of course it worked,
Double check those fields and make sure they are matching...
Hope it may give you a clue to find the issue
In my case I missed #ManyToOne(fetch = FetchType.EAGER) on that #JoinColumn
Verify that the user with which you are executing the query has the necessary grants for the test_func() function.

sql Error in derby - ERROR 42X01: Syntax error: Encountered "KEY"

following query gives error like ERROR 42X01: Syntax error: Encountered "KEY" at line 1, column 48.
I am not able to understand what is the exact issue. column KEY is exist and datatype is integer.
Insert into UOM_TYPE
(UNITS_OF_MEASURE_NO,TYPE,KEY,CREATED_BY,CREATED_DATE,MODIFIED_BY,MODIFIED_DATE,VERSION)
values
(79,'Clinical Property',32,'JRL',DATE('2007-05-04'),'JRL',DATE('2007-05-04'),2);
Please help me to resolve the issue
KEY is a Keyword in derby db. you have to escape it :
Insert into UOM_TYPE
(UNITS_OF_MEASURE_NO,TYPE,"KEY",CREATED_BY,CREATED_DATE,MODIFIED_BY,MODIFIED_DATE,VERSION)
values
(79,'Clinical Property',32,'JRL',DATE('2007-05-04'),'JRL',DATE('2007-05-04'),2);

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ',' trying to INSERT INTO

i've succesfully created db and tables, but when i try populate one of a table, like this
INSERT INTO Products(IsProductActive,ProductName,ProductCount)
VALUES(0,'productName1',0),
(0,'productName2',0),
(1,'productName3',9),
(1,'productName4',7),
(1,'productName5',3),
(1,'productName6',10),
(0,'productName7',0),
(1,'productName8',6),
(1,'productName9',12),
(1,'productName10',20);
GO
i got an error:
Msg 102, Level 15, State 1,
Line 2 Incorrect syntax near ','.
firstly which ',' is meant, secondly - what is wrong?
PS: i use MS Management Studio v 9.0 if it is needed...
Versions of SQL Server 2005 and below do not support the multiple VALUE clause syntax
SQL Server 2005 is version 9...
See How do I insert multiple rows WITHOUT repeating the "INSERT INTO dbo.Blah" part of the statement? for more
if you are using SQL SERVER 2005 and below, the query wouldn't work because it doesn't support multiple value clause insert statement. You should insert it one by one.
Like this one below,
INSERT INTO Products(IsProductActive,ProductName,ProductCount)
VALUES(0,'productName1',0)
GO
INSERT INTO Products(IsProductActive,ProductName,ProductCount)
VALUES(0,'productName2',0)
GO