Eapen G's Library tagged → View Popular
Less Than Dot - Blog - The Ten Most Asked SQL Server Questions And Their Answers
The Ten Most Asked SQL Server Questions And Their Answers
by SQLDenis
Permalink 10 Dec 2008 10:09 , Categories: Data Modelling & Design Tags: answers, questions, sql server 2000, sql server 2005, sql server 2008
If you are active in the SQL Server newsgroups and forums as I am, you will notice that the same questions keep popping up all the time. I picked ten of them which I see daily. Since this became a pretty long blogpost I have linked all the questions below to jump to the question itself.
1) Selecting all the values from a table for a particular date
2) Search all columns in all the tables in a database for a specific value
3) Splitting string values
4) Select all rows from one table that don't exist in another table
5) Getting all rows from one table and only the latest from the child table
6) Getting all characters until until a specific character
7) Return all rows with NULL values in a column
8) Row values to column (PIVOT)
9) Pad or remove leading zeroes from numbers
10) Concatenate Values From Multiple Rows Into One Column
1 Selecting all the values from a table for a particular date
This is a very popular question and people sometimes answer that you need to use between. There is a problem with between if you happen to have a value at exactly midnight. Let us take a look, first create this table.
tsqlLine number On/Off | Show/Hide | Select all
1. CREATE TABLE SomeDates (DateColumn DATETIME)
Code is hidden, SHOW
Insert 2 values
tsqlLine number On/Off | Show/Hide | Select all
1. INSERT INTO SomeDates VALUES('2008-10-02 00:00:00.000')
2. INSERT INTO SomeDates VALUES('2008-10-01 00:00:00.000')
Code is hidden, SHOW
Return everything between '2008-10-01' and '2008-10-02'
tsqlLine number On/Off | Show/Hide | Select all
1. SELECT *
2. FROM SomeDates
3. WHERE DateColumn BETWEEN '20081001' AND '20081002'
4. ORDER BY DateColumn
Code is hidden, SHOW
This works without a problem, we get this returned
(results)
2008-10-01 00:00:00.000
2008-10-02 00:00:00.000
Let's add some m
Selected Tags
Related Tags
Sponsored Links
Top Contributors
Groups interested in programm...
-
Rspec Intro
RSpec is a Behaviour Driven...
Items: 11 | Visits: 234
Created by: Vincent Tsao
-
webdevelopment
Links to webdevelopment
Items: 252 | Visits: 189
Created by: alfred westerveld
-
Programming jQquery
Items: 26 | Visits: 254
Created by: Vincent Tsao
Diigo is about better ways to research, share and collaborate on information. Learn more »
Join Diigo
