How can I get the table creation date of a MS SQL table using a SQL query? I could not see any table physically but I can query that particular table. Answer For 2005 up, you can use I think for 2000, you need to have enabled auditing.
Tag: sql
Sql Query to Linq
How would I convert this query from SQL to Linq: Update Thanks Guys, this is the code I used. Tested and returns the same as above: Answer I don’t know if the syntax is correct (especially the last two lines) but it should be pretty close. I added the 0 between group and by based on Eamon Nerbonne’…
How do I calculate a running total in SQL without using a cursor?
I’m leaving out all the cursor setup and the SELECT from the temp table for brevity. Basically, this code computes a running balance for all transactions per transaction. Inspired by this code from an answer to another question, I was wondering if SQL had the ability to sum numbers in the same way it…
Column name or number of supplied values does not match table definition
In SQL server, I am trying to insert values from one table to another by using the below query: delete from tblTable1 insert into tblTable1 select * from tblTable1_Link I am getting the following …
Dynamic order direction
I writing a SP that accepts as parameters column to sort and direction. I don’t want to use dynamic SQL. The problem is with setting the direction parameter. This is the partial code: Answer You could have two near-identical ORDER BY items, one ASC and one DESC, and extend your CASE statement to make on…
Oracle SQL escape character (for a ‘&’)
While attempting to execute SQL insert statements using Oracle SQL Developer I keep generating an “Enter substitution value” prompt: I’ve tried escaping the special character in the query using the ” above but I still can’t avoid the ampersand, ‘&’, causing a stri…
T-Sql 2005 Adding hours to a datetime field with the result within working hours
I have two Datetime fields that I wish to add together. They are in the following format: ’01/01/1900 00:00:00′. The main issue with this is that I want the calculation to only include working hours. …
Grouped LIMIT in PostgreSQL: show the first N rows for each group?
I need to take the first N rows for each group, ordered by custom column. Given the following table: I need the first 2 rows (ordered by name) for each section_id, i.e. a result similar to: I am using PostgreSQL 8.3.5. Answer New solution (PostgreSQL 8.4)
LINQ to SQL – Left Outer Join with multiple join conditions
I have the following SQL, which I am trying to translate to LINQ: I have seen the typical implementation of the left outer join (ie. into x from y in x.DefaultIfEmpty() etc.) but am unsure how to introduce the other join condition (AND f.otherid = 17) EDIT Why is the AND f.otherid = 17 condition part of the J…
How to think in SQL?
How do I stop thinking every query in terms of cursors, procedures and functions and start using SQL as it should be? Do we make the transition to thinking in SQL just by practise or is there any …