Is there a property that I can add to a column so that it converts its value to lowercase? Instead of doing it for every single value through PHP? Answer You could probably do it through a trigger that fires on insert or update. Myself, I’d rather just create a view that has a lower-case version of the column in
sql query: list every song belonging to a particular artist, even though there is no direct foreign key reference between them
I have 4 tables artist (artistID, …) album (albumID, artistID, …) song (songID, …) albumsongs (songID, albumID) and the table that joins the many to many between album and songs – albumsongs …
For VAT tax, what is the correct Decimal(p, s) precision and scale for SQL Server field size declaration?
I am defining VAT rates (European and other countries levy the VAT tax) in a SQL Server database and am wondering what the ideal decimal definition to capture the necessary precision. I have seen VAT rates of: I am curious if there are cases where the VAT rate requires more precision than decimal(4, 3) where p is precision and s
MySQL OPTIMIZE all tables?
MySQL has an OPTIMIZE TABLE command which can be used to reclaim unused space in a MySQL install. Is there a way (built-in command or common stored procedure) to run this optimization for every table in the database and/or server install, or is this something you’d have to script up yourself? Answer You can use mysqlcheck to do this at
SQL – Get Numerical Day of Month/Quarter
Using SQL Server 2005: How can I get the numerical day of the month and day of the quarter in a query? DECLARE @DATE DATETIME SET @DATE = GETDATE() SELECT DATEPART(dy, @DATE) AS DayOfYear –, &…
Why can’t I simply add an index that includes all columns?
I have a table in SQL Server database which I want to be able to search and retrieve data from as fast as possible. I don’t care about how long time it takes to insert into the table, I am only …
SQL query for today’s date minus two months
I want to select all the records in a table where their date of entry is older then 2 months. Any idea how I can do that? I haven’t tried anything yet but I am on this point: Answer If you are using SQL Server try this: Based on your update it would be:
How to insert a timestamp in Oracle?
I have an Oracle DB with a timestamp field in it. What is the correct SQL code to insert a timestamp into this field?
passing parameters to a stored procedure in C#
How can i send three parameters a to stored procedure in sql? Here is my error: Procedure or function GetIslemIdleri has too many arguments specified. This is my stored procedure: CREATE PROCEDURE …
SQL grouping by month and year
I’m not sure what should I write in the following SQL query to show ‘date’ column like this: “month-year” – “9-2011”. So, what I want to do is to change the data from the first column to show month and year instead of showing month only. Answer Or as @40-Love mentioned you can cast with leading zeroes: