In the documentation about the LIKE operator, nothing is told about the case-sensitivity of it. Is it? How to enable/disable it? I am querying varchar(n) columns, on an Microsoft SQL Server 2005 installation, if that matters. Answer It is not the operator that is case sensitive, it is the column itself. When …
Regex remove all occurrences of multiple characters in a string
In my PostgreSQL I want to replace all characters (;) occurrences in a string. My query: update table_name set text = regexp_replace(text, ‘/[(;)]+/g’, ”); I think my regexp is …
Bulk load: An unexpected end of file was encountered in the data file
I am using SQL Server Express 2008 When I’m trying load data from txt file in to this table create table Clients ( ClientID int not null IDENTITY (9000,1), LastName varchar (30)not null, FirsName …
Does Postgresql plpgsql/sql support short circuiting in the where clause?
If I have the following toy query Would the first condition in the WHERE clause short circuit the second condition which would have a complex run time? I’m working on some sql that is actually part of a FOR LOOP in plpgsql, and I could do iterations over all records that exist in the my_other_tables, an…
MYSQL, How to combine the first 2 letters of the first name and the first 5 letters of the last name
I’m trying to write an SQL query (using the SELECT function) that will take the first two letters of the first name and the first 5 letters of the last name, then combine them and put them in a new column called “User Name.” I’ve tried using the SUBSTRING and CONCAT functions together,…
How to SUM two fields within an SQL query
I need to get the total of two fields which are within the same row and input that number in a field at the end of that same row. This is my code. Is this what the SUM function is used for, or can you only use the SUM function for getting the total of a column? Thanks Answer SUM
Text to List in SQL
Is there any way on how to convert a comma separated text value to a list so that I can use it with ‘IN’ in SQL? I used PostgreSQL for this one. Ex.: This query: produces ‘SG’,’PH’ I wanted to produce this query: Nothing returned when I executed the first query. The table h…
Query using min() not showing the correct result
I have this table: CREATE TABLE IF NOT EXISTS `Vars` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `code` varchar(15) NOT NULL, `userID` bigint(20) NOT NULL, `viewedT` bigint(20) NOT NULL, …
Parent – child sql query with in a single table
I’ve a table: Id | Name | ParentID I want to select records whose parentid not equal to zero, with parent record(parent record have parentid = 0, but some parent record don’t have child record I …
How can I find the dependencies of a multiple objects in sql databases?
sp_depends will provide information for all dependent objects on a particular objects But it is working for only single object , giving information about single object. I want the information about multiple object, How can I achieve it using sp_depend or any other way is there? Answer You want sys.sql_express…