Top "Sql-server" questions

Microsoft SQL Server is a relational database management system (RDBMS).

How to select all records from one table that do not exist in another table?

table1 (id, name) table2 (id, name) Query: SELECT name FROM table2 -- that are not in table1 already

sql sql-server tsql
"CASE" statement within "WHERE" clause in SQL Server 2008

I am working with a query which contains "CASE" statement within "WHERE" clause. But SQL Server 2008 is giving some errors …

sql sql-server case
Remove all spaces from a string in SQL Server

What is the best way to remove all spaces from a string in SQL Server 2008? LTRIM(RTRIM(' a b …

sql sql-server string whitespace trim
Pad a string with leading zeros so it's 3 characters long in SQL Server 2008

I have a string that is up to 3 characters long when it's first created in SQL Server 2008 R2. I would …

sql-server tsql
Inserting data into a temporary table

After having created a temporary table and declaring the data types like so; CREATE TABLE #TempTable( ID int, Date datetime, …

sql sql-server temp-tables
How can I select the first day of a month in SQL?

I just need to select the first day of the month of a given datetime variable. I know it's quite …

sql sql-server tsql sql-server-2008 datetime
How do I use ROW_NUMBER()?

I want to use the ROW_NUMBER() to get... To get the max(ROW_NUMBER()) --> Or i guess …

sql sql-server row-number
SQL exclude a column using SELECT * [except columnA] FROM tableA?

We all know that to select all columns from a table, we can use SELECT * FROM tableA Is there a …

sql sql-server tsql
Convert Rows to columns using 'Pivot' in SQL Server

I have read the stuff on MS pivot tables and I am still having problems getting this correct. I have …

sql sql-server pivot pivot-table
How to avoid the "divide by zero" error in SQL?

I have this error message: Msg 8134, Level 16, State 1, Line 1 Divide by zero error encountered. What is the best way to …

sql sql-server sql-server-2005 sql-server-2008