I have an SQLite database that I need to do the following: Keep only last N records, sorted by date. How do you do that? Answer To delete all but the latest 10 records.
‘LIKE (‘%this%’ OR ‘%that%’) and something=else’ not working
I have a select query where I am trying to search strings for multiple patterns Returns zero results However returns results and returns result Is it possible to get all my results into one query? If a string matches both, how will it handle that? Answer It would be nice if you could, but you can’t use …
Format() function doesn’t work?
I am trying to execute following built-in function in sql but it gives me error that this function doesn’t exist my query: Error i am getting: What may be the problem, or what am i doing wrong? Thanks! Answer Use Convert function instead. Example:
Casting datetime to varchar in scalar-valued function SQL Server 2005
I’m trying to get the following statement executed. The scalar-valued function is expecting a varchar for the date and the original column in customertable is a datetime. I’ve done my research and …
SQL Query ORDER BY column values
I have a column which can take any values from 0 to 100. Now i have a type TYPE1 which can take values 2, 4, 16 TYPE2 which can take values 8,12,64. Now i want to sort the column by TYPE1 values first and then TYPE2 values. Is there any way to do that. My column has only these values.
How to delete all duplicate records from SQL Table?
Hello I have table name FriendsData that contains duplicate records as shown below I want to remove duplicate combinations rows using MS SQL? Remove latest duplicate records from MS SQL FriendsData table. here I attached image which highlights duplicate column combinations. How I can removed all duplicate com…
How to DROP multiple columns with a single ALTER TABLE statement in SQL Server?
I would like to write a single SQL command to drop multiple columns from a single table in one ALTER TABLE statement. From MSDN’s ALTER TABLE documentation… Specifies that constraint_name or column_name is removed from the table. DROP COLUMN is not allowed if the compatibility level is 65 or earli…
How to select several hardcoded SQL rows?
If you execute this query SELECT ‘test-a1’ AS name1, ‘test-a2’ AS name2 the result will be a one row-selection with two columns having these values: test-a1, test-a2 How can I modify the above …
MySQL PRIMARY KEYs: UUID / GUID vs BIGINT (timestamp+random)
tl;dr: Is assigning rows IDs of {unixtimestamp}{randomdigits} (such as 1308022796123456) as a BIGINT a good idea if I don’t want to deal with UUIDs? Just wondering if anyone has some insight into …
Database Data Types and their equivelants in Windows Forms
I’ve read in forums about people having issues with certain data types when accessing a database from their website and windows forms application. Mostly the decimal, float and datetime data types. My DB Table, for example, the Orders table consists of the following Columns. Below each column is the dat…