Search this insane blog:

Friday, April 30, 2010

Sharepoint Services on Vista? Hmm! Worth the try!~

I hear there is a registry hack (cough cough)  for Sharepoint Services install on Vista.
I think I'll try it next time I have...errr.. time?

http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2008/05/21/how-to-install-windows-sharepoint-services-3-0-sp1-on-vista-x64-x86.aspx

Tuesday, April 27, 2010

send email

this evaluates jobs:

declare @tableHTML nvarchar(max) ,
@hdr varchar(max) ;

--------------------------
select case recent_jobs.run_status
when 1 then 'YES'
when 0 then 'NO'
end as run_status, msdb.dbo.sysjobs.name, msg.message, msg.run_date
into [#t]
from (
select max(instance_id) as [MOST RECENT], job_id, server,
run_status
from msdb.dbo.sysjobhistory
group by job_id, server, run_status
) as recent_jobs
inner join msdb.dbo.sysjobs
on recent_jobs.job_id = msdb.dbo.sysjobs.job_id
inner join msdb.dbo.sysjobhistory as msg
on recent_jobs.[MOST RECENT] = msg.instance_id
where ( msdb.dbo.sysjobs.enabled = 1 )

--------------------------

set @hdr = ( N'

Recent SQL Server Job Run

' + N'
<><><><><><>' + N' <><><><><><>' + N' <><><><><><>' ) select @tableHTML = @hdr + cast(( select td = #t.run_status, '', td = #t.name, '', td = #t.message, '', td = #t.run_date, '' from #t for xml path('tr') , type ) as nvarchar(max)) + N'
OKnamemessagedate
' ;

exec msdb.dbo.sp_send_dbmail @recipients = 'it@nationalraisin.com',
@subject = 'SQL Daily Status Report', @body = @tableHTML,
@body_format = 'HTML' ;

drop table #t

Friday, April 23, 2010

Seriously! (Severity in Error Messages) Take time to be careful

—- use the master database

SELECT error, severity, dlevel,
[description]

FROM sysmessagesWHERE
(msglangid = 1033)

-- hint-hint: the msglangid =1033 is for English..
You can use this list of errors and severities to make sure your scripts are neat and clean.

Function
Description
ERROR_NUMBER() Returns the number of the error
ERROR_SEVERITY() Returns the severity
ERROR_STATE() Returns the error state number
ERROR_PROCEDURE() Returns the name of the stored procedure or trigger where the error occurred
ERROR_LINE() Returns the line number inside the routine that caused the error
ERROR_MESSAGE() Returns the complete text of the error message. The text includes the values supplied for any substitutable parameters, such as lengths, object names, or times





Thursday, April 22, 2010

Poop Duty

Erin snapped this as she waited for the bus. Man, the things governmental officials do for our safety.
Sent via BlackBerry by AT&T

Ava and Pompey

Finally, Ava is settling in and is snuggling like crazy. Her agility with the other dogs is getting better! I'm dying to get back into the saddle and train her for confirmation... I want to get the champion into her and out in the ring.
Sent via BlackBerry by AT&T

Tuesday, April 20, 2010

loop through records

-- runningCaseTotal


DECLARE @rowcount INT,
@item_no VARCHAR(20),
@id INT -- identity key to track rows with
SET @rowcount = (SELECT COUNT(*) FROM dbo.production_availability_ready_not_ready)
-----------------------------
--UPDATE dbo.production_availability_ready_not_ready
--SET runningCaseTotal = NULL
-----------------------------

WHILE @rowcount>0
BEGIN
-------TESTING-----------------
--PRINT 'ROWCOUNT: ' + CONVERT(VARCHAR(20),@rowcount)
--SET @id = (SELECT TOP 1 id FROM dbo.production_availability_ready_not_ready WHERE runningCaseTotal IS null)
--PRINT '..processing @id ' + CONVERT(VARCHAR(20),@id)
--SET @item_no = (SELECT [Item No_] FROM dbo.production_availability_ready_not_ready WHERE id = @id)
--UPDATE dbo.production_availability_ready_not_ready SET runningCaseTotal = 0 WHERE id = @id
--PRINT 'item_no: ' + CONVERT(VARCHAR(20),@item_no)
--PRINT '---------'
-----------------------------




SET @rowcount = @rowcount-1;


END

Thursday, April 15, 2010

Whozits & Whatzit: Managing SQL Server email Accounts

/*
I don't know who or where I got this one.
this gives you all the email accounts listed on your SQL Server.
*/
CREATE TABLE #temp01
(
profile_id INT,
[name] VARCHAR(50),
description VARCHAR(50)
)
INSERT INTO #temp01
EXECUTE msdb.dbo.sysmail_help_profile_sp ;
CREATE TABLE #temp02
(
profile_id INT,
profile_name VARCHAR(50),
account_id INT,
account_name VARCHAR(50),
seq int
)
INSERT INTO #temp02
EXECUTE msdb.dbo.sysmail_help_profileaccount_sp ;
CREATE TABLE #temp03
(
account_id INT,
[name] VARCHAR(50),
description VARCHAR(50),
email_address VARCHAR(50),
display_name VARCHAR(50),
replyto_address VARCHAR(50),
servertype VARCHAR(50),
servername VARCHAR(50),
port INT,
username VARCHAR(50),
use_default_credentials VARCHAR(50),
enable_ssl int
)
INSERT INTO #temp03
EXECUTE msdb.dbo.sysmail_help_account_sp ;
SELECT a.name,
b.account_name,
c.description,
c.email_address,
c.display_name,
c.replyto_address,
c.servertype,
c.servername,
c.port,
c.username,
c.use_default_credentials,
c.enable_ssl
FROM [#temp01] AS a
INNER JOIN [#temp02] AS b ON a.profile_id = b.[profile_id]
INNER JOIN [#temp03] AS c ON b.account_id = c.account_id
DROP TABLE #temp01
DROP TABLE #temp02
DROP TABLE [#temp03]

whaa? Differential won't restore? (what bloke backed up last)

/*
We had to restore a full backup and a differential backup a while ago
To a local db to get some old data put back into the live database.
my manager & I had a heck of a time trying to find out where someone put the last back up.


This query helped us know a utility was still backing up to another location AFTER the job ran...
hence all the extents the DIFF were looking for were bye-bye into the rogue, full-backup.
*/

-------------copy below this line-----------------------

declare
@startDate DATETIME,
@endDate DATETIME,
@database sysname


-- enter your database and date range here:
select
@database = 'SSRC_V5SP1-2',
@startDate = '09/28/09',
@endDate = '09/30/09'


SELECT b.database_name,
b.backup_start_date,
b.backup_finish_date,
b.user_name,
f.logical_name,
f.physical_name,
mf.physical_device_name,
f.file_type,
f.file_size,
b.backup_size
FROM msdb.dbo.backupfile f,
msdb.dbo.backupset b,
msdb.dbo.backupmediafamily mf
WHERE f.backup_set_id = b.backup_set_id
AND b.media_set_id = mf.media_set_id
AND b.backup_start_date BETWEEN @startDate
AND @endDate
AND b.database_name = COALESCE
(@database,database_name)
ORDER BY b.database_name,
b.backup_start_date

SSRS: What reports do I have uploaded?


/*
this refers to a linked server called myServer
if you don't have a linked server remove the text "myServer."
*/
SELECT
CASE C_1.TYPE
WHEN 2 THEN 'Report'
  WHEN 3 THEN 'Resource'  WHEN 4 THEN 'Linked Report'  WHEN 5 THEN 'Data Source' ELSE 'unknown'
  END AS TypeOfReport,

C_1.ItemID,
C_1.Path,
C_1.Name,
C_1.ParentID,
C_1.Type,
C_1.[Content],
C_1.Intermediate,
C_1.SnapshotDataID,
C_1.LinkSourceID,
C_1.Property,
C_1.Description,
C_1.Hidden,
C_1.CreatedByID,
C_1.CreationDate,
C_1.ModifiedByID,
C_1.ModifiedDate,
C_1.MimeType,
C_1.SnapshotLimit,
C_1.Parameter,
C_1.PolicyID,
C_1.PolicyRoot,
C_1.ExecutionFlag,
C_1.ExecutionTime,
R.ItemID AS Expr1,
R.Name AS Expr2,
R.id,
R.primary_rs_reports_id,
R.ManagerViewOnly,
R.HasDollars,
R.add_date
FROM nrdev1.ReportServer.dbo.Catalog AS C_1
LEFT
OUTER
JOIN admin_primary_rs_reports AS R

ON C_1.ItemID=R.ItemID
WHERE
(C_1.Path LIKE
'/%')