About 2,650,000 results
Open links in new tab
  1. sql - DISTINCT for only one column - Stack Overflow

    Feb 19, 2017 · 15 This assumes SQL Server 2005+ and your definition of "last" is the max PK for a given email WITH CTE AS ( SELECT ID, Email, ProductName, ProductModel, …

  2. sql - How to get the identity of an inserted row? - Stack Overflow

    Sep 3, 2008 · SQL server clustering is a high availability feature and has no bearing on parallelism. It is very uncommon for single row inserts (the most common case for …

  3. sql - How to SELECT FROM stored procedure - Stack Overflow

    May 4, 2017 · I have a stored procedure that returns rows: CREATE PROCEDURE MyProc AS BEGIN SELECT * FROM MyTable END My actual procedure is a little more complicated, …

  4. Best way to do nested case statement logic in SQL Server

    I'm writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions. I'm currently using nested case statements, but its getting messy. …

  5. sql - How to Join to first row - Stack Overflow

    Feb 14, 2019 · For SQL Server versions prior to 2005, you need to use an INNER JOIN instead of a CROSS APPLY: SELECT Orders.OrderNumber, LineItems.Quantity, LineItems.Description

  6. SQL - 'DISTINCT' based on only some columns? - Stack Overflow

    Jul 23, 2011 · I have a database with two tables. One of the tables contains users, the other contains addresses for those users. Each user may have several addresses (though each …

  7. sql - Get top 1 row of each group - Stack Overflow

    Jul 27, 2011 · The select top 1 with ties clause tells SQL Server that you want to return the first row per group. But how does SQL Server know how to group up the data? This is where the …

  8. Format SQL in SQL Server Management Studio - Stack Overflow

    Feb 13, 2020 · Beginning with SQL Server Management Studio (SSMS) 18.7, Azure Data Studio is automatically installed alongside SSMS. Source Update: Actually Azure Data Studio is in …

  9. sql - How do I list all the columns in a table? - Stack Overflow

    Oct 16, 2009 · Microsoft SQL Server Management Studio 2008 R2: In a query editor, if you highlight the text of table name (ex dbo.MyTable) and hit ALT + F1, you'll get a list of column …

  10. sql - Conversion failed when converting the nvarchar value ... to …

    Feb 9, 2014 · My invalid SQL query looked like this: SELECT * FROM RandomTable WHERE Id IN (SELECT Id FROM RandomTable WHERE [Number] = 13028533) This didn't work since …