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…
Tag: sql
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
How to add value to SET field in mysql?
I have a table named user with a field of type SET named privs. The allowed values of this field are: ‘ADD’,’EDIT’,DELETE’,’ALL’. What SQL query should I execute to add let’s say value ‘EDIT’ to the field privs for a given row? But only if there is n…
Converting Numbers to Words in MYSQL result! Using Query
I am trying to print a output as follows when I execute a query in mysql. Name Salary Sal_in_Words Mohan 45000 Rupees Forty Five Thousand Only The column Salary has a value 45000 and in the …
Select EMP with max SAL from each DEPT
I´m having a bad time with a SQL query. I´m using oracle default tables: ‘EMP’ TABLE http://imageshack.us/photo/my-images/850/sinttuloxps.png/ AND ‘DEPT’ TABLE http://imageshack.us/photo/my-images/19/assayp.png/ I wan´t to get the employee with the highest salary in each department. I´…