I have triggers that manipulate and insert a lot of data into a Change tracking table for audit purposes on every insert, update and delete. This trigger does its job very well, by using it we are …
What is the equivalent of ‘go’ in MySQL?
In TSQL I can state: In MySQL I can’t write the same query. What is the correct way to write this query in MySQL? Answer Semicolon at the end of the statement.
What’s the fastest way to do a bulk insert into Postgres?
I need to programmatically insert tens of millions of records into a Postgres database. Presently, I’m executing thousands of insert statements in a single query. Is there a better way to do this, some bulk insert statement I do not know about? Answer PostgreSQL has a guide on how to best populate a database initially, and they suggest using the
MS Sql: Conditional ORDER BY ASC/DESC Question
I want to to make to make the ordering in my query conditional so if it satisfiess the condition it should be ordered by descending For instance: Answer Don’t change the ASC or DESC, change the sign of the thing being sorted-by: The OP asks: Guys, I am not the SQL Expert, please explain me what means the id and
Select a random sample of results from a query result
This question asks about getting a random(ish) sample of records on SQL Server and the answer was to use TABLESAMPLE. Is there an equivalent in Oracle 10? If there isn’t, is there a standard way to …
Are there multiline comment delimiters in SQL that are vendor-agnostic?
While editing, building up, or cherry picking from SQL statements I can find myself interacting with one of four popular database tools. I have been resorting to single line commenting for DB2 and Informix. I have created macros in Vim to make this slightly more efficient, but I was wondering if I am working too hard. Answer C style comments
Difference between CTE and SubQuery?
From this post How to use ROW_NUMBER in the following procedure? There are two versions of answers where one uses a sub-query and the other uses a CTE to solve the same problem. Now then, what is the advantage of using a CTE (Common Table Expression) over a ‘sub-query`(thus, more readable what the query is actually doing) The only advantage
How to combine date from one field with time from another field – MS SQL Server
In an extract I am dealing with, I have 2 datetime columns. One column stores the dates and another the times as shown. How can I query the table to combine these two fields into 1 column of type datetime? Dates Times Answer You can simply add the two. if the Time part of your Date column is always zero
Most efficient way to select 1st and last element, SQLite?
What is the most efficient way to select the first and last element only, from a column in SQLite?
Creating table names that are reserved words/keywords in MS SQL Server [closed]
Is it ok to name my database tables that are already keywords? For my case, I am trying to name the table that will hold my users. I’ve named it User but it is showing up as pink in SQL Server …