Meditech NPR Reports / NPR Report Writing / NPR Report Writer / Meditech NPR / Non-Procedural Report / Meditech Consulting / Meditech Reports Relational Database Programming: October 2006

Friday, October 20, 2006

2 Ways to Perform Inner Joins

These 2 queries return the same data. They would return all players that are Chicago Bulls players.

SELECT PLAYER,TEAM
FROM dbo.PLAYERS
INNER JOIN dbo.TEAM on PLAYER.TEAMID = TEAM.ID
WHERE TEAM.TEAM = "CHICAGO BULLS"

SELECT PLAYER,TEAM
FROM dbo.PLAYERS
, dbo.TEAM
WHERE PLAYER.TEAMID = TEAM.ID
AND TEAM.TEAM = "CHICAGO BULLS"

Monday, October 16, 2006

Change Control

Change control; instead of making a backup and performing a change in LIVE; do this.

1) Make the backup.
2) Make a copy to a test database.
3) Perform then change / update in the test database.
4) Review the test data.
5) Test your restore capability to the TEST database.
6) Make the update in LIVE.

Friday, October 13, 2006

Sql Server Ports

To determine the port for SQL server:
1) Sql Enterprise Manager
2) Select and Right-Click Instance of SQL Server
3) Select the General Tab
4) Select the Network Configuration Button
5) Select TCP/IP (it should be in the list of enabled protocols)
6) Click Properties
7) If the port is default it will be 1433. Otherwise a port is listed.

Sql Table Backup Restore

The easiest way to backup a table is using an SQL query.

Using the GO statement causes SQL to process your groups of statements sequentially instead of processing them in parallel. If you try to create a table that exists; but you were dropping it... you get the idea; it gets messy. Using the GO takes care of that.

=== Turn on bulk copy. ===
EXEC sp_dboption EVEREST_HMC99,'select into/bulkcopy', true
GO

=== Drop the destination backup table. ===
if exists (select * from dbo.sysobjects where id = object_id(N'[bkpItems]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [bkpItems]
GO

=== Backup the table. ===
SELECT *
INTO bkpItems
FROM Items
GO

=== Restoring the backup table using UPDATE for existing records. ===
=== Sample column names used below. ===
UPDATE Items
SET Items.SerialId = bkpItems.SerialId,Items.Cost = bkpItems.Cost
FROM bkpItems,Items
WHERE bkpItems.[ID]=Items.[ID]

Meditech NPR Reports / NPR Report Writing / NPR Report Writer / Meditech NPR / Non-Procedural Report / Meditech Consulting / Meditech Reports