sybase-ase

How to simulate GREATEST() in Sybase ASE?

核能气质少年 提交于 2020-01-13 03:53:50
问题 Most databases have something like a GREATEST function, which can be useful some times. At least these databases don't have such a function: Derby SQL Server Sybase ASE Sybase SQL Anywhere For SQL Server and Sybase SQL Anywhere, the function can be simulated using subqueries and UNION ALL , as can be seen in this question here. An example: -- SELECT GREATEST(field1, field2, field3) FROM my_table SELECT (SELECT MAX(c) FROM (SELECT my_table.field1 AS c UNION ALL SELECT my_table.field2 UNION ALL

How to simulate GREATEST() in Sybase ASE?

爷,独闯天下 提交于 2020-01-13 03:53:42
问题 Most databases have something like a GREATEST function, which can be useful some times. At least these databases don't have such a function: Derby SQL Server Sybase ASE Sybase SQL Anywhere For SQL Server and Sybase SQL Anywhere, the function can be simulated using subqueries and UNION ALL , as can be seen in this question here. An example: -- SELECT GREATEST(field1, field2, field3) FROM my_table SELECT (SELECT MAX(c) FROM (SELECT my_table.field1 AS c UNION ALL SELECT my_table.field2 UNION ALL

SQL query to get primary keys for all tables in sybase ase 15.x along with column names

[亡魂溺海] 提交于 2020-01-06 23:43:07
问题 I'm using Sybase ASE 15.5 and a stranger to this database. Straight to the point--> I'm looking for a sql query that would help me get the primary keys for all tables in sybase along with the column names on which the primary key is declared. For example, if I have the following tables, organization having primary key PK_org_id on the column org_id org_alias having primary key PK_alias_id on the column alias_id org_temp having primary key PK_org_temp_id on the columns (org_id,org_name) then

Alternative to SQL window functions in Sybase

纵然是瞬间 提交于 2020-01-05 09:09:20
问题 I am working on Sybase Adaptive Server Enterprise (version 12.5.0.3). Trying to use Row_number() OVER (Partition by columnname order by columnname) . When I execute the query it is throwing an exception saying that the syntax near OVER is incorrect. I have searched for proper row_number() syntax for sybase database, but there is nothing wrong in the syntax. I guess that the Sybase version that am using does not support row_number() OVER . I even tried dense_rank() OVER , but am getting the

which to use OLEDB or ODBC for SYbase

对着背影说爱祢 提交于 2020-01-04 02:34:07
问题 I am not able to figure out which drivers should I use. Even I don't know what I have. When I am trying to make the connection string through the .udl file it only shows SYbase ASE OleDB Provider while in install folder I can see in driver list Syabse Ase ODBC driver but in connection string it is unable to pick up the driver, here I used Driver = (Sybase ASE ODBC Driver) What should I go for? Thanks 回答1: Using udl you have only the possibility to generate a connection string that uses an

How to set date format in sybase?

只谈情不闲聊 提交于 2019-12-25 03:08:04
问题 How to set date format in sybase? Currently it's inserting default date format Jan 9 2014 1:07AM to Sybase DB,But i have to insert seconds also like "20140109 01:06:46" Is there any way i can set date format in stored proc. please suggest me,thanks! 回答1: select --cast( dateformat('Jan 9 2014 1:07AM','YYYYMMDD HH:NN:SS') --returns varchar --as datetime) --datetime object in database datetime format 来源: https://stackoverflow.com/questions/21013037/how-to-set-date-format-in-sybase

How to find triggers along with schemas defined on a table in Sybase ASE 16.0?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 19:53:14
问题 I am trying to find all the triggers defined on a table in a given schema in Sybase ASE 16.0, and the triggers can be defined in different schema than the given table (User has all required permissions). Example, below table will be created in dbo schema (default) and the triggers in dbo and s1 schema respectively. CREATE TABLE tblAllTypesTriggers ( "Id" int NOT NULL primary key, "Name" varchar(30), "Salary" int, "Gender" varchar(10), "DepartmentId" int ) LOCK ALLPAGES / CREATE TRIGGER

How to get part of the column value in sybase where this column situated in a query which is inside other query?

戏子无情 提交于 2019-12-24 17:56:01
问题 I have a column named Cons in a table named Conses as Order::Resource(PPP32#BB300320LQ00J#AAAR05504) I have second table which depends on first table. i wants to get all data from the seconds table and i did it manually as below and result is ok select * from so_db..item where id =('PPP32' ) and sub_id =('BB300320LQ00J') and tem_id =('AAAR05504'); but i want to replace inside the parentheses with an other query which must get one part of the column mentioned above as follow: id = first part

Select TOP 1 * from Table Fails in Sybase Procedure

大兔子大兔子 提交于 2019-12-23 12:33:40
问题 Am trying to Fetch Only one record from the Sybase Table without using the RowCount Function, even though "WHERE Condition" returns multiple results. SELECT TOP 1 EMPLOYEE_NAME FROM EMPLOYEES WHERE EMPLOYEEID > 50 Runs Successfully with one Record Only, However SELECT TOP 1 EMPLOYEE_NAME FROM EMPLOYEES WHERE EMPLOYEEID > 50 fails, when written inside a Sybase Procedure as a Sub Query 回答1: Top is supported only in outer query only, here is the link For ordered data I am using having cause