I’ve got a SQL Server table with about 50,000 rows in it. I want to select about 5,000 of those rows at random. I’ve thought of a complicated way, creating a temp table with a “random number” column, …
Persistent temp tables in SQL?
Is it possible to have a ‘persistent’ temp table in MS-SQL? What I mean is that I currently have a background task which generates a global temp table, which is used by a variety of other tasks (…
Getting new IDs after insert
I’m inserting a bunch of new rows into a table which is defined as follows: using the following insert: when I’ve finished, I’d like to know the IDs of all the newly inserted rows. SCOPE_IDENTITY() only returns the ID last row inserted. How can I get all the new IDs? One method that springs to mind would be to grab
WHERE IS NULL, IS NOT NULL or NO WHERE clause depending on SQL Server parameter value
I have a stored procedure in SQL Server 2000 that performs a search based on parameter values. For one of the parameters passed in, I need a different WHERE clause depending on its value – the problem …
How can I compare time in SQL Server?
I’m trying to compare time in a datetime field in a SQL query, but I don’t know if it’s right. I don’t want to compare the date part, just the time part. I’m doing this: Is it correct? I’m asking this because I need to know if 08:00:00 is less or greater than 07:30:00 and I don’t want to compare
What is the best way to access stored procedures in Django’s ORM
I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django’s ORM. Has anyone integrated SP’s with Django’s ORM successfully? If so, what RDBMS …
How to update rows with a random date
I have a simple SQL table which has a DateTime column. I would like to update all the rows (>100000 rows) with a random date. Is there a simple way to do this a SQL Query?
SQL query that distinguishes between ß and ss
It seems that ß=ss in SQL. I need to be able to distinguish on a strict charcter equivalent basis. i.e. SELECT * from table WHERE name LIKE ‘%ß%’ yields Brian Bruß Steven Sossmix etc.. I’ve looked at …
Case expressions in Access
Can you use case expressions in Access? I’m trying to determine the max date form 2 columns but keep getting syntax errors in the following code: CASE WHEN dbo_tbl_property.LASTSERVICEDATE > …
How to use “AND” in a Django filter?
How do I create an “AND” filter to retrieve objects in Django? e.g I would like to retrieve a row which has a combination of two words in a single field. For example the following SQL query does exactly that when I run it on mysql database: How do you accomplish this in Django using filters? Answer (update: this answer