I need to generate a report where the user can choose All Issues, Open Issues, or Closed issues in a radio button. In my view I have a isClosed bit column. If I didn’t have the All Issues radio box I’…
Tag: sql
How to Set Customer Table with Multiple Phone Numbers? – Relational Database Design
A customer can have multiple phone numbers e.g. Cell, Work, etc. phoneID in Customer table is unique and points to PhoneID in Phone table. If customer record is deleted, phoneID in Phone table should also be deleted. Do you have any concerns on my design? Is this designed properly? My problem is phoneID in Cu…
Unable to drop constraint in SQL server 2005, “Could not drop constraint. See previous errors”
I’m trying to drop a constraint on a DB table, something like: But the execution just runs and runs. If I stop it I see: Web search throws up various pages but note that the constraint is properly named and I am trying to remove it using the correct name Answer Found a way to sort this, although I don&#…
Run all SQL files in a directory
I have a number of .sql files which I have to run in order to apply changes made by other developers on an SQL Server 2005 database. The files are named according to the following pattern: Is there a way to run all of them in one go? Answer Create a .BAT file with the following command: If you need
MySQL: Order by field size/length
Here is a table structure (e.g. test): Field Name Data Type id BIGINT (20) title varchar(25) Description Text A query like: But I would like to order by the field size/length of the field description. The field type will be TEXT or BLOB. Answer The LENGTH function gives the length of string in bytes. If you w…
How to log SQL statements in Grails
I want to log in the console or in a file, all the queries that Grails does, to check performance. I had configured this without success. Any idea would help.
What does the specified number mean in a VARCHAR() clause?
Just to clarify, by specifying something like VARCHAR(45) means it can take up to max 45 characters? I remember I heard from someone a few years ago that the number in the parenthesis doesn’t refer to …
How to search multiple columns in MySQL?
I’m trying to make a search feature that will search multiple columns to find a keyword based match. This query: works only for searching one column, I noticed separating column names with commas results in an error. So is it possible to search multiple columns in mysql? Answer You can use the AND or OR…
Python: Number of rows affected by cursor.execute(“SELECT …)
How can I access the number of rows affected by: Answer Try using fetchone: result will hold a tuple with one element, the value of COUNT(*). So to find the number of rows: Or, if you’d rather do it in one fell swoop: PS. It’s also good practice to use parametrized arguments whenever possible, bec…
How to troubleshoot ORA-02049 and lock problems in general with Oracle
I am getting ORA-02049 occasionally for some long-running and/or intensive transactions. There is seemingly no pattern to this, but it happens on a simple INSERT. I have no clue how to get any sort …