T-SQL and Stored Procedure Reference Manual

  • I am curious of others' thoughts on what book would meet my needs. I bought the Microsoft SQL-Server 2008 T-SQL Fundamentals book but I find it very sparse in what I need.

    I am a data analyst, not a DBA. I am very good at writing Oracle queries and I am very experienced with Microsoft Access. SQL Server is a little new to me. I am one month into a new job where SQL Server is the primary database that we use. What I mostly need is a reference book.

    Usually, I know what I want to do. I know how to do it in other languages. I just need to find the appropriate command for certain issues and the syntax for them. So, I need a reference book where I can find them easily.

    For example, when I need to convert an date stored as an integer (ex. '20120521') and I want to convert it to a date, I would like to be able to look up the convert/cast functions and see the options and examples or find a better way to do it. It would be nice if there was a chapter/section on date functions with all the date functions, the syntax for them, and examples.

    Or, when I want to write a stored procedure and I am looking to branch my code with a Case statement I want a book that clearly tells me that you can't do that because the Case statement can only be used in Select statements. It took me awhile to realize that you have to use nested If statements instead of Case statements.

    Also, I want a book that tells me different string functions (maybe all in the same chapter) where I can go to when I need to work with strings and need syntax. Like the date function suggestion I had before.

    I am not looking for the book to be limited to SQL functions. I would like the book to have information on writing stored procedures, user defined functions, and triggers, also.

    What book would you suggest?

    Thank you.

    Tammy

  • First, welcome to SSC and MS SQL Server.

    I had to go the other way for a while (MS SQL Server to Oracle) and was confused to CASE used for flow control.

    Any way, the only book I can think of that you may be looking for is SQL Servers Books Online, the help system for MS SQL Server.

    As for some of what you are looking for, may come from just doing it. Converting an integer value 20120521 to a datetime value, for instance. Easy to do if you know all the values are valid dates (trickier if you need to validate them first). Using SQL Server 2008, here is an example:

    declare @dateint int = 20120521;

    select @dateint, cast(CAST(@dateint as varchar) as datetime);

    If you have any questions, SSC is a good place to ask. Best thing to do, read the first article I reference below in my signature block. It will help you with some of the questions you may ask. Also, you may want to make sure you post in the correct forum for the version of SQL Server you are using. If you are using SQL Server 2000 and post in a SQL Server 2008 forum, you may get answers that don't work for you.

    Again, welcome to SQL Server!

  • Start with MSDN.com. It's where Microsoft documents all the T-SQL commands, functions, syntax, etc. Same content as the installable "help file", called Books Online.

    If you need the syntax of a particular T-SQL piece, Bing/Google/whatever, will find it for you pretty easily. For example, searching for "t-sql select" gets you the Select clause syntax. "t-sql case" as a search would probably have saved you a bit of time.

    On writing procedures, functions, et al, I really found "The SQL Server Bible" series very, very helpful when I was learning the subject. I'm not sure if there's a 2012 version of that, since the last one I used was SQL 2000. I found it very helpful to a total newbie on the thing, without being sparse (like a For Dummies book).

    But, from the sounds of it, most of what you need is the documentation on MSDN.com. It should answer 80-90% of your questions, and you can probably get the rest of them answered here on these forums.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply