I’m working on an application that deals with periodic payments Payments are done fortnightly i.e. payment 1: 2009-06-01 payment 2: 2009-06-15 payment 3: 2009-06-29 and now I need a SQL statement …
Tag: sql
How can I see the raw SQL queries Django is running?
Is there a way to show the SQL that Django is running while performing a query?
MySQL “Group By” and “Order By”
I want to be able to select a bunch of rows from a table of e-mails and group them by the from sender. My query looks like this: The query almost works as I want it — it selects records grouped by e-mail. The problem is that the subject and timestamp don’t correspond to the most recent record for a
How can I get column names from a table in SQL Server?
I want to query the name of all columns of a table. I found how to do this in: Oracle MySQL PostgreSQL But I also need to know: how can this be done in Microsoft SQL Server (2008 in my case)?
SQL query: count for all the reviews that each customer has written
Lets say I have one table called “REVIEWS” This table has Reviews that customers have written for various products. I would like to be able to get a “count” for all the reviews that each customer …
How to precompile stored procedures in SQL server?
Is there any way to pre compile stored procedures in SQL Server? My requirement goes like this.. I have some stored procedures, which take more time in compiling than executing. So I want to precompile all the stored procedures. It would be nice to precompile them when the db server is started and running. An…
Running a .sql script using MySQL with JDBC
I am starting to use MySQL with JDBC. I have 3-4 tables to create and this doesn’t look good. Is there a way to run a .sql script from MySQL JDBC? Answer Ok. You can use this class here (posted on pastebin because of file length) in your project. But remember to keep the apache license info. JDBC Script…
Best way to determine Server Product version and execute SQL accordingly?
This is a two-pronged question: Scenario: I have a script to query MSDB and get me details of job schedules. Obviously, the tables differ from SQL 2000 to SQL 2005. Hence, I want to check the version running on the box and query accordingly. Now the questions: Question 1: This is what I am doing. Is there a b…
SQL Bulk Insert with FIRSTROW parameter skips the following line
I can’t seem to figure out how this is happening. Here’s an example of the file that I’m attempting to bulk insert into SQL server 2005: ***A NICE HEADER HERE*** 0000001234|SSNV|00013893-03JUN09 …
Condition within JOIN or WHERE
Is there any difference (performance, best-practice, etc…) between putting a condition in the JOIN clause vs. the WHERE clause? For example… Which do you prefer (and perhaps why)? Answer The relational algebra allows interchangeability of the predicates in the WHERE clause and the INNER JOIN, so e…