The platform that enables you to build rich, interactive communities
in
All Tags » Database (RSS)

Browse by Tags

  • SQL 2005 Questions & Answers

    1. Explain the similarities and differences between a primary key and a unique key. Both primary key and unique key are used to identify a row as a unique entity for a table. A primary key can not be null; while a unique key can be null. 2. Explain the difference between a clustered index and a non-clustered...
    Posted to snowcounty (Weblog) by rliang on 01-16-2008
  • SQL 2005 Sample Databases

    A link to SQL 2005 sample databases: http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004
    Posted to snowcounty (Weblog) by rliang on 10-14-2007
  • SQL Nested Transactions

    Committing inner transactions is ignored by the SQL Server Database Engine. The transaction is either committed or rolled back based on the action taken at the end of the outermost transaction. If the outer transaction is committed, the inner nested transactions are also committed. If the outer transaction...
    Posted to snowcounty (Weblog) by rliang on 06-02-2007
  • Cartesian Join

    A Cartesian join is when you join every row of one table to every row of another table. You can also get one by joining every row of a table to every row of itself. One common mistake one makes is that when you join a table with itself. It forms a cartesian join. For example, a table with four duplicate...
    Posted to snowcounty (Weblog) by rliang on 05-05-2007
  • Query Performance with temp table

    Here is a situation, there is a table with over 100K records, using normal join would take a couple of minutes to complete. So I created one temp table to insert and update data. The result reduced to 2 minutes. Still it is not good. Here is a different version that using two temp tables. Insert into...
    Posted to snowcounty (Weblog) by rliang on 05-02-2007
  • Basic Database Terms

    Database Design Principles: 1. 3 rd Normal Form: 1). Atomicity, each entity in a database should be indivisible and consist of a single logical entity. 2). Primary key dependence, the primary key for an entity should be solely required to identify an entity. 3). Attribute independence, every attribute...
    Posted to snowcounty (Weblog) by rliang on 04-02-2007
  • Select duplicate rows in a SQL table

    There are two ways to select or delete duplicate rows in a sql table. SELECT sw1.term_id FROM myduplicate_table sw1 INNER JOIN myduplicate_table sw2 ON sw1.word_text = sw2.word_text WHERE sw1.term_id > sw2.term_id GROUP BY sw1.term_id, sw1.word_text OR SELECT * FROM TABLE1 A WHERE ID NOT IN (SELECT...
    Posted to snowcounty (Weblog) by rliang on 03-30-2007
  • A simple case statement

    SELECT FirstName, LastName, Salary, DOB, CASE Gender WHEN ‘M’ THEN ‘Male’ WHEN ‘F’ THEN ‘Female’ END FROM Employees
    Posted to snowcounty (Weblog) by rliang on 03-29-2007
  • Database scripts for creating the user, grant execution permission to the user

    Create a database user USE [TEMPDB] DECLARE @PW VARCHAR(50) SET @PW = ‘TEMPDB_user!!’ Exec(’CREATE LOGIN TEMPDB_user WITH PASSWORD = ‘'’ + @PW + ‘'’, CHECK_POLICY = OFF’) Exec(’CREATE USER [TEMPDB_user] FOR LOGIN [TEMPDB_user] WITH DEFAULT_SCHEMA=[dbo]’) GRANT table access to an user GRANT SELECT...
    Posted to snowcounty (Weblog) by rliang on 03-28-2007
  • SQL Temp table

    To create a temp table: CREATE TABLE #tmpTable ( tmpID int, tmpName char(30) ) select name from tempdb..sysobjects where name like ‘#tmpTable%’ drop table #tmpTable Temp table is a very useful way to compute complex business rules within database. The computing result is much, much faster then through...
    Posted to snowcounty (Weblog) by rliang on 03-25-2007
Page 1 of 3 (24 items) 1 2 3 Next >