SQL Interview Questions

Basic questions

Q.How do you query a database?

A. We use select statement against a table. We can choose the particular fields that we want or we can pull everything in the table using * for fields.

Q.You have student tables which has the enrollment student first name, last name and enrollment date. How do you pull the list of students who are were enrolled the last (most recently)

select * from students order by enrolldate desc

Q. How do you enter date in SQL Server 2008?

The general accepted form for data in SQL is YYYY-MM-DD. That is year first, followed by – then month then – than day. However depending on which country we are in, we can also use datatime in the format that the operating system understands. For exmaple we can enter

4/20/2012 which is equal to Apr-04-2012

We may also use / instead of – when entering date. E.g

04/20/2012  -- this is a valid date

Q. Can you write syntax of join two tables A and B?

 

Q.You have two tables both contain similar data and the same number of fields? Can I find the difference between the two tables?

 

 

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s