insert script_devs_and_dbs into table scripts


DELETE scripts WHERE name = 'script_devs_and_dbs'
go
INSERT scripts 
VALUES('script_devs_and_dbs','DECLARE @name VARCHAR(30),')
INSERT scripts 
VALUES('script_devs_and_dbs','        @phyname VARCHAR(127),')
INSERT scripts 
VALUES('script_devs_and_dbs','	@vdevno VARCHAR(20),')
INSERT scripts 
VALUES('script_devs_and_dbs','	@size VARCHAR(20),')
INSERT scripts 
VALUES('script_devs_and_dbs','	@line varchar(80)')
INSERT scripts 
VALUES('script_devs_and_dbs','SET NOCOUNT ON')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "/**************************************************************"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "     CINS SQL SERVER DEVICE AND DATABASE RECOVERY SCRIPT"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','SELECT @line = "                     SERVER: " + @@SERVERNAME')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT @line')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','SELECT @line = "                 DATE: " + CONVERT(CHAR(20),getdate())')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT @line')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "          =================== NOTES =================="')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   This script will create all SQL Server devices and databases."')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   Rebuild any database by making sure a device structure like that"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   shown exists for that database, running the relevant create"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   script(s), and loading the most recent dump for that database."')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "                 "')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   The device section includes a script to create the master device."')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   Remove the script if you are working with a good master device"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   that matches the size shown."')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   The database section includes scripts to create the master, model,"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   msdb, pubs, and tempdb databases. Remove as necessary BEFORE "')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   running the full script."')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   To restart after a rebuild of master where all user devices"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   are still useable, change all DISK INIT to DISK REINIT and"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   replace the entire database create section with the single"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "   line: DISK REFIT"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "*****************************************************************/"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "         /*============= DEVICES SCRIPTS ===============*/"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "USE master"')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "GO"')
INSERT scripts 
VALUES('script_devs_and_dbs','DECLARE object_cursor CURSOR')
INSERT scripts 
VALUES('script_devs_and_dbs','FOR')
INSERT scripts 
VALUES('script_devs_and_dbs',' SELECT d.name,')
INSERT scripts 
VALUES('script_devs_and_dbs','        phyname,')
INSERT scripts 
VALUES('script_devs_and_dbs',' STR(CONVERT(TINYINT,SUBSTRING(CONVERT(BINARY(4),d.low),v.low, 1)),3,0), ')
INSERT scripts 
VALUES('script_devs_and_dbs','        str(d.high - d.low + 1,8,0)')
INSERT scripts 
VALUES('script_devs_and_dbs','FROM master..sysdevices d,master..spt_values v')
INSERT scripts 
VALUES('script_devs_and_dbs','WHERE cntrltype=0 AND v.type="E" AND v.number=3')
INSERT scripts 
VALUES('script_devs_and_dbs','ORDER BY CONVERT(TINYINT,SUBSTRING(CONVERT(BINARY(4),d.low),v.low,1))')
INSERT scripts 
VALUES('script_devs_and_dbs','OPEN object_cursor')
INSERT scripts 
VALUES('script_devs_and_dbs','FETCH NEXT FROM object_cursor INTO @name, @phyname, @vdevno, @size')
INSERT scripts 
VALUES('script_devs_and_dbs','WHILE (@@fetch_status <> -1)')
INSERT scripts 
VALUES('script_devs_and_dbs','  BEGIN')
INSERT scripts 
VALUES('script_devs_and_dbs','  IF @name = "master" PRINT "/*****"')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT " "')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT "DISK INIT"')
INSERT scripts 
VALUES('script_devs_and_dbs','    SELECT @line = "   NAME = " + CHAR(39) + @name + CHAR(39) + CHAR(44)')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT @line')
INSERT scripts 
VALUES('script_devs_and_dbs','    SELECT @line = "   PHYSNAME = " + CHAR(39) + @phyname + CHAR(39) + CHAR(44)')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT @line')
INSERT scripts 
VALUES('script_devs_and_dbs','    SELECT @line = "   VDEVNO = " + @vdevno + CHAR(44)')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT @line')
INSERT scripts 
VALUES('script_devs_and_dbs','    SELECT @line = "   SIZE = " + @size')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT @line')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','    IF @name = "master" PRINT "*****/"')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT "GO"')
INSERT scripts 
VALUES('script_devs_and_dbs','    PRINT ""')
INSERT scripts 
VALUES('script_devs_and_dbs','    FETCH NEXT FROM object_cursor INTO @name, @phyname, @vdevno, @size')
INSERT scripts 
VALUES('script_devs_and_dbs','  END')
INSERT scripts 
VALUES('script_devs_and_dbs','DEALLOCATE object_cursor')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "          /*============ DATABASES SCRIPTS ==============*/"')
INSERT scripts 
VALUES('script_devs_and_dbs','EXEC sp_help_revdatabase')
INSERT scripts 
VALUES('script_devs_and_dbs','PRINT "          /*================== END ======================*/"')