I have a situation where i need to enforce a unique constraint on a set of columns, but only for one value of a column. So for example I have a table like Table(ID, Name, RecordStatus). RecordStatus can only have a value 1 or 2 (active or deleted), and I want to create a unique constraint on (ID, RecordStatus) only
Tag: sql-server-2005
Simulating group_concat MySQL function in Microsoft SQL Server 2005?
I’m trying to migrate a MySQL-based app over to Microsoft SQL Server 2005 (not by choice, but that’s life). In the original app, we used almost entirely ANSI-SQL compliant statements, with one …
SQL Server 2005: Determine datatype of variable
Is it possible to determine the type of a local variable at runtime in TSQL? For example, say I wanted to do something along these lines: Or Does anyone know of any way to accomplish this? EDIT: This is not for a specific task, this is more of a general knowledge question. I do appreciate answers that indicate that the
SQL – Temp Table: Storing all columns in temp table versus only Primary key
I would need to create a temp table for paging purposes. I would be selecting all records into a temp table and then do further processing with it. I am wondering which of the following is a better approach: 1) Select all the columns of my Primary Table into the Temp Table and then being able to select the rows
SQL Statement Help – Select latest Order for each Customer
Say I have 2 tables: Customers and Orders. A Customer can have many Orders. Now, I need to show any Customers with his latest Order. This means if a Customer has more than one Orders, show only the Order with the latest Entry Time. This is how far I managed on my own: This of course returns all Customers with
Is it possible to execute a text file from SQL query?
I have a number of generated .sql files that I want to run in succession. I’d like to run them from a SQL statement in a query (i.e. Query Analyzer/Server Management Studio). Is it possible to do something like this and if so what is the syntax for doing this? I’m hoping for something like: I am using SQL Server