blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Browse by Tags

All Tags » SQL » T-SQL
Showing page 1 of 2 (17 total posts)
  • Using a Bitmask - a practical example

    A colleague of mine asked for a simple example to get him up and running with the basics of bitmasking.  Since I had gone to the effort to create the example I thought I might as well blog it :o). This example uses the logical AND operator &. First of all you need to define your table.. create table BitmaskDemo (ID int Primary ...
  • T-SQL IDENTITY : Fun and Games with DBCC CHECKIDENT

      This issue caught me out today whilst putting together some build scripts for reference data. So I thought I’d share it. USE [tempdb] GO CREATE TABLE [dbo].[Table_1](       [Col1] [int] IDENTITY(1,1) NOT NULL,       [Col2] [char](1) NOT NULL ) ON [PRIMARY] GO delete from ...
  • SQL tutorials and learning resources

    Following a few requests, here are some sites you may find useful for supporting your SQL learning: General http://www.stickyminds.com/  http://www.thefreecountry.com/documentation/onlinesql.shtml (free online tutorials) T-SQL http://sqlcourse.com/ (free online tutorial) http://www.w3schools.com/sql/default.asp (free online ...
    Posted to Jim 2.0 (Weblog) by James.Pipe on November 14, 2007
  • SQL: Using the Trim function to remove white space from a field

    Today I was looking at a table with an apparantly empty column and discovered that the field is actually populated with blank spaces - Fortunately this field is of no interest to me and I noticed it purely by chance when I pasted an extract of the dat into excel and happened to notice the cell was unusually wide when I formatted the sheet. Anyway, ...
    Posted to Jim 2.0 (Weblog) by James.Pipe on August 14, 2007
  • SQL Quick Tip: Using Top N to browse a database

    If you ever need to browse through a database, and dip in and out of tables to see what the data looks like, but you have very little data to go on, then you will be aware that simply running a select * against each table can be a time consuming and inefficient process. I am in this situation currently with a database that has no enforced ...
    Posted to Jim 2.0 (Weblog) by James.Pipe on August 9, 2007
  • Automatically format your SQL statements

    A colleague forwarded me this link today, which I thought would be beneficial to anyone who has to write a lot of SQL statements. The tool will automatically format the statements to 'beautify' them, so no more excuses for 'ugly' code! Check it out here James
    Posted to Jim 2.0 (Weblog) by James.Pipe on August 9, 2007
  • SQL Server 2005: Passing variables into an OPENQUERY argument

    Today I ran into a blocker when trying to do this. Having spent a reasonable amount of time taking all of my sql statements out of the OPENQUERY argument and putting them into a string variable I then found it didn't work. The reason (from BOL) it turns out is that, and I quote; "OPENQUERY does not accept variables for its ...
    Posted to Jim 2.0 (Weblog) by James.Pipe on June 28, 2007
  • T-SQL Calendar table

    After experimentation with various datepart and datename methods following my most recent blog post, I was able to identify many if not all the necessary components for constructing a calendar table.To do this I have combined these functions with the SQL to generate a list of dates as posted by Jamie some time ago. The resultant SQL is given ...
    Posted to Jim 2.0 (Weblog) by James.Pipe on April 24, 2007
  • PL/SQL and T-SQL for Week Ending Date

    Recently my colleague challenged me to  find a method for identifying the week ending date for the week which any given date belongs to; i.e. say for a gven date which happens to be a Tuesday, what is the date of the end of the week? In this example, week ending is defined as a Sunday, however depending on how your server is set up, ...
    Posted to Jim 2.0 (Weblog) by James.Pipe on April 24, 2007
  • T-SQL: Common date ranges; Daily, Weekly, Monthly, Yearly, Last 12 Months

    As promised in my original post on PL/SQL date ranges previously, below is a sql statement which can be used preceeding most queries in order to apply common date range lookups to the data the query returns. SQL Server Management Studio (SSMS) doesn't have an equivalent to the '&' functionality that TOAD has to ...
    Posted to Jim 2.0 (Weblog) by James.Pipe on March 1, 2007
1 2 Next >
Powered by Community Server (Personal Edition), by Telligent Systems