As I am not expert in writing the SQL queries so want for help. I have a table called programmer whose structure & data look like: In prof1 data are: PASCAL,CLIPPER,COBOL,CPP,COBOL,PASCAL,ASSEMBLY,PASCAL,BASIC,C,PASCAL,FOXPRO. In prof2 data are: BASIC,COBOL,DBASE,DBASE,ORACLE,DBASE,CLIPPER,C,DBASE,COBOL,A…
Insert datetime from C# into SQL Server database
when I try to insert datetime value into a SQL Server database I get this error: Conversion failed when converting date and/or time from character string Code: Table table has 1 datetime column called time. Edit: my table created in msSQL 2012: http://i.imgur.com/TJ3t3y7.png my real code is: Answer The actual…
Oracle table create error ORA-00904 invalid identifier
It’s very interesting I don’t know why I’m getting ORA-00904 invalid identifier when I’m trying to create a table with oracle. CREATE TABLE animals ( CONSTRAINT animal_id NUMBER(6) PRIMARY_KEY, …
SqlAlchemy: How to use the result of a selected subquery inside the where clause
I wish to get a list of articles along with the count of the comments for each article My query looks like this – comments_subq = meta.Session.query(func.count(Comment.id)).filter(Comment.article_id=…
What does SQL Server do with a timed out request?
Suppose that I use C# to run a long running SQL Server stored procedure (lets say 30 minutes). Further suppose that I put a 1 hour timeout period on the query in C# such that if for whatever reason this SP takes longer than expected, I don’t end up monopolizing the DB. Lastly, suppose that this stored p…
Get data from both table, where data isn’t common for this tables
I have 2 tables TABLE jt1 and TABLE jt2 I need get names from both tables, which is not common for both tables, that is result must be This is my query, but may be there is better solution for this? Answer BTW: the naive solution could probably be faster: BTW: I purposely use UNION ALL here, because I know
What determines the locking order for a multi-table query?
Does the SQL standard specify the locking order for a multi-table query? For example, given: Does the SQL standard guarantee a locking order or is it determined by the (implementation-specific) execution plan? Is there a way to guarantee a locking order? If there is no way to guarantee locking order, how are …
Count NULL Values from multiple columns with SQL
I have 3 columns let say A, B, and C. I need to count the NULL values in each column. For example: Should output: I’ve tried count, sum, sub-queries but nothing has worked for me yet. Any input would be appreciated! Answer
How can I delete using INNER JOIN with SQL Server?
I want to delete using INNER JOIN in SQL Server 2008. But I get this error: Msg 156, Level 15, State 1, Line 15 Incorrect syntax near the keyword ‘INNER’. My code: Answer You need to specify what table you are deleting from. Here is a version with an alias:
Flattening a hierarchial data set in Oracle
I have a set of data as shown below I need to flatten this data as below: And so on. I can have up to 30 parent child relationship I used the connect by and sys_connect_by_path as follows The result set is too large. There are other trees in this table and I don’t think it just looks at the