Category Archives: SQL Server

SQL Server Resources – 7/11/09

sql

I have run across a few great resources for SQL Server recently. Some are new and some have been around for awhile and I’m just discovering them.

Until later…

Converting Dates in SQL Server

 

In the world of Application and DB Development there is always a need to display dates in a format that is understandable to your audience.  For example, in the US we normally expect to see a date as mm/dd/yyyy; however, in Great Britain, the normal format is dd/mm/yyyy.  The Convert function in SQL Server provides a means to translate SQL Server’s default date format to just about any format.

The syntax for the Convert function is as follows:

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Available Date Formats –

 Source Code

tsql

It shows some of the different ways dates can be formatted and produces the result below.

 

Below are a few resources that I found on using the Convert function.

I also posted a while back about Handling Dates in SQL Server.

Happy Learning!

PASS 2008 Resources

I rarely get to go to conferences unless they are local and cheap, so I try to focus on finding information from the conferences that I can’t be at. Below are some great resources that I have run across for the 2008 SQL PASS Community Summit.

I am sure there are a lot more resources that I have not seen.  I will update this post as I run across any more.

SQL Server Reporting Services – Resources

We had a “brown bag” lunch at work last Wednesday and the topic was SQL Server Reporting Services (SSRS). We use SSRS extensively at our company, but I have just recently been exposed to it, so I thought I would post some resources and information on the topic.

SQL Server Reporting Services is a report generation tool, similar to Crystal Reports, that can be used to make interactive and printed reports. The design environment takes a little getting used to, but it is a pretty powerful tool. Reports can be exported to a number of different formats including XLS, PDF and XML.

Information Resources

Video Tutorials

Support Resources

Updated 08/28/2008 – I was informed via email of 2 more great resources for Reporting Services.

Happy Learning!!!

SQL Programming Tutorial

 

BlackWasp Software Development has started a great tutorial on SQL Server Programming Fundamentals.  In the past they have posted tutorials on C# Fundamentals and C# Object-Oriented Programming.  All of the tutorials thus far have wielded a plethora of information.  BlackWasp is a great resource for beginning to intermediate developers and I highly recommend checking out their site.

Happy Learning…

SQL Join Resources

A Join combines records from two (or more) tables to create a new data set.  There are several ways to join SQL tables.  Below are the most common Joins.

  • INNER Join – Result will contain matching records from both tables
  • LEFT Join – Result will contain all records from the “left” table even if the join-condition does not find any matching record in the “right” table
  • RIGHT Join – Result will contain all records from the “right” table even if the join-condition does not find any matching record in the “left” table
  • FULL Join – Result will contain all records from both tables, and fill in NULLs for missing matches on either side
  • CROSS Join – Result will contain returns the cartesian product of the sets of records from the two joined tables (Dangerous with large tables)

Instead of including all the normal code snippets illustrating each type of join, I am listing links to others who have done that job very well.

The above articles are ones the I will likely reference over and over again.

Column Headings from SQL Results – Easier Way

I posted yesterday on pulling the column headings from a SQL Server result set and transferring them to Excel.  I received a comment from Scott Stonehouse outlining a much easier way to do what I need to do.

Simply access the Tools Menu and select Options.  On the left, expand Query Results/SQL Server and select Results to Grid.  On the right check Include column headers when copying or saving the results.

2008-04-24_084916

Run a query in SQL Server Management Studio and select the contents of the result set.

2008-04-24_085755

 

Paste the results into Excel – like magic, there are the column headings.

2008-04-24_085900 

To me, Scott proved what the Internet and blogs are for.  Teaching and Learning.

Column Headings from SQL Results

I have had some one-off requests to basically dump data from SQL Server to an Excel spreadsheet.  I am the kind that wants to make the spreadsheet look decent, so I would like to at least have column headings.  The below process provides a less painful way to get column headings from a SQL results grid into Excel. 

In SSMS, go to Query>Results To>Results to Text

1

Run the query
Copy the column heading line and paste into NotePad

2

Next, put the headings on separate lines by doing CTRL-Right Arrow-Enter until you hit the end of the list

3 

Copy the list and paste into Excel starting on line 2
Once in Excel, do a Ctrl C, select A1 and Paste/Paste Special and Check transpose (ok)

4

As you can see the column headings are now on Row A

5

Go back to SSMS and go to Query>Results To>Results to Grid
Run the query
6

Copy the contents and paste it in the Excel file starting in Row B

7   

This process helps tremendously when the result set contains more than 20 fields; however, if you find yourself pulling the same data on a regular basis, I recommend using SQL Server Integration Services or Excel automation.

HDNUG Meeting – 04/10/08 – Recap

I attended the Houston .NET User Group meeting Thursday night where there was a great turnout of well over 100 people.  The sponsor was Clearpoint Technology.

hdnugsmall         clear point

The presentation was given by Mohammad Azam and the topic was LINQ to SQL and Gotchas.  Mohammad is a very interesting presenter and really knows his stuff.  He is what I like to call a coding presenter.  A presenter that codes their samples on the spot and does not have a ton of slides in the slide deck.  Although, he did present his first slide that read “Slide 1 of 347″  (or something like that) as a joke to break the ice.  Well it worked, he had the whole room laughing.

Below are some of the items/points presented.

  • CRUD operations using LINQ to SQL
  • The DelayLoaded property in the data designer
  • Data load options
  • LINQ to SQL as an alternative to calling Stored Procedures from C# code
  • Anonymous Data Types

Mohammad finished the presentation by going over some of the problems he encountered while working with LINQ to SQL.

There was a plethora of information in the presentation – so much it was difficult to note everything.

n663266440_780230_9260     n663266440_780232_9688

Related Content

HASSUG Meeting Recap – 04/08/08

I attended the Houston SQL Server User Group meeting today during my lunch hour.  The speaker was Randy Dyess with Solid Quality Mentors and the topic was SQL Server memory management.

There were about 30 people in attendance.  Up from the past.  When asked, several said they heard about the group via the Microsoft Launch last month.

0408081250-00

It was an information-packed presentation.  So packed that there was not enough time to finish the entire demo.

[Download Presentation Materials

Some of the items covered

  • Memory Limits
  • Memory Extensions
    1. AWE – Address Windowing Extension
    2. PAE – Physical Address Extension
  • Cache Concepts (cache – Basically, memory broken into 8k pages)
  • Memory Allocation
    1. Dynamic Memory Allocation
    2. Fixed Memory Allocation (SQL Server’s memory)
  • SQL Memory
    1. MemToLeave (aka Memory Outside Buffer Pool)
    2. Worker Threads
    3. Buffer Pool
  • Linked Servers
  • SQL CLR
  • Memory Counters
  • Extended stored procs run in unmanaged memory

Follow

Get every new post delivered to your Inbox.