Say I have a table “products” and I would like to check if this table has any indexes, foreign keys etc A “DESCRIBE products” would give some information. Mainly the key field in the case. But defenietly no references and what table is linked to who etc etc. What is the best way to get…
How can I group by date time column without taking time into consideration
I have a bunch of product orders and I’m trying to group by the date and sum the quantity for that date. How can I group by the month/day/year without taking the time part into consideration? 3/8/2010 7:42:00 should be grouped with 3/8/2010 4:15:00 Answer Cast/Convert the values to a Date type for your …
How can I share the same primary key across two tables?
I’m reading a book on EF4 and I came across this problem situation: So I was wondering how to create this database so I can follow along with the example in the book. How would I create these …
Cannot use a CONTAINS or FREETEXT predicate on table or indexed view because it is not full-text indexed
I am getting following error in my SQL server 2008 R2 database: Cannot use a CONTAINS or FREETEXT predicate on table or indexed view ‘tblArmy’ because it is not full-text indexed.
Casting a double to a DateTime type is off by 2 days?
I store datetime values in the database as sql float type (Converted from an DateTime.OADate) for a myriad of reasons however in certain circumstances it is nice to get a human readable date/time …
What does the following Oracle error mean: invalid column index
I got the following error while testing some code: SQLException: Invalid column index What exactly does that mean? Is there an online document explaining what all the Oracle error codes and statements? Answer If that’s a SQLException thrown by Java, it’s most likely because you are trying to get o…
Fastest Way of Inserting in Entity Framework
I’m looking for the fastest way of inserting into Entity Framework. I’m asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomple…
Hamming weight/population count in T-SQL
I’m looking for a fast way to calculate the hamming weight/population count/”the number of 1 bits” of a BINARY(1024) field. MySQL has a BIT_COUNT function that does something like that. I couldn’t find a similar function in T-SQL? Or would you suggest storing the binary data in a field…
SQL Server Compact Edition ISNULL(sth, ‘ ‘) returns a boolean value?
I have an Accounts table with columns name, password and email. They are all type nvarchar. I wrote a query like SELECT name, password, ISNULL(email, ‘eeee’) FROM Accounts WHERE name = ‘” + …
How to find which columns don’t have any data (all values are NULL)?
I have several tables in a database. I would like to find which columns (in which tables) don’t have any values (all NULL in a column). I the example below, the result should be I don’t have any idea how to create this kind of query. Your help is most appreciated! Answer For a single column, count…