What is the equivalent of: …in SQL Server 2005? Answer Recommended: This is another alternative, but it’s risky because of casting to a FLOAT. It’s also been demonstrated to not scale performance as well as the DATEADD/DATEDIFF approach.
Tag: oracle
Insert if not exists Oracle
I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: Is this at all possible with Oracle? Bonus points if you can tell me how to do this in PostgreSQL
Why use a JOIN clause versus a WHERE condition?
I develop against Oracle databases. When I need to manually write (not use an ORM like hibernate), I use a WHERE condition instead of a JOIN. for example (this is simplistic just to illustrate the style): I learned this style from an OLD oracle DBA. I have since learned that this is not standard SQL syntax. O…
How can I select records ONLY from yesterday?
I’ve spent hours searching the web for an answer to this question… Here’s what I currently have: select * from order_header oh where tran_date = sysdate-1
SELECT SUM as field
Suppose i have this table table (a,b,c,d). Datatypes are not important. I want to do this select a as a1,b as b1,c as c1, (select sum(d) from table where a=a1 and b=b1) as total from table …
Oracle SQL escape character (for a ‘&’)
While attempting to execute SQL insert statements using Oracle SQL Developer I keep generating an “Enter substitution value” prompt: I’ve tried escaping the special character in the query using the ” above but I still can’t avoid the ampersand, ‘&’, causing a stri…
Deferrable Constraints in SQL Server
Do any versions of SQL Server support deferrable constraints (DC)? Since about version 8.0, Oracle has supported deferrable constraints – constraints that are only evaluated when you commit a …
What SQL would I need to use to list all the stored procedures on an Oracle database?
What SQL would I need to use to list all the stored procedures on an Oracle database? If possible I’d like two queries: list all stored procedures by name list the code of a stored procedure, given …
How to execute an .SQL script file using c#
I’m sure this question has been answered already, however I was unable to find an answer using the search tool. Using c# I’d like to run a .sql file. The sql file contains multiple sql statements, some of which are broken over multiple lines. I tried reading in the file and tried executing the fil…
How do I spool to a CSV formatted file using SQLPLUS?
I want to extract some queries to a CSV output format. Unfortunately, I can’t use any fancy SQL client or any language to do it. I must use SQLPLUS. How do I do it?