I.T. Discussion Community!
-Collapse +Expand
DBA
Search DBA Group:

Advanced
-Collapse +Expand DBA Group Home

WEEKLYLESSON
Week 37 Lesson◄╣

MY
GROUPSETTINGS
-Collapse +Expand DBA Store
PRESTWOODSTORE
   ► All GroupsDBA Group   Print This    All Groups  

Weekly DBA Lesson

Week 37, Posted Monday 9/16/2019

Content changes every Monday @ 1AM!! Check back once per week. Learn! Review! Test Yourself!

Weekly DBA Lesson

[Print Lesson]

Week 37, Posted Monday 9/16/2019

Content changes every Monday @ 1AM!! Check back once per week. Learn! Review! Test Yourself!

FAQ of the Week
Question: Is there a way to reverse order a select statement?

Answer:

Yes. Use the DESC keyword in your order by clause on each column you want ordered descending. Use ASC for ascending.

select * from Customer 
Order by Age Desc, City Asc, State Asc
Tip of the Week
Tip: The three normal forms can be summed up in the following phrase: “All the fields of a table should relate to the key, the whole key, and nothing but the key.”
Definition of the Week
Master Table:  A master table in a multitable relationship is the primary table. For every record in the master table, there can be many records in the detail table. If you are only dealing with one table, then it is the master table. A detail table in a multitable relationship is the table whose records are subordinate to those of the master table. A detail table is also called a slave table, a child table, or a many table.
Link of the Week
Windows Virtualization List of resources provided by Microsoft about Windows Virtualization which was introduced with Vista.
File of the Week
Oracle Berkely DB XML

Lastest DBA Flashcard

Our flashcards are part of our library of tidbits.

Tidbits are FAQs, Definitions, Tips, and Code Snippets from our knowledge base.

Easy SQL Server Backup Script

Learn how to make an easy SQL Server Script that will automatically back up all your databases in a simple way.

-- Back Up All Databases
-- by Bryan Valencia

--create temp table
declare @temp table(commands varchar(500), completed bit)

--load it with backup commands
insert into @temp (commands, completed)
(select
    'BACKUP DATABASE ['+name+
    '] TO  DISK = N''J:\Backups\'+name+
    '.bak'' WITH  COPY_ONLY, NOFORMAT, NOINIT,  NAME = N'''+name+
    '-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD,  STATS = 10',
    0
from
    master.sys.databases
where
    owner_sid <> 0x01 and state_desc='ONLINE'
)

--variable for the current command
declare @thisCommand varchar(500);

--loop through the table
while (select count(1) from @temp where completed=0)>0
begin
    --find the first row that has not already been executed
    select top 1 @thisCommand = commands from @temp where completed=0

    --show the command in the "mesage" output window.
    print @thisCommand

    --execute the command
    EXEC (@thisCommand);

    --flag this row as completed.
    update @temp set completed=1 where commands=@thisCommand
end

--show the user the rows that have been found.
select * from @temp

Posted By Bryan Valencia, Post #102439, KB Topic: Microsoft SQL Server

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech