top of page

SSMS How to pull data (Simple, single table)

"Can you pull this data for me, please?"


This is a very common question for someone who does not know how to retrieve data, but here we will go over by how to pull data from a SINGLE table.


If you don't know where the table is located, simply ask your "go to" person. Example, "Hey, where is the table that shows summary of sales <or whatever you are looking for>?" Hopefully it isn't too complicated to retrieve what you are looking for (e.g. having to join to another table to get exactly what you need)


Later on we can go over how to find the table(s) on your own, but in the mean time, we can only work with what we've got, right? At least if you need to keep pulling the same data over and over again you won't have to be at the mercy of constantly waiting for someone else.


I'm sharing to you my initial steps of what I've learned, where to research, and how I wrote my first data pull query. I hope this helps!


Initial Set-up:

Before you can start your query, you will first need to know how to connect to the table. The best source I found when I was starting up was directly from this website. I followed the steps and screenshots, and gosh darn it, it works!


Commands:

  • SELECT - tells the system that data needs to be retrieved. I simply use the term 'start', because it literally is the start, the beginning, the first thing you do

  • FROM - tells the system which table to retrieve the data from

  • WHERE – tells the system the criteria of what to retrieve on the specified column. Often referred to as the filter or search condition.

  • AND/OR - tells the system I have more than one filter or search condition


SELECT *

FROM TABLE_NAME

This translates to: Retrieve ALL from the table! Asterisks (*) = ALL

To be honest, I've learned my lesson not to use this because it literally pulls everything and I've caused our server to lag. Oops


SELECT COLUMN_1_NAME, COLUMN_2_NAME, COLUMN_3_NAME

FROM TABLE_NAME

WHERE CONDITION_1

AND CONDITION_2

OR CONDITION_3

This, on the other hand translates to: Retrieve specific column from the table, but I only want specific data to show up


I've created and printed out this common condition table and slapped it on my wall (I made it myself). Side note, the usage part is just something I've used them for in real life scenarios, but not necessarily the only way to use them.


Common Conditions:


Example Result:

Common Conditions Examples:


Resources:

This is my favorite resource as it gave me several examples to get started:


Additional learning resource can be found here:








0 comments

Recent Posts

See All

Comments


bottom of page