Monday, October 3, 2016
Could not load file or assembly or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
If all the subprojects are on the right version check the app pool.
Wednesday, July 20, 2016
Monday, May 16, 2016
SQL Server Last Restore Time
-- Last Restore time
WITH LastRestores AS
(
SELECT
DatabaseName = [d].[name] ,
[d].[create_date] ,
[d].[compatibility_level] ,
[d].[collation_name] ,
r.*,
RowNum = ROW_NUMBER() OVER (PARTITION BY d.Name ORDER BY r.[restore_date] DESC)
FROM master.sys.databases d
LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = d.Name
)
SELECT *
FROM [LastRestores]
WHERE [RowNum] = 1
Tuesday, March 15, 2016
ASPState DB
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
aspnet_regsql.exe -ssadd -sstype p -S server\instance -U sa -P somePass
Wednesday, January 6, 2016
Entity Framework (EF) 6 (or at least 6.13) Error - Missing Primary Keys
In the past EF would blow up when trying to make an *.edmx file on a table with no PK. As of EF 6 (or at least 6.13) it allows them but the result set returned when performing a join on a table will this version can/will be incorrect.
A deadly, but silent, error.
A deadly, but silent, error.
SQL Server Finding the Object Alter Date
select TOP 1 * from sys.procedures order by create_date desc
select TOP 1 * from sys.tables order by create_date desc
select TOP 1 * from sys.views order by create_date desc
/*
CREATE PROC jkAlterProcTest
AS
SELECT 1
CREATE TABLE jkAlterTableTest (a int)
CREATE VIEW jkAlterViewTest
AS
SELECT a
FROM jkAlterTableTest
ALTER PROC jkAlterProcTest
AS
SELECT 2
ALTER TABLE jkAlterTableTest ADD b int
ALTER VIEW jkAlterViewTest
AS
SELECT a, b
FROM jkAlterTableTest
*/
select TOP 1 * from sys.tables order by create_date desc
select TOP 1 * from sys.views order by create_date desc
/*
CREATE PROC jkAlterProcTest
AS
SELECT 1
CREATE TABLE jkAlterTableTest (a int)
CREATE VIEW jkAlterViewTest
AS
SELECT a
FROM jkAlterTableTest
ALTER PROC jkAlterProcTest
AS
SELECT 2
ALTER TABLE jkAlterTableTest ADD b int
ALTER VIEW jkAlterViewTest
AS
SELECT a, b
FROM jkAlterTableTest
*/
Wednesday, October 14, 2015
Enable CLR for db / user
MAKE SURE YOU ARE TARGETING THE CORRECT DB
For instance - DNN and not Person
USE dbFoo;
GO;
EXEC
sp_changedbowner 'sa'
GO;
ALTER DATABASE dbFoo
SET TRUSTWORTHY ON;
GO;
USE MASTER;
GO;
GRANT EXTERNAL
ACCESS ASSEMBLY TO [domain\userBar]; -- note: server-wide
GO;
USE dbFoo;
GO;
sp_configure 'show advanced options',
1;
GO;
RECONFIGURE WITH OVERRIDE;
GO;
sp_configure 'clr enabled', 1;
GO;
RECONFIGURE WITH OVERRIDE;
GO;
Thursday, September 3, 2015
Disable Aero Shake, Win 7; All Windows Automagically Minimizing
http://www.howtogeek.com/howto/windows-7/disable-aero-shake-in-windows-7/
Disable Aero Shake in Windows 7
One of the interesting new features in Windows 7 is the way you can grab a window by the title bar and “shake” it back and forth to minimize everything else. It’s a fun feature, but just in case you want to disable it we’ve got the solution for you.
Disable Aero Shake Manual Registry Hack
Open up regedit.exe through the start menu search or run box, and then navigate down to the following key:
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows
Once you are there, right-click on the Windows key and create a new key called Explorer.
Now right-click on the right-hand side, create a new 32-bit DWORD with the following settings:
- Name: NoWindowMinimizingShortcuts
- Value: 1
Once you’ve created this, you should log off and back on for the change to take effect.
Downloadable Registry Hack
Simply download, extract, and double-click on DisableAeroShake.reg to enter the information into the registry. To re-enable use the other file.
Prevent RDC from Logging Out Your Active Session When Logging In from Another Box
Credit: Brian Trexler
"I think I found the incredibly annoying setting that logs
you out (and closes your active work) when disconnecting a Remote Desktop
Session on Windows 7! I’ve been determined to slay this dragon.
I’m going to keep an eye on this to ensure it sticks and
never logs me out. Let me know what you guys find.
Here is the maximum setting for “MaxDisconnectionTime”…"
Back up the registry, navigate to:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\
Change (decimal) value for MaxDisconnectionTime to 4294967295
Wednesday, August 26, 2015
VBA Pattern Matching with the Levenshtein Algorithm
Public Sub match()
'MsgBox ("asdfs")
For i = 3 To 200
If (Cells(i, 2).Value <> "") Then
If (Trim(UCase(Cells(i, 2).Value)) = Trim(UCase(Cells(i, 3).Value))) _
And (Trim(UCase(Cells(i, 4).Value)) = Trim(UCase(Cells(i, 5).Value))) _
And (Trim(UCase(Cells(i, 6).Value)) = Trim(UCase(Cells(i, 7).Value))) _
And (Trim(UCase(Cells(i, 8).Value)) = Trim(UCase(Cells(i, 9).Value))) _
Then
Cells(i, 13).Value = "Y"
Else
Cells(i, 13).Value = "N"
End If
Cells(i, 14).Value = Levenshtein(Cells(i, 2).Value, Cells(i, 3).Value)
Cells(i, 15).Value = Levenshtein(Cells(i, 4).Value, Cells(i, 5).Value)
Cells(i, 16).Value = Levenshtein(Cells(i, 6).Value, Cells(i, 7).Value)
Cells(i, 17).Value = Levenshtein(Cells(i, 8).Value, Cells(i, 9).Value)
Cells(i, 18).Value = Cells(i, 14).Value + Cells(i, 15).Value + Cells(i, 16).Value + Cells(i, 17).Value
Else
Cells(i, 13).Value = ""
Cells(i, 14).Value = ""
Cells(i, 15).Value = ""
Cells(i, 16).Value = ""
Cells(i, 17).Value = ""
Cells(i, 18).Value = ""
End If
' Write sql
' Good ones
If ((Cells(i, 13).Value = "Y") Or (Cells(i, 18).Value < 5)) And (Cells(i, 2).Value <> "") Then
' Likely good
' If (Cells(i, 18).Value > 4) (Cells(i, 18).Value < 10) Then
writeSQL (i)
' the names are an exact match but there is not city/state/zip information
' this is the case with a lot of the SMO_2015_Voting_Member_List ones
ElseIf (UCase(Trim(Cells(i, 2).Value)) = UCase(Trim(Cells(i, 3).Value))) _
And UCase(Trim((Cells(i, 4).Value)) = UCase(Trim(Cells(i, 5).Value))) _
And UCase(Trim((Cells(i, 6).Value)) = "NULL") _
And UCase(Trim((Cells(i, 8).Value)) = "NULL") _
And UCase(Trim((Cells(i, 10).Value)) = "NULL") Then
writeSQLNULL (i)
Else
Cells(i, 20).Value = ""
Cells(i, 21).Value = ""
End If
Next i
End Sub
Function Levenshtein(ByVal string1 As String, ByVal string2 As String) As Long
'https://en.wikipedia.org/wiki/Levenshtein_distance
'http://stackoverflow.com/questions/4243036/levenshtein-distance-in-excel
string1 = UCase(Trim(string1))
string2 = UCase(Trim(string2))
Dim i As Long, j As Long
Dim string1_length As Long
Dim string2_length As Long
Dim distance() As Long
string1_length = Len(string1)
string2_length = Len(string2)
ReDim distance(string1_length, string2_length)
For i = 0 To string1_length
distance(i, 0) = i
Next
For j = 0 To string2_length
distance(0, j) = j
Next
For i = 1 To string1_length
For j = 1 To string2_length
If Asc(Mid$(string1, i, 1)) = Asc(Mid$(string2, j, 1)) Then
distance(i, j) = distance(i - 1, j - 1)
Else
distance(i, j) = Application.WorksheetFunction.Min _
(distance(i - 1, j) + 1, _
distance(i, j - 1) + 1, _
distance(i - 1, j - 1) + 1)
End If
Next
Next
Levenshtein = distance(string1_length, string2_length)
End Function
Function writeSQL(ByVal i As Integer)
Dim customer As String, firstName As String, lastName As String, _
city As String, state As String, zip As String, _
_id As String, sqlSelect As String, sqlUpdate As String
customer = RTrim(Cells(i, 1).Value)
firstName = RTrim(Cells(i, 3).Value)
lastName = RTrim(Cells(i, 5).Value)
city = RTrim(Cells(i, 6).Value)
state = RTrim(Cells(i, 8).Value)
zip = RTrim(Cells(i, 10).Value)
_id = RTrim(Right("0000000000000" & Cells(i, 12).Value, 12))
sqlSelect = "-- SELECT * FROM ca WHERE ca.firstName = '" + _
firstName + "' AND ca.lastName = '" + lastName + "' AND city = '" + city + _
"' AND [state] = '" + state + "' AND zip = '" + zip + "'"
sqlUpdate = "' -- UPDATE ca SET ca.Member = 40, ca. = '" + _id + _
"' FROM ca WHERE ca.firstName = '" + firstName + "' AND " + _
"ca.lastName = '" + lastName + "' AND city = '" + city + "' AND [state] = '" + state + _
"' AND zip = '" + zip + "' AND customer = '" + customer + "'"
If (firstName = "firstName") Then
Cells(i, 20).Value = ""
Cells(i, 21).Value = ""
Rows(i).Interior.Color = 45535
Else
'Cells(i, 20).Value = sqlSelect
Cells(i, 20).Value = ""
Cells(i, 21).Value = sqlUpdate
Rows(i).Interior.Color = 65535
End If
End Function
Function writeSQLNULL(ByVal i As Integer)
Dim customer As String, firstName As String, lastName As String, _
city As String, state As String, zip As String, _
ship_master_customer_id As String, sqlSelect As String, sqlUpdate As String
customer = Cells(i, 1).Value
firstName = Cells(i, 3).Value
lastName = Cells(i, 5).Value
city = Cells(i, 6).Value
state = Cells(i, 8).Value
zip = Cells(i, 10).Value
_id = Right("0000000000000" & Cells(i, 12).Value, 12)
sqlSelect = "-- SELECT * FROM ca WHERE ca.firstName = '" + _
firstName + "' AND ca.lastName = '" + lastName + "' AND city = '" + city + _
"' AND [state] = '" + state + "' AND zip = '" + zip + "'"
sqlUpdate = "' -- UPDATE ca SET ca.Member = 40, ca.= '" + _id + _
"' FROM ca ca WHERE ca.firstName = '" + firstName + "' AND " + _
"ca.lastName = '" + lastName + "' AND city IS NULL AND [state] IS NULL AND zip IS NULL AND customer = '" + customer + "'"
If (firstName = "firstName") Then
Cells(i, 20).Value = ""
Cells(i, 21).Value = ""
Rows(i).Interior.Color = 45535
Else
'Cells(i, 20).Value = sqlSelect
Cells(i, 20).Value = ""
Cells(i, 21).Value = sqlUpdate
Rows(i).Interior.Color = 65535
End If
End Function
'MsgBox ("asdfs")
For i = 3 To 200
If (Cells(i, 2).Value <> "") Then
If (Trim(UCase(Cells(i, 2).Value)) = Trim(UCase(Cells(i, 3).Value))) _
And (Trim(UCase(Cells(i, 4).Value)) = Trim(UCase(Cells(i, 5).Value))) _
And (Trim(UCase(Cells(i, 6).Value)) = Trim(UCase(Cells(i, 7).Value))) _
And (Trim(UCase(Cells(i, 8).Value)) = Trim(UCase(Cells(i, 9).Value))) _
Then
Cells(i, 13).Value = "Y"
Else
Cells(i, 13).Value = "N"
End If
Cells(i, 14).Value = Levenshtein(Cells(i, 2).Value, Cells(i, 3).Value)
Cells(i, 15).Value = Levenshtein(Cells(i, 4).Value, Cells(i, 5).Value)
Cells(i, 16).Value = Levenshtein(Cells(i, 6).Value, Cells(i, 7).Value)
Cells(i, 17).Value = Levenshtein(Cells(i, 8).Value, Cells(i, 9).Value)
Cells(i, 18).Value = Cells(i, 14).Value + Cells(i, 15).Value + Cells(i, 16).Value + Cells(i, 17).Value
Else
Cells(i, 13).Value = ""
Cells(i, 14).Value = ""
Cells(i, 15).Value = ""
Cells(i, 16).Value = ""
Cells(i, 17).Value = ""
Cells(i, 18).Value = ""
End If
' Write sql
' Good ones
If ((Cells(i, 13).Value = "Y") Or (Cells(i, 18).Value < 5)) And (Cells(i, 2).Value <> "") Then
' Likely good
' If (Cells(i, 18).Value > 4) (Cells(i, 18).Value < 10) Then
writeSQL (i)
' the names are an exact match but there is not city/state/zip information
' this is the case with a lot of the SMO_2015_Voting_Member_List ones
ElseIf (UCase(Trim(Cells(i, 2).Value)) = UCase(Trim(Cells(i, 3).Value))) _
And UCase(Trim((Cells(i, 4).Value)) = UCase(Trim(Cells(i, 5).Value))) _
And UCase(Trim((Cells(i, 6).Value)) = "NULL") _
And UCase(Trim((Cells(i, 8).Value)) = "NULL") _
And UCase(Trim((Cells(i, 10).Value)) = "NULL") Then
writeSQLNULL (i)
Else
Cells(i, 20).Value = ""
Cells(i, 21).Value = ""
End If
Next i
End Sub
Function Levenshtein(ByVal string1 As String, ByVal string2 As String) As Long
'https://en.wikipedia.org/wiki/Levenshtein_distance
'http://stackoverflow.com/questions/4243036/levenshtein-distance-in-excel
string1 = UCase(Trim(string1))
string2 = UCase(Trim(string2))
Dim i As Long, j As Long
Dim string1_length As Long
Dim string2_length As Long
Dim distance() As Long
string1_length = Len(string1)
string2_length = Len(string2)
ReDim distance(string1_length, string2_length)
For i = 0 To string1_length
distance(i, 0) = i
Next
For j = 0 To string2_length
distance(0, j) = j
Next
For i = 1 To string1_length
For j = 1 To string2_length
If Asc(Mid$(string1, i, 1)) = Asc(Mid$(string2, j, 1)) Then
distance(i, j) = distance(i - 1, j - 1)
Else
distance(i, j) = Application.WorksheetFunction.Min _
(distance(i - 1, j) + 1, _
distance(i, j - 1) + 1, _
distance(i - 1, j - 1) + 1)
End If
Next
Next
Levenshtein = distance(string1_length, string2_length)
End Function
Function writeSQL(ByVal i As Integer)
Dim customer As String, firstName As String, lastName As String, _
city As String, state As String, zip As String, _
_id As String, sqlSelect As String, sqlUpdate As String
customer = RTrim(Cells(i, 1).Value)
firstName = RTrim(Cells(i, 3).Value)
lastName = RTrim(Cells(i, 5).Value)
city = RTrim(Cells(i, 6).Value)
state = RTrim(Cells(i, 8).Value)
zip = RTrim(Cells(i, 10).Value)
_id = RTrim(Right("0000000000000" & Cells(i, 12).Value, 12))
sqlSelect = "-- SELECT * FROM ca WHERE ca.firstName = '" + _
firstName + "' AND ca.lastName = '" + lastName + "' AND city = '" + city + _
"' AND [state] = '" + state + "' AND zip = '" + zip + "'"
sqlUpdate = "' -- UPDATE ca SET ca.Member = 40, ca. = '" + _id + _
"' FROM ca WHERE ca.firstName = '" + firstName + "' AND " + _
"ca.lastName = '" + lastName + "' AND city = '" + city + "' AND [state] = '" + state + _
"' AND zip = '" + zip + "' AND customer = '" + customer + "'"
If (firstName = "firstName") Then
Cells(i, 20).Value = ""
Cells(i, 21).Value = ""
Rows(i).Interior.Color = 45535
Else
'Cells(i, 20).Value = sqlSelect
Cells(i, 20).Value = ""
Cells(i, 21).Value = sqlUpdate
Rows(i).Interior.Color = 65535
End If
End Function
Function writeSQLNULL(ByVal i As Integer)
Dim customer As String, firstName As String, lastName As String, _
city As String, state As String, zip As String, _
ship_master_customer_id As String, sqlSelect As String, sqlUpdate As String
customer = Cells(i, 1).Value
firstName = Cells(i, 3).Value
lastName = Cells(i, 5).Value
city = Cells(i, 6).Value
state = Cells(i, 8).Value
zip = Cells(i, 10).Value
_id = Right("0000000000000" & Cells(i, 12).Value, 12)
sqlSelect = "-- SELECT * FROM ca WHERE ca.firstName = '" + _
firstName + "' AND ca.lastName = '" + lastName + "' AND city = '" + city + _
"' AND [state] = '" + state + "' AND zip = '" + zip + "'"
sqlUpdate = "' -- UPDATE ca SET ca.Member = 40, ca.= '" + _id + _
"' FROM ca ca WHERE ca.firstName = '" + firstName + "' AND " + _
"ca.lastName = '" + lastName + "' AND city IS NULL AND [state] IS NULL AND zip IS NULL AND customer = '" + customer + "'"
If (firstName = "firstName") Then
Cells(i, 20).Value = ""
Cells(i, 21).Value = ""
Rows(i).Interior.Color = 45535
Else
'Cells(i, 20).Value = sqlSelect
Cells(i, 20).Value = ""
Cells(i, 21).Value = sqlUpdate
Rows(i).Interior.Color = 65535
End If
End Function
Thursday, August 6, 2015
FYI: Resolution - Build / Compile Issues - The XML namespace for the conceptual model's Schema element is not supported on this project's target framework version
Apparently when compiled w/ a 2012 vs. a 2013 it IDE
(minimum known is “Premium”) it will no longer play nicely yielding many rabbit
holes and a rather generic error of “The XML namespace for the conceptual
model's Schema element is not supported on this project's target framework
version”.
Wednesday, August 5, 2015
Force Restart Over RDC
http://www.fixedbyvonnie.com/2013/11/shutdown-restart-windows-remote-desktop-connection/
How to shutdown or restart Windows over a Remote Desktop connection
I would love the world to think of me as an industrious, prolific IT director and blogger; however, I’ve finally avowed this one truth:
I’m lazy.
Yep. Why hide it. It’s true.
I like to take the easy way out, the path of least resistance, and I have a propensity to be dormant unless someone lights a flame under my butt.
My indolence is precisely what makes programs like Remote Desktop such a joy to use. Why should I get up and walk over to a server when I can remotely connect to it from the comfort of my desk? Remote Desktop lets me access almost any Windows computer on my network and gives me the feeling of sitting right there in front of the box.
A bunch of smart people at Microsoft concocted the Remote Desktop Protocol (RDP), and with the advent ofWindows XP, Microsoft began bundling the Remote Desktop Connection (RDC) with ever OS since.
The RDC client is great because it supports cool features like 24-bit color, audio, and file system redirection. So, for example, you can open a Youtube video on the remote computer and hear the audio on your local machine. Or you can access the files on your local machine from the remote machine. All this magic is made possible through the RDP and what Microsoft calls the Terminal Services client (mstsc.exe).
Whenever you connect to a Microsoft Server, the Shutdown and Restart buttons are visible in the little arrow immediately to the right of the lock icon.
But you might be wondering how to do the same thing when opening a remote connection on a Windows 7 box.
As you can see, there’s only a Lock and Disconnect option but no Shutdown or Restart function.
To restart the remote computer, click the Start button and enter this command in the search box:
shutdown /r /t 0
The /r switch tells the machine to reboot and the /t option sets the number of seconds to execute the command. Since we set /t to zero, the restart should initiate immediately.
To shutdown the machine just enter:
shutdown /s
The other option is to just to click the Desktop and press Alt + F4 to bring up the shutdown menu.
Finally, if you execute the shutdown command but then suddenly realize you made a mistake type:
shutdown /a
This will attempt to abort the shutdown sequence.
Tuesday, August 4, 2015
Find the BAK, MDF and LDF Files
-- Find the BAK files:
SELECT physical_device_name,
backup_start_date,
backup_finish_date,
backup_size/1024.0 BackupSizeKB
FROM msdb.dbo.backupset b
JOIN msdb.dbo.backupmediafamily m ON b.media_set_id = m.media_set_id
WHERE database_name like '%%'
ORDER BY backup_finish_date DESC
-- Find the MDF's and LDF's:
DECLARE @command varchar(1000)
SELECT @command = 'SELECT * FROM sys.database_files'
EXEC sp_MSforeachdb @command
-- Or ... easier
EXEC sp_MSforeachdb 'USE ? SELECT ''?'', SF.filename, SF.size FROM sys.sysfiles SF'
SELECT physical_device_name,
backup_start_date,
backup_finish_date,
backup_size/1024.0 BackupSizeKB
FROM msdb.dbo.backupset b
JOIN msdb.dbo.backupmediafamily m ON b.media_set_id = m.media_set_id
WHERE database_name like '%%'
ORDER BY backup_finish_date DESC
-- Find the MDF's and LDF's:
DECLARE @command varchar(1000)
SELECT @command = 'SELECT * FROM sys.database_files'
EXEC sp_MSforeachdb @command
-- Or ... easier
EXEC sp_MSforeachdb 'USE ? SELECT ''?'', SF.filename, SF.size FROM sys.sysfiles SF'
-- Or ... even easier
SELECT 'USE [' + name + ']; SELECT SF.filename, SF.size FROM sys.sysfiles SF'
FROM master.dbo.sysdatabases Thursday, July 30, 2015
Dropping Global Temp Tables
-- A better question is why are you using global temp tables in the first place???
IF OBJECT_ID('tempdb..##badge_updt') IS NOT NULL DROP TABLE ##badge_updt
IF OBJECT_ID('tempdb..##badge_updt') IS NOT NULL DROP TABLE ##badge_updt
Wednesday, July 29, 2015
TFS Hidden Workspace Solution
-
Q:
When creating a new build in Team
Foundation Server, I get the following error when attempting to run the new
build:
The path
C:\Build\ProductReleases\FullBuildv5.4.2x\Sources is already mapped to
workspace BuildServer_23.
I am unable to see a workspace by that
name in the workspaces dialog.
|
|
|
|
Monday, July 27, 2015
PowerShell - Find All Files of Type by Date
$limit = (Get-Date).AddDays(-15)
#$path = "C:\Some\Path"
$path = "C:\Temp"
# Delete files older than the $limit.
# Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit -and $_.Extension -eq ".txt" }
$limit = (Get-Date).AddDays(-1)
$path = "C:\Temp"
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit -and $_.Extension -eq ".BAK" }
#$path = "C:\Some\Path"
$path = "C:\Temp"
# Delete files older than the $limit.
# Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit -and $_.Extension -eq ".txt" }
$limit = (Get-Date).AddDays(-1)
$path = "C:\Temp"
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit -and $_.Extension -eq ".BAK" }
What Are the Sizes of My Databases?
with fs
as
(
select database_id, type, size * 8.0 / 1024 size
from sys.master_files
)
select
name,
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeMB,
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB
from sys.databases db
as
(
select database_id, type, size * 8.0 / 1024 size
from sys.master_files
)
select
name,
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeMB,
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB
from sys.databases db
Where Are my Backups?
SELECT physical_device_name,
backup_start_date,
backup_finish_date,
backup_size/1024.0 BackupSizeKB
FROM msdb.dbo.backupset b
JOIN msdb.dbo.backupmediafamily m ON b.media_set_id = m.media_set_id
WHERE database_name like '%%'
ORDER BY backup_finish_date DESC
backup_start_date,
backup_finish_date,
backup_size/1024.0 BackupSizeKB
FROM msdb.dbo.backupset b
JOIN msdb.dbo.backupmediafamily m ON b.media_set_id = m.media_set_id
WHERE database_name like '%%'
ORDER BY backup_finish_date DESC
Wednesday, July 22, 2015
Fun With Powershell - Copy All Unique Files and Grab the Top X Lines
#change the prompt
function prompt { "Posh >" ; return " " }
#copy locally all unique file names
#Make the script file to Get just the top few lines
Get-ChildItem -Path C:\temp\ExperiantRegistration\ -Filter "*.txt" | ForEach-Object {"Get-Content " + """" + $_.FullName + """ -totalcount 3" > getHeaders.ps1}
function prompt { "Posh >" ; return " " }
#copy locally all unique file names
Get-ChildItem -Path \\server\ARC\Exp\AM\ -Recurse -Filter "*.txt" | ForEach-Object {"Copy " + $_.FullName + " ""\\Dest\temp\ExperiantRegistration\" + $_.Name + " " + $_.LastWriteTime + ".txt""" -replace ":", "" -replace "/", "" >> copyLocal.bat}
#Make the script file to Get just the top few lines
Get-ChildItem -Path C:\temp\ExperiantRegistration\ -Filter "*.txt" | ForEach-Object {"Get-Content " + """" + $_.FullName + """ -totalcount 3" > getHeaders.ps1}
Tuesday, July 14, 2015
Find Tables with Column Named
SELECT
c.name
, t.name
FROM sys.tables t
JOIN sys.columns c
ON t.object_id = c.object_id
WHERE c.name like '%sub%topi%' -- OBJ%' -- NOTE%'
ORDER BY
c.name
, t.name
c.name
, t.name
FROM sys.tables t
JOIN sys.columns c
ON t.object_id = c.object_id
WHERE c.name like '%sub%topi%' -- OBJ%' -- NOTE%'
ORDER BY
c.name
, t.name
Friday, July 10, 2015
SQL Server - Is DB Still Restoring?
SELECT DATABASEPROPERTYEX ('DBName', 'Status')
SELECT session_id SPID
, command
, a.text Query
, start_time
, percent_complete
, dateadd(second,estimated_completion_time/1000, getdate()) estimated_completion_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
WHERE r.command in ('BACKUP DATABASE','RESTORE DATABASE')
SELECT session_id SPID
, command
, a.text Query
, start_time
, percent_complete
, dateadd(second,estimated_completion_time/1000, getdate()) estimated_completion_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
WHERE r.command in ('BACKUP DATABASE','RESTORE DATABASE')
Wednesday, June 17, 2015
Find Table in Multiple Databases
http://stackoverflow.com/questions/610609/find-a-table-across-multiple-databases-sql-server-2005
sp_MSforeachdb 'USE ?
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N''[table_name_here]'') AND OBJECTPROPERTY(id, N''IsUserTable'') = 1)
BEGIN
PRINT ''Found in db ?''
END'
Or ...
USE master
GO
SELECT 'USE [' + name + '] ' + CHAR (13) + CHAR (10)
+ 'GO ' + CHAR (13) + CHAR (10)
+ 'SET NOCOUNT ON; SELECT DB_NAME(); SELECT name FROM sysobjects WHERE type = ''U'' AND name = ''some_table'' '
+ CHAR (13)
FROM sysdatabases
Monday, June 15, 2015
Find tables with foreign keys.
Source: http://stackoverflow.com/questions/483193/how-can-i-list-all-foreign-keys-referencing-a-given-table-in-sql-server
SELECT t.name TableWithForeignKey
, fk.constraint_column_id FK_PartNo
, c.name ForeignKeyColumn
FROM sys.foreign_key_columns fk
JOIN sys.tables t
ON fk.parent_object_id = t.[object_id]
JOIN sys.columns c
ON fk.parent_object_id = c.[object_id]
AND fk.parent_column_id = c.column_id
JOIN sys.tables t1
ON fk.referenced_object_id = t1.[object_id]
ORDER BY
TableWithForeignKey
, FK_PartNo
Source: http://stackoverflow.com/questions/483193/how-can-i-list-all-foreign-keys-referencing-a-given-table-in-sql-server
SELECT t.name TableWithForeignKey
, fk.constraint_column_id FK_PartNo
, c.name ForeignKeyColumn
FROM sys.foreign_key_columns fk
JOIN sys.tables t
ON fk.parent_object_id = t.[object_id]
JOIN sys.columns c
ON fk.parent_object_id = c.[object_id]
AND fk.parent_column_id = c.column_id
JOIN sys.tables t1
ON fk.referenced_object_id = t1.[object_id]
ORDER BY
TableWithForeignKey
, FK_PartNo
Tuesday, April 21, 2015
Tuesday, November 19, 2013
SSIS/SQLAgent - Enable User to See and Start Jobs
To see, the user must be in the SQLAgentReaderRole or SQLAgentUserRole, to start them the user must be in the SQLAgentOperaterRole. As these only exist in MSDB then the user must also be a member there.
Friday, November 8, 2013
Get and record all browser and session values
public static void recordUserVariables()
{
string sessionId = System.Web.HttpContext.Current.Session.SessionID,
sameSessionId = UtilFns.Common.GetSessionVariable("userSessionId");
bool recordSession = false;
/// The sess vars are apparently not alwas set when the user first gets to the portal
string temp_ss_Username_aspx = UtilFns.Common.GetSessionVariable("Username_aspx");
string repeatSessionRecording = UtilFns.Common.GetSessionVariable("repeatSessionRecording");
/// The sess vars are apparently not alwas set when the user first gets to the portal
/// so set a flag to repeat this when they are present
if (String.IsNullOrEmpty(temp_ss_Username_aspx))
{
UtilFns.Common.SetSessionVariable("repeatSessionRecording", "1");
}
if (repeatSessionRecording == "1")
{
recordSession = true;
UtilFns.Common.SetSessionVariable("repeatSessionRecording", "0");
}
if (String.IsNullOrEmpty(sameSessionId))
{
recordSession = true;
UtilFns.Common.SetSessionVariable("userSessionId", sessionId);
}
else if (sameSessionId != sessionId)
{
recordSession = true;
}
if (recordSession)
{
/// For recording user values, called from teh home page
string ss_Username_aspx = "",
ss_Email_aspx = "",
ss_IsAdmin_aspx = "",
ss_ActualUsername_aspx = "",
ss_ActualIsAdmin_aspx = "",
ss_FullName2_aspx = "",
ss_HRAdmin = "",
ss_eRF_Agency = "",
ss_BudEntryAlways = "",
sv_APPL_MD_PATH = "",
sv_APPL_PHYSICAL_PATH = "",
sv_AUTH_TYPE = "",
sv_AUTH_USER = "",
sv_INSTANCE_META_PATH = "",
sv_LOCAL_ADDR = "",
sv_LOGON_USER = "",
sv_REMOTE_ADDR = "",
sv_REMOTE_HOST = "",
sv_REMOTE_USER = "",
sv_REQUEST_METHOD = "",
sv_SCRIPT_NAME = "",
sv_SERVER_NAME = "",
sv_SERVER_PORT = "",
sv_SERVER_PROTOCOL = "",
sv_SERVER_SOFTWARE = "",
sv_URL = "",
sv_HTTP_CONNECTION = "",
sv_HTTP_ACCEPT = "",
sv_HTTP_ACCEPT_ENCODING = "",
sv_HTTP_ACCEPT_LANGUAGE = "",
sv_HTTP_COOKIE = "",
sv_HTTP_HOST = "",
sv_HTTP_USER_AGENT = "",
brwsr_computer_name = "",
brwsr_MachineName = "",
brwsr_Type = "",
brwsr_Browser = "",
brwsr_Version = "",
brwsr_MajorVersion = "",
brwsr_MinorVersion = "",
brwsr_Platform = "",
brwsr_Beta = "",
brwsr_Crawler = "",
brwsr_AOL = "",
brwsr_Win16 = "",
brwsr_Win32 = "",
brwsr_Frames = "",
brwsr_Tables = "",
brwsr_Cookies = "",
brwsr_VBScript = "",
brwsr_EcmaScriptVersion = "",
brwsr_JavaApplets = "",
brwsr_ActiveXControls = "",
brwsr_JavaScriptVersion = "";
try
{
ss_Username_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("Username_aspx")))?
UtilFns.Common.GetSessionVariable("Username_aspx"): "";
ss_Email_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("Email_aspx")))?
UtilFns.Common.GetSessionVariable("Email_aspx"): "";
ss_IsAdmin_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("IsAdmin_aspx")))?
UtilFns.Common.GetSessionVariable("IsAdmin_aspx"): "";
ss_ActualUsername_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("Username_aspx")))?
UtilFns.Common.GetSessionVariable("Username_aspx"): "";
ss_ActualIsAdmin_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("ActualIsAdmin_aspx")))?
UtilFns.Common.GetSessionVariable("ActualIsAdmin_aspx"): "";
ss_FullName2_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("FullName2_aspx")))?
UtilFns.Common.GetSessionVariable("FullName2_aspx"): "";
ss_HRAdmin = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("HRAdmin")))?
UtilFns.Common.GetSessionVariable("HRAdmin"): "";
ss_eRF_Agency = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("eRF_Agency")))?
UtilFns.Common.GetSessionVariable("eRF_Agency"): "";
ss_BudEntryAlways = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("BudEntryAlways")))?
UtilFns.Common.GetSessionVariable("BudEntryAlways"): "";
sv_APPL_MD_PATH = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("APPL_MD_PATH")))?
UtilFns.Common.GetServerVariable("APPL_MD_PATH"): "";
sv_APPL_PHYSICAL_PATH = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("APPL_PHYSICAL_PATH")))?
UtilFns.Common.GetServerVariable("APPL_PHYSICAL_PATH"): "";
sv_AUTH_TYPE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("AUTH_TYPE")))?
UtilFns.Common.GetServerVariable("AUTH_TYPE"): "";
sv_AUTH_USER = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("AUTH_USER")))?
UtilFns.Common.GetServerVariable("AUTH_USER"): "";
sv_INSTANCE_META_PATH = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("INSTANCE_META_PATH")))?
UtilFns.Common.GetServerVariable("INSTANCE_META_PATH"): "";
sv_LOCAL_ADDR = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("LOCAL_ADDR")))?
UtilFns.Common.GetServerVariable("LOCAL_ADDR"): "";
sv_LOGON_USER = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("LOGON_USER")))?
UtilFns.Common.GetServerVariable("LOGON_USER"): "";
sv_REMOTE_ADDR = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REMOTE_ADDR")))?
UtilFns.Common.GetServerVariable("REMOTE_ADDR"): "";
sv_REMOTE_HOST = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REMOTE_HOST")))?
UtilFns.Common.GetServerVariable("REMOTE_HOST"): "";
sv_REMOTE_USER = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REMOTE_USER")))?
UtilFns.Common.GetServerVariable("REMOTE_USER"): "";
sv_REQUEST_METHOD = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REQUEST_METHOD")))?
UtilFns.Common.GetServerVariable("REQUEST_METHOD"): "";
sv_SCRIPT_NAME = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SCRIPT_NAME")))?
UtilFns.Common.GetServerVariable("SCRIPT_NAME"): "";
sv_SERVER_NAME = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_NAME")))?
UtilFns.Common.GetServerVariable("SERVER_NAME"): "";
sv_SERVER_PORT = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_PORT")))?
UtilFns.Common.GetServerVariable("SERVER_PORT"): "";
sv_SERVER_PROTOCOL = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_PROTOCOL")))?
UtilFns.Common.GetServerVariable("SERVER_PROTOCOL"): "";
sv_SERVER_SOFTWARE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_SOFTWARE")))?
UtilFns.Common.GetServerVariable("SERVER_SOFTWARE"): "";
sv_URL = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("URL")))?
UtilFns.Common.GetServerVariable("URL"): "";
sv_HTTP_CONNECTION = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_CONNECTION")))?
UtilFns.Common.GetServerVariable("HTTP_CONNECTION"): "";
sv_HTTP_ACCEPT = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_ACCEPT")))?
UtilFns.Common.GetServerVariable("HTTP_ACCEPT"): "";
sv_HTTP_ACCEPT_ENCODING = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_ACCEPT_ENCODING")))?
UtilFns.Common.GetServerVariable("HTTP_ACCEPT_ENCODING"): "";
sv_HTTP_ACCEPT_LANGUAGE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_ACCEPT_LANGUAGE")))?
UtilFns.Common.GetServerVariable("HTTP_ACCEPT_LANGUAGE"): "";
sv_HTTP_COOKIE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_COOKIE")))?
UtilFns.Common.GetServerVariable("HTTP_COOKIE"): "";
sv_HTTP_HOST = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_HOST")))?
UtilFns.Common.GetServerVariable("HTTP_HOST"): "";
sv_HTTP_USER_AGENT = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_USER_AGENT")))?
UtilFns.Common.GetServerVariable("HTTP_USER_AGENT"): "";
string[] computer_name = System.Net.Dns.GetHostEntry
(HttpContext.Current.Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' });
brwsr_computer_name = (!String.IsNullOrEmpty(computer_name[0].ToString()))?
computer_name[0].ToString(): "";
brwsr_MachineName = (!String.IsNullOrEmpty(System.Environment.MachineName))?
System.Environment.MachineName: "";
System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser;
brwsr_Type = (!String.IsNullOrEmpty(browser.Type.ToString()))?
browser.Type.ToString(): "";
brwsr_Browser = (!String.IsNullOrEmpty(browser.Browser.ToString()))?
browser.Browser.ToString(): "";
brwsr_Version = (!String.IsNullOrEmpty(browser.Version.ToString()))?
browser.Version.ToString(): "";
brwsr_MajorVersion = (!String.IsNullOrEmpty(browser.MajorVersion.ToString()))?
browser.MajorVersion.ToString(): "";
brwsr_MinorVersion = (!String.IsNullOrEmpty(browser.MinorVersion.ToString()))?
browser.MinorVersion.ToString(): "";
brwsr_Platform = (!String.IsNullOrEmpty(browser.Platform.ToString()))?
browser.Platform.ToString(): "";
brwsr_Beta = (!String.IsNullOrEmpty(browser.Beta.ToString()))?
browser.Beta.ToString(): "";
brwsr_Crawler = (!String.IsNullOrEmpty(browser.Crawler.ToString()))?
browser.Crawler.ToString(): "";
brwsr_AOL = (!String.IsNullOrEmpty(browser.AOL.ToString()))?
browser.AOL.ToString(): "";
brwsr_Win16 = (!String.IsNullOrEmpty(browser.Win16.ToString()))?
browser.Win16.ToString(): "";
brwsr_Win32 = (!String.IsNullOrEmpty(browser.Win32.ToString()))?
browser.Win32.ToString(): "";
brwsr_Frames = (!String.IsNullOrEmpty(browser.Frames.ToString()))?
browser.Frames.ToString(): "";
brwsr_Tables = (!String.IsNullOrEmpty(browser.Tables.ToString()))?
browser.Tables.ToString(): "";
brwsr_Cookies = (!String.IsNullOrEmpty(browser.Cookies.ToString()))?
browser.Cookies.ToString(): "";
brwsr_VBScript = (!String.IsNullOrEmpty(browser.VBScript.ToString()))?
browser.VBScript.ToString(): "";
brwsr_EcmaScriptVersion = (!String.IsNullOrEmpty(browser.EcmaScriptVersion.ToString()))?
browser.EcmaScriptVersion.ToString(): "";
brwsr_JavaApplets = (!String.IsNullOrEmpty(browser.JavaApplets.ToString()))?
browser.JavaApplets.ToString(): "";
brwsr_ActiveXControls = (!String.IsNullOrEmpty(browser.ActiveXControls.ToString()))?
browser.ActiveXControls.ToString(): "";
brwsr_JavaScriptVersion = (!String.IsNullOrEmpty(browser["JavaScriptVersion"].ToString()))?
browser["JavaScriptVersion"].ToString(): "";
string sSQL = @"foo.insBarBrowserValues "
+ " @sessionId = '" + sessionId + "'"
+ ", @ss_Username_aspx = '" + ss_Username_aspx + "'"
+ ", @ss_Email_aspx = '" + ss_Email_aspx + "'"
+ ", @ss_IsAdmin_aspx = '" + ss_IsAdmin_aspx + "'"
+ ", @ss_ActualUsername_aspx = '" + ss_ActualUsername_aspx + "'"
+ ", @ss_ActualIsAdmin_aspx = '" + ss_ActualIsAdmin_aspx + "'"
+ ", @ss_FullName2_aspx = '" + ss_FullName2_aspx + "'"
+ ", @ss_HRAdmin = '" + ss_HRAdmin + "'"
+ ", @ss_eRF_Agency = '" + ss_eRF_Agency + "'"
+ ", @ss_BudEntryAlways = '" + ss_BudEntryAlways + "'"
+ ", @sv_APPL_MD_PATH = '" + sv_APPL_MD_PATH + "'"
+ ", @sv_APPL_PHYSICAL_PATH = '" + sv_APPL_PHYSICAL_PATH + "'"
+ ", @sv_AUTH_TYPE = '" + sv_AUTH_TYPE + "'"
+ ", @sv_AUTH_USER = '" + sv_AUTH_USER + "'"
+ ", @sv_INSTANCE_META_PATH = '" + sv_INSTANCE_META_PATH + "'"
+ ", @sv_LOCAL_ADDR = '" + sv_LOCAL_ADDR + "'"
+ ", @sv_LOGON_USER = '" + sv_LOGON_USER + "'"
+ ", @sv_REMOTE_ADDR = '" + sv_REMOTE_ADDR + "'"
+ ", @sv_REMOTE_HOST = '" + sv_REMOTE_HOST + "'"
+ ", @sv_REMOTE_USER = '" + sv_REMOTE_USER + "'"
+ ", @sv_REQUEST_METHOD = '" + sv_REQUEST_METHOD + "'"
+ ", @sv_SCRIPT_NAME = '" + sv_SCRIPT_NAME + "'"
+ ", @sv_SERVER_NAME = '" + sv_SERVER_NAME + "'"
+ ", @sv_SERVER_PORT = '" + sv_SERVER_PORT + "'"
+ ", @sv_SERVER_PROTOCOL = '" + sv_SERVER_PROTOCOL + "'"
+ ", @sv_SERVER_SOFTWARE = '" + sv_SERVER_SOFTWARE + "'"
+ ", @sv_URL = '" + sv_URL + "'"
+ ", @sv_HTTP_CONNECTION = '" + sv_HTTP_CONNECTION + "'"
+ ", @sv_HTTP_ACCEPT = '" + sv_HTTP_ACCEPT + "'"
+ ", @sv_HTTP_ACCEPT_ENCODING = '" + sv_HTTP_ACCEPT_ENCODING + "'"
+ ", @sv_HTTP_ACCEPT_LANGUAGE = '" + sv_HTTP_ACCEPT_LANGUAGE + "'"
+ ", @sv_HTTP_COOKIE = '" + sv_HTTP_COOKIE + "'"
+ ", @sv_HTTP_HOST = '" + sv_HTTP_HOST + "'"
+ ", @sv_HTTP_USER_AGENT = '" + sv_HTTP_USER_AGENT + "'"
+ ", @brwsr_computer_name = '" + brwsr_computer_name + "'"
+ ", @brwsr_MachineName = '" + brwsr_MachineName + "'"
+ ", @brwsr_Type = '" + brwsr_Type + "'"
+ ", @brwsr_Browser = '" + brwsr_Browser + "'"
+ ", @brwsr_Version = '" + brwsr_Version + "'"
+ ", @brwsr_MajorVersion = '" + brwsr_MajorVersion + "'"
+ ", @brwsr_MinorVersion = '" + brwsr_MinorVersion + "'"
+ ", @brwsr_Platform = '" + brwsr_Platform + "'"
+ ", @brwsr_Beta = '" + brwsr_Beta + "'"
+ ", @brwsr_Crawler = '" + brwsr_Crawler + "'"
+ ", @brwsr_AOL = '" + brwsr_AOL + "'"
+ ", @brwsr_Win16 = '" + brwsr_Win16 + "'"
+ ", @brwsr_Win32 = '" + brwsr_Win32 + "'"
+ ", @brwsr_Frames = '" + brwsr_Frames + "'"
+ ", @brwsr_Tables = '" + brwsr_Tables + "'"
+ ", @brwsr_Cookies = '" + brwsr_Cookies + "'"
+ ", @brwsr_VBScript = '" + brwsr_VBScript + "'"
+ ", @brwsr_EcmaScriptVersion = '" + brwsr_EcmaScriptVersion + "'"
+ ", @brwsr_JavaApplets = '" + brwsr_JavaApplets + "'"
+ ", @brwsr_ActiveXControls = '" + brwsr_ActiveXControls + "'"
+ ", @brwsr_JavaScriptVersion = '" + brwsr_JavaScriptVersion + "'" ;
DataUtilities.utilSQL.DBExecNonQueryText(sSQL, "foo");
}
catch (Exception ex)
{
UtilFns.Common.LogAll("Error Recording User Values", ex.ToString(), UtilFns.Common.GetCurrentPageName(),
"Session ID: " + sessionId, true);
}
finally
{
;
}
}
}
--DROP TABLE foo.userBarValues
--USE foo
--GO
--CREATE TABLE foo.userBarValues (
-- ident BIGINT IDENTITY (1, 1)
--, sessionId VARCHAR(128) NOT NULL
--, ss_Username_aspx VARCHAR(128)
--, ss_Email_aspx VARCHAR(128)
--, ss_IsAdmin_aspx VARCHAR(2)
--, ss_ActualUsername_aspx VARCHAR(128)
--, ss_ActualIsAdmin_aspx VARCHAR(2)
--, ss_FullName2_aspx VARCHAR(128)
--, ss_HRAdmin VARCHAR(2)
--, ss_eRF_Agency VARCHAR(2)
--, ss_BudEntryAlways VARCHAR(2)
--, sv_APPL_MD_PATH VARCHAR(128)
--, sv_APPL_PHYSICAL_PATH VARCHAR(128)
--, sv_AUTH_TYPE VARCHAR(128)
--, sv_AUTH_USER VARCHAR(128)
--, sv_INSTANCE_META_PATH VARCHAR(128)
--, sv_LOCAL_ADDR VARCHAR(32)
--, sv_LOGON_USER VARCHAR(128)
--, sv_REMOTE_ADDR VARCHAR(32)
--, sv_REMOTE_HOST VARCHAR(32)
--, sv_REMOTE_USER VARCHAR(128)
--, sv_REQUEST_METHOD VARCHAR(16)
--, sv_SCRIPT_NAME VARCHAR(128)
--, sv_SERVER_NAME VARCHAR(128)
--, sv_SERVER_PORT VARCHAR(8)
--, sv_SERVER_PROTOCOL VARCHAR(16)
--, sv_SERVER_SOFTWARE VARCHAR(128)
--, sv_URL VARCHAR(128)
--, sv_HTTP_CONNECTION VARCHAR(128)
--, sv_HTTP_ACCEPT VARCHAR(1024)
--, sv_HTTP_ACCEPT_ENCODING VARCHAR(128)
--, sv_HTTP_ACCEPT_LANGUAGE VARCHAR(128)
--, sv_HTTP_COOKIE VARCHAR(1024)
--, sv_HTTP_HOST VARCHAR(128)
--, sv_HTTP_USER_AGENT VARCHAR(1024)
--, brwsr_computer_name VARCHAR(128)
--, brwsr_MachineName VARCHAR(128)
--, brwsr_Type VARCHAR(128)
--, brwsr_Browser VARCHAR(128)
--, brwsr_Version VARCHAR(16)
--, brwsr_MajorVersion VARCHAR(16)
--, brwsr_MinorVersion VARCHAR(16)
--, brwsr_Platform VARCHAR(128)
--, brwsr_Beta VARCHAR(16)
--, brwsr_Crawler VARCHAR(16)
--, brwsr_AOL VARCHAR(16)
--, brwsr_Win16 VARCHAR(16)
--, brwsr_Win32 VARCHAR(16)
--, brwsr_Frames VARCHAR(16)
--, brwsr_Tables VARCHAR(16)
--, brwsr_Cookies VARCHAR(16)
--, brwsr_VBScript VARCHAR(16)
--, brwsr_EcmaScriptVersion VARCHAR(16)
--, brwsr_JavaApplets VARCHAR(16)
--, brwsr_ActiveXControls VARCHAR(16)
--, brwsr_JavaScriptVersion VARCHAR(16)
--, crDate DATETIME DEFAULT GETDATE()
--)
USE PerformanceFoo
GO
CREATE PROC Foo.insBarBrowserValues (
@sessionId VARCHAR(128)
, @ss_Username_aspx VARCHAR(128)
, @ss_Email_aspx VARCHAR(128)
, @ss_IsAdmin_aspx VARCHAR(2)
, @ss_ActualUsername_aspx VARCHAR(128)
, @ss_ActualIsAdmin_aspx VARCHAR(2)
, @ss_FullName2_aspx VARCHAR(128)
, @ss_HRAdmin VARCHAR(2)
, @ss_eRF_Agency VARCHAR(2)
, @ss_BudEntryAlways VARCHAR(2)
, @sv_APPL_MD_PATH VARCHAR(128)
, @sv_APPL_PHYSICAL_PATH VARCHAR(128)
, @sv_AUTH_TYPE VARCHAR(128)
, @sv_AUTH_USER VARCHAR(128)
, @sv_INSTANCE_META_PATH VARCHAR(128)
, @sv_LOCAL_ADDR VARCHAR(32)
, @sv_LOGON_USER VARCHAR(128)
, @sv_REMOTE_ADDR VARCHAR(32)
, @sv_REMOTE_HOST VARCHAR(32)
, @sv_REMOTE_USER VARCHAR(128)
, @sv_REQUEST_METHOD VARCHAR(16)
, @sv_SCRIPT_NAME VARCHAR(128)
, @sv_SERVER_NAME VARCHAR(128)
, @sv_SERVER_PORT VARCHAR(8)
, @sv_SERVER_PROTOCOL VARCHAR(16)
, @sv_SERVER_SOFTWARE VARCHAR(128)
, @sv_URL VARCHAR(128)
, @sv_HTTP_CONNECTION VARCHAR(128)
, @sv_HTTP_ACCEPT VARCHAR(1024)
, @sv_HTTP_ACCEPT_ENCODING VARCHAR(128)
, @sv_HTTP_ACCEPT_LANGUAGE VARCHAR(128)
, @sv_HTTP_COOKIE VARCHAR(1024)
, @sv_HTTP_HOST VARCHAR(128)
, @sv_HTTP_USER_AGENT VARCHAR(1024)
, @brwsr_computer_name VARCHAR(128)
, @brwsr_MachineName VARCHAR(128)
, @brwsr_Type VARCHAR(128)
, @brwsr_Browser VARCHAR(128)
, @brwsr_Version VARCHAR(16)
, @brwsr_MajorVersion VARCHAR(16)
, @brwsr_MinorVersion VARCHAR(16)
, @brwsr_Platform VARCHAR(128)
, @brwsr_Beta VARCHAR(16)
, @brwsr_Crawler VARCHAR(16)
, @brwsr_AOL VARCHAR(16)
, @brwsr_Win16 VARCHAR(16)
, @brwsr_Win32 VARCHAR(16)
, @brwsr_Frames VARCHAR(16)
, @brwsr_Tables VARCHAR(16)
, @brwsr_Cookies VARCHAR(16)
, @brwsr_VBScript VARCHAR(16)
, @brwsr_EcmaScriptVersion VARCHAR(16)
, @brwsr_JavaApplets VARCHAR(16)
, @brwsr_ActiveXControls VARCHAR(16)
, @brwsr_JavaScriptVersion VARCHAR(16)
)
AS
BEGIN
/*************************************************************************
Joe Kelly
2013-11-08 15:50:13.990
For collecting data about the browser a user is employing, called from
the default page in the portal
*************************************************************************/
SET NOCOUNT ON
DECLARE @errorMsg VARCHAR (MAX) = ''
BEGIN TRY
INSERT Foo.userBarValues (
sessionId
, ss_Username_aspx
, ss_Email_aspx
, ss_IsAdmin_aspx
, ss_ActualUsername_aspx
, ss_ActualIsAdmin_aspx
, ss_FullName2_aspx
, ss_HRAdmin
, ss_eRF_Agency
, ss_BudEntryAlways
, sv_APPL_MD_PATH
, sv_APPL_PHYSICAL_PATH
, sv_AUTH_TYPE
, sv_AUTH_USER
, sv_INSTANCE_META_PATH
, sv_LOCAL_ADDR
, sv_LOGON_USER
, sv_REMOTE_ADDR
, sv_REMOTE_HOST
, sv_REMOTE_USER
, sv_REQUEST_METHOD
, sv_SCRIPT_NAME
, sv_SERVER_NAME
, sv_SERVER_PORT
, sv_SERVER_PROTOCOL
, sv_SERVER_SOFTWARE
, sv_URL
, sv_HTTP_CONNECTION
, sv_HTTP_ACCEPT
, sv_HTTP_ACCEPT_ENCODING
, sv_HTTP_ACCEPT_LANGUAGE
, sv_HTTP_COOKIE
, sv_HTTP_HOST
, sv_HTTP_USER_AGENT
, brwsr_computer_name
, brwsr_MachineName
, brwsr_Type
, brwsr_Browser
, brwsr_Version
, brwsr_MajorVersion
, brwsr_MinorVersion
, brwsr_Platform
, brwsr_Beta
, brwsr_Crawler
, brwsr_AOL
, brwsr_Win16
, brwsr_Win32
, brwsr_Frames
, brwsr_Tables
, brwsr_Cookies
, brwsr_VBScript
, brwsr_EcmaScriptVersion
, brwsr_JavaApplets
, brwsr_ActiveXControls
, brwsr_JavaScriptVersion
)
SELECT
@sessionId
, @ss_Username_aspx
, @ss_Email_aspx
, @ss_IsAdmin_aspx
, @ss_ActualUsername_aspx
, @ss_ActualIsAdmin_aspx
, @ss_FullName2_aspx
, @ss_HRAdmin
, @ss_eRF_Agency
, @ss_BudEntryAlways
, @sv_APPL_MD_PATH
, @sv_APPL_PHYSICAL_PATH
, @sv_AUTH_TYPE
, @sv_AUTH_USER
, @sv_INSTANCE_META_PATH
, @sv_LOCAL_ADDR
, @sv_LOGON_USER
, @sv_REMOTE_ADDR
, @sv_REMOTE_HOST
, @sv_REMOTE_USER
, @sv_REQUEST_METHOD
, @sv_SCRIPT_NAME
, @sv_SERVER_NAME
, @sv_SERVER_PORT
, @sv_SERVER_PROTOCOL
, @sv_SERVER_SOFTWARE
, @sv_URL
, @sv_HTTP_CONNECTION
, @sv_HTTP_ACCEPT
, @sv_HTTP_ACCEPT_ENCODING
, @sv_HTTP_ACCEPT_LANGUAGE
, @sv_HTTP_COOKIE
, @sv_HTTP_HOST
, @sv_HTTP_USER_AGENT
, @brwsr_computer_name
, @brwsr_MachineName
, @brwsr_Type
, @brwsr_Browser
, @brwsr_Version
, @brwsr_MajorVersion
, @brwsr_MinorVersion
, @brwsr_Platform
, @brwsr_Beta
, @brwsr_Crawler
, @brwsr_AOL
, @brwsr_Win16
, @brwsr_Win32
, @brwsr_Frames
, @brwsr_Tables
, @brwsr_Cookies
, @brwsr_VBScript
, @brwsr_EcmaScriptVersion
, @brwsr_JavaApplets
, @brwsr_ActiveXControls
, @brwsr_JavaScriptVersion
END TRY
BEGIN CATCH
--
SELECT @errorMsg = foo.fnGetErrorTryCatch(0)
SELECT @sessionId = 'Error logging values for session: ' + @sessionId
EXEC dbo.ins_sys_error_log
'foo.insBarBrowserValues'
, @sessionId
, 0
, @errorMsg
, 1
END CATCH
END
{
string sessionId = System.Web.HttpContext.Current.Session.SessionID,
sameSessionId = UtilFns.Common.GetSessionVariable("userSessionId");
bool recordSession = false;
/// The sess vars are apparently not alwas set when the user first gets to the portal
string temp_ss_Username_aspx = UtilFns.Common.GetSessionVariable("Username_aspx");
string repeatSessionRecording = UtilFns.Common.GetSessionVariable("repeatSessionRecording");
/// The sess vars are apparently not alwas set when the user first gets to the portal
/// so set a flag to repeat this when they are present
if (String.IsNullOrEmpty(temp_ss_Username_aspx))
{
UtilFns.Common.SetSessionVariable("repeatSessionRecording", "1");
}
if (repeatSessionRecording == "1")
{
recordSession = true;
UtilFns.Common.SetSessionVariable("repeatSessionRecording", "0");
}
if (String.IsNullOrEmpty(sameSessionId))
{
recordSession = true;
UtilFns.Common.SetSessionVariable("userSessionId", sessionId);
}
else if (sameSessionId != sessionId)
{
recordSession = true;
}
if (recordSession)
{
/// For recording user values, called from teh home page
string ss_Username_aspx = "",
ss_Email_aspx = "",
ss_IsAdmin_aspx = "",
ss_ActualUsername_aspx = "",
ss_ActualIsAdmin_aspx = "",
ss_FullName2_aspx = "",
ss_HRAdmin = "",
ss_eRF_Agency = "",
ss_BudEntryAlways = "",
sv_APPL_MD_PATH = "",
sv_APPL_PHYSICAL_PATH = "",
sv_AUTH_TYPE = "",
sv_AUTH_USER = "",
sv_INSTANCE_META_PATH = "",
sv_LOCAL_ADDR = "",
sv_LOGON_USER = "",
sv_REMOTE_ADDR = "",
sv_REMOTE_HOST = "",
sv_REMOTE_USER = "",
sv_REQUEST_METHOD = "",
sv_SCRIPT_NAME = "",
sv_SERVER_NAME = "",
sv_SERVER_PORT = "",
sv_SERVER_PROTOCOL = "",
sv_SERVER_SOFTWARE = "",
sv_URL = "",
sv_HTTP_CONNECTION = "",
sv_HTTP_ACCEPT = "",
sv_HTTP_ACCEPT_ENCODING = "",
sv_HTTP_ACCEPT_LANGUAGE = "",
sv_HTTP_COOKIE = "",
sv_HTTP_HOST = "",
sv_HTTP_USER_AGENT = "",
brwsr_computer_name = "",
brwsr_MachineName = "",
brwsr_Type = "",
brwsr_Browser = "",
brwsr_Version = "",
brwsr_MajorVersion = "",
brwsr_MinorVersion = "",
brwsr_Platform = "",
brwsr_Beta = "",
brwsr_Crawler = "",
brwsr_AOL = "",
brwsr_Win16 = "",
brwsr_Win32 = "",
brwsr_Frames = "",
brwsr_Tables = "",
brwsr_Cookies = "",
brwsr_VBScript = "",
brwsr_EcmaScriptVersion = "",
brwsr_JavaApplets = "",
brwsr_ActiveXControls = "",
brwsr_JavaScriptVersion = "";
try
{
ss_Username_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("Username_aspx")))?
UtilFns.Common.GetSessionVariable("Username_aspx"): "";
ss_Email_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("Email_aspx")))?
UtilFns.Common.GetSessionVariable("Email_aspx"): "";
ss_IsAdmin_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("IsAdmin_aspx")))?
UtilFns.Common.GetSessionVariable("IsAdmin_aspx"): "";
ss_ActualUsername_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("Username_aspx")))?
UtilFns.Common.GetSessionVariable("Username_aspx"): "";
ss_ActualIsAdmin_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("ActualIsAdmin_aspx")))?
UtilFns.Common.GetSessionVariable("ActualIsAdmin_aspx"): "";
ss_FullName2_aspx = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("FullName2_aspx")))?
UtilFns.Common.GetSessionVariable("FullName2_aspx"): "";
ss_HRAdmin = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("HRAdmin")))?
UtilFns.Common.GetSessionVariable("HRAdmin"): "";
ss_eRF_Agency = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("eRF_Agency")))?
UtilFns.Common.GetSessionVariable("eRF_Agency"): "";
ss_BudEntryAlways = (!String.IsNullOrEmpty(UtilFns.Common.GetSessionVariable("BudEntryAlways")))?
UtilFns.Common.GetSessionVariable("BudEntryAlways"): "";
sv_APPL_MD_PATH = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("APPL_MD_PATH")))?
UtilFns.Common.GetServerVariable("APPL_MD_PATH"): "";
sv_APPL_PHYSICAL_PATH = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("APPL_PHYSICAL_PATH")))?
UtilFns.Common.GetServerVariable("APPL_PHYSICAL_PATH"): "";
sv_AUTH_TYPE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("AUTH_TYPE")))?
UtilFns.Common.GetServerVariable("AUTH_TYPE"): "";
sv_AUTH_USER = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("AUTH_USER")))?
UtilFns.Common.GetServerVariable("AUTH_USER"): "";
sv_INSTANCE_META_PATH = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("INSTANCE_META_PATH")))?
UtilFns.Common.GetServerVariable("INSTANCE_META_PATH"): "";
sv_LOCAL_ADDR = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("LOCAL_ADDR")))?
UtilFns.Common.GetServerVariable("LOCAL_ADDR"): "";
sv_LOGON_USER = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("LOGON_USER")))?
UtilFns.Common.GetServerVariable("LOGON_USER"): "";
sv_REMOTE_ADDR = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REMOTE_ADDR")))?
UtilFns.Common.GetServerVariable("REMOTE_ADDR"): "";
sv_REMOTE_HOST = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REMOTE_HOST")))?
UtilFns.Common.GetServerVariable("REMOTE_HOST"): "";
sv_REMOTE_USER = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REMOTE_USER")))?
UtilFns.Common.GetServerVariable("REMOTE_USER"): "";
sv_REQUEST_METHOD = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("REQUEST_METHOD")))?
UtilFns.Common.GetServerVariable("REQUEST_METHOD"): "";
sv_SCRIPT_NAME = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SCRIPT_NAME")))?
UtilFns.Common.GetServerVariable("SCRIPT_NAME"): "";
sv_SERVER_NAME = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_NAME")))?
UtilFns.Common.GetServerVariable("SERVER_NAME"): "";
sv_SERVER_PORT = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_PORT")))?
UtilFns.Common.GetServerVariable("SERVER_PORT"): "";
sv_SERVER_PROTOCOL = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_PROTOCOL")))?
UtilFns.Common.GetServerVariable("SERVER_PROTOCOL"): "";
sv_SERVER_SOFTWARE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("SERVER_SOFTWARE")))?
UtilFns.Common.GetServerVariable("SERVER_SOFTWARE"): "";
sv_URL = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("URL")))?
UtilFns.Common.GetServerVariable("URL"): "";
sv_HTTP_CONNECTION = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_CONNECTION")))?
UtilFns.Common.GetServerVariable("HTTP_CONNECTION"): "";
sv_HTTP_ACCEPT = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_ACCEPT")))?
UtilFns.Common.GetServerVariable("HTTP_ACCEPT"): "";
sv_HTTP_ACCEPT_ENCODING = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_ACCEPT_ENCODING")))?
UtilFns.Common.GetServerVariable("HTTP_ACCEPT_ENCODING"): "";
sv_HTTP_ACCEPT_LANGUAGE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_ACCEPT_LANGUAGE")))?
UtilFns.Common.GetServerVariable("HTTP_ACCEPT_LANGUAGE"): "";
sv_HTTP_COOKIE = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_COOKIE")))?
UtilFns.Common.GetServerVariable("HTTP_COOKIE"): "";
sv_HTTP_HOST = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_HOST")))?
UtilFns.Common.GetServerVariable("HTTP_HOST"): "";
sv_HTTP_USER_AGENT = (!String.IsNullOrEmpty(UtilFns.Common.GetServerVariable("HTTP_USER_AGENT")))?
UtilFns.Common.GetServerVariable("HTTP_USER_AGENT"): "";
string[] computer_name = System.Net.Dns.GetHostEntry
(HttpContext.Current.Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' });
brwsr_computer_name = (!String.IsNullOrEmpty(computer_name[0].ToString()))?
computer_name[0].ToString(): "";
brwsr_MachineName = (!String.IsNullOrEmpty(System.Environment.MachineName))?
System.Environment.MachineName: "";
System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser;
brwsr_Type = (!String.IsNullOrEmpty(browser.Type.ToString()))?
browser.Type.ToString(): "";
brwsr_Browser = (!String.IsNullOrEmpty(browser.Browser.ToString()))?
browser.Browser.ToString(): "";
brwsr_Version = (!String.IsNullOrEmpty(browser.Version.ToString()))?
browser.Version.ToString(): "";
brwsr_MajorVersion = (!String.IsNullOrEmpty(browser.MajorVersion.ToString()))?
browser.MajorVersion.ToString(): "";
brwsr_MinorVersion = (!String.IsNullOrEmpty(browser.MinorVersion.ToString()))?
browser.MinorVersion.ToString(): "";
brwsr_Platform = (!String.IsNullOrEmpty(browser.Platform.ToString()))?
browser.Platform.ToString(): "";
brwsr_Beta = (!String.IsNullOrEmpty(browser.Beta.ToString()))?
browser.Beta.ToString(): "";
brwsr_Crawler = (!String.IsNullOrEmpty(browser.Crawler.ToString()))?
browser.Crawler.ToString(): "";
brwsr_AOL = (!String.IsNullOrEmpty(browser.AOL.ToString()))?
browser.AOL.ToString(): "";
brwsr_Win16 = (!String.IsNullOrEmpty(browser.Win16.ToString()))?
browser.Win16.ToString(): "";
brwsr_Win32 = (!String.IsNullOrEmpty(browser.Win32.ToString()))?
browser.Win32.ToString(): "";
brwsr_Frames = (!String.IsNullOrEmpty(browser.Frames.ToString()))?
browser.Frames.ToString(): "";
brwsr_Tables = (!String.IsNullOrEmpty(browser.Tables.ToString()))?
browser.Tables.ToString(): "";
brwsr_Cookies = (!String.IsNullOrEmpty(browser.Cookies.ToString()))?
browser.Cookies.ToString(): "";
brwsr_VBScript = (!String.IsNullOrEmpty(browser.VBScript.ToString()))?
browser.VBScript.ToString(): "";
brwsr_EcmaScriptVersion = (!String.IsNullOrEmpty(browser.EcmaScriptVersion.ToString()))?
browser.EcmaScriptVersion.ToString(): "";
brwsr_JavaApplets = (!String.IsNullOrEmpty(browser.JavaApplets.ToString()))?
browser.JavaApplets.ToString(): "";
brwsr_ActiveXControls = (!String.IsNullOrEmpty(browser.ActiveXControls.ToString()))?
browser.ActiveXControls.ToString(): "";
brwsr_JavaScriptVersion = (!String.IsNullOrEmpty(browser["JavaScriptVersion"].ToString()))?
browser["JavaScriptVersion"].ToString(): "";
string sSQL = @"foo.insBarBrowserValues "
+ " @sessionId = '" + sessionId + "'"
+ ", @ss_Username_aspx = '" + ss_Username_aspx + "'"
+ ", @ss_Email_aspx = '" + ss_Email_aspx + "'"
+ ", @ss_IsAdmin_aspx = '" + ss_IsAdmin_aspx + "'"
+ ", @ss_ActualUsername_aspx = '" + ss_ActualUsername_aspx + "'"
+ ", @ss_ActualIsAdmin_aspx = '" + ss_ActualIsAdmin_aspx + "'"
+ ", @ss_FullName2_aspx = '" + ss_FullName2_aspx + "'"
+ ", @ss_HRAdmin = '" + ss_HRAdmin + "'"
+ ", @ss_eRF_Agency = '" + ss_eRF_Agency + "'"
+ ", @ss_BudEntryAlways = '" + ss_BudEntryAlways + "'"
+ ", @sv_APPL_MD_PATH = '" + sv_APPL_MD_PATH + "'"
+ ", @sv_APPL_PHYSICAL_PATH = '" + sv_APPL_PHYSICAL_PATH + "'"
+ ", @sv_AUTH_TYPE = '" + sv_AUTH_TYPE + "'"
+ ", @sv_AUTH_USER = '" + sv_AUTH_USER + "'"
+ ", @sv_INSTANCE_META_PATH = '" + sv_INSTANCE_META_PATH + "'"
+ ", @sv_LOCAL_ADDR = '" + sv_LOCAL_ADDR + "'"
+ ", @sv_LOGON_USER = '" + sv_LOGON_USER + "'"
+ ", @sv_REMOTE_ADDR = '" + sv_REMOTE_ADDR + "'"
+ ", @sv_REMOTE_HOST = '" + sv_REMOTE_HOST + "'"
+ ", @sv_REMOTE_USER = '" + sv_REMOTE_USER + "'"
+ ", @sv_REQUEST_METHOD = '" + sv_REQUEST_METHOD + "'"
+ ", @sv_SCRIPT_NAME = '" + sv_SCRIPT_NAME + "'"
+ ", @sv_SERVER_NAME = '" + sv_SERVER_NAME + "'"
+ ", @sv_SERVER_PORT = '" + sv_SERVER_PORT + "'"
+ ", @sv_SERVER_PROTOCOL = '" + sv_SERVER_PROTOCOL + "'"
+ ", @sv_SERVER_SOFTWARE = '" + sv_SERVER_SOFTWARE + "'"
+ ", @sv_URL = '" + sv_URL + "'"
+ ", @sv_HTTP_CONNECTION = '" + sv_HTTP_CONNECTION + "'"
+ ", @sv_HTTP_ACCEPT = '" + sv_HTTP_ACCEPT + "'"
+ ", @sv_HTTP_ACCEPT_ENCODING = '" + sv_HTTP_ACCEPT_ENCODING + "'"
+ ", @sv_HTTP_ACCEPT_LANGUAGE = '" + sv_HTTP_ACCEPT_LANGUAGE + "'"
+ ", @sv_HTTP_COOKIE = '" + sv_HTTP_COOKIE + "'"
+ ", @sv_HTTP_HOST = '" + sv_HTTP_HOST + "'"
+ ", @sv_HTTP_USER_AGENT = '" + sv_HTTP_USER_AGENT + "'"
+ ", @brwsr_computer_name = '" + brwsr_computer_name + "'"
+ ", @brwsr_MachineName = '" + brwsr_MachineName + "'"
+ ", @brwsr_Type = '" + brwsr_Type + "'"
+ ", @brwsr_Browser = '" + brwsr_Browser + "'"
+ ", @brwsr_Version = '" + brwsr_Version + "'"
+ ", @brwsr_MajorVersion = '" + brwsr_MajorVersion + "'"
+ ", @brwsr_MinorVersion = '" + brwsr_MinorVersion + "'"
+ ", @brwsr_Platform = '" + brwsr_Platform + "'"
+ ", @brwsr_Beta = '" + brwsr_Beta + "'"
+ ", @brwsr_Crawler = '" + brwsr_Crawler + "'"
+ ", @brwsr_AOL = '" + brwsr_AOL + "'"
+ ", @brwsr_Win16 = '" + brwsr_Win16 + "'"
+ ", @brwsr_Win32 = '" + brwsr_Win32 + "'"
+ ", @brwsr_Frames = '" + brwsr_Frames + "'"
+ ", @brwsr_Tables = '" + brwsr_Tables + "'"
+ ", @brwsr_Cookies = '" + brwsr_Cookies + "'"
+ ", @brwsr_VBScript = '" + brwsr_VBScript + "'"
+ ", @brwsr_EcmaScriptVersion = '" + brwsr_EcmaScriptVersion + "'"
+ ", @brwsr_JavaApplets = '" + brwsr_JavaApplets + "'"
+ ", @brwsr_ActiveXControls = '" + brwsr_ActiveXControls + "'"
+ ", @brwsr_JavaScriptVersion = '" + brwsr_JavaScriptVersion + "'" ;
DataUtilities.utilSQL.DBExecNonQueryText(sSQL, "foo");
}
catch (Exception ex)
{
UtilFns.Common.LogAll("Error Recording User Values", ex.ToString(), UtilFns.Common.GetCurrentPageName(),
"Session ID: " + sessionId, true);
}
finally
{
;
}
}
}
--DROP TABLE foo.userBarValues
--USE foo
--GO
--CREATE TABLE foo.userBarValues (
-- ident BIGINT IDENTITY (1, 1)
--, sessionId VARCHAR(128) NOT NULL
--, ss_Username_aspx VARCHAR(128)
--, ss_Email_aspx VARCHAR(128)
--, ss_IsAdmin_aspx VARCHAR(2)
--, ss_ActualUsername_aspx VARCHAR(128)
--, ss_ActualIsAdmin_aspx VARCHAR(2)
--, ss_FullName2_aspx VARCHAR(128)
--, ss_HRAdmin VARCHAR(2)
--, ss_eRF_Agency VARCHAR(2)
--, ss_BudEntryAlways VARCHAR(2)
--, sv_APPL_MD_PATH VARCHAR(128)
--, sv_APPL_PHYSICAL_PATH VARCHAR(128)
--, sv_AUTH_TYPE VARCHAR(128)
--, sv_AUTH_USER VARCHAR(128)
--, sv_INSTANCE_META_PATH VARCHAR(128)
--, sv_LOCAL_ADDR VARCHAR(32)
--, sv_LOGON_USER VARCHAR(128)
--, sv_REMOTE_ADDR VARCHAR(32)
--, sv_REMOTE_HOST VARCHAR(32)
--, sv_REMOTE_USER VARCHAR(128)
--, sv_REQUEST_METHOD VARCHAR(16)
--, sv_SCRIPT_NAME VARCHAR(128)
--, sv_SERVER_NAME VARCHAR(128)
--, sv_SERVER_PORT VARCHAR(8)
--, sv_SERVER_PROTOCOL VARCHAR(16)
--, sv_SERVER_SOFTWARE VARCHAR(128)
--, sv_URL VARCHAR(128)
--, sv_HTTP_CONNECTION VARCHAR(128)
--, sv_HTTP_ACCEPT VARCHAR(1024)
--, sv_HTTP_ACCEPT_ENCODING VARCHAR(128)
--, sv_HTTP_ACCEPT_LANGUAGE VARCHAR(128)
--, sv_HTTP_COOKIE VARCHAR(1024)
--, sv_HTTP_HOST VARCHAR(128)
--, sv_HTTP_USER_AGENT VARCHAR(1024)
--, brwsr_computer_name VARCHAR(128)
--, brwsr_MachineName VARCHAR(128)
--, brwsr_Type VARCHAR(128)
--, brwsr_Browser VARCHAR(128)
--, brwsr_Version VARCHAR(16)
--, brwsr_MajorVersion VARCHAR(16)
--, brwsr_MinorVersion VARCHAR(16)
--, brwsr_Platform VARCHAR(128)
--, brwsr_Beta VARCHAR(16)
--, brwsr_Crawler VARCHAR(16)
--, brwsr_AOL VARCHAR(16)
--, brwsr_Win16 VARCHAR(16)
--, brwsr_Win32 VARCHAR(16)
--, brwsr_Frames VARCHAR(16)
--, brwsr_Tables VARCHAR(16)
--, brwsr_Cookies VARCHAR(16)
--, brwsr_VBScript VARCHAR(16)
--, brwsr_EcmaScriptVersion VARCHAR(16)
--, brwsr_JavaApplets VARCHAR(16)
--, brwsr_ActiveXControls VARCHAR(16)
--, brwsr_JavaScriptVersion VARCHAR(16)
--, crDate DATETIME DEFAULT GETDATE()
--)
USE PerformanceFoo
GO
CREATE PROC Foo.insBarBrowserValues (
@sessionId VARCHAR(128)
, @ss_Username_aspx VARCHAR(128)
, @ss_Email_aspx VARCHAR(128)
, @ss_IsAdmin_aspx VARCHAR(2)
, @ss_ActualUsername_aspx VARCHAR(128)
, @ss_ActualIsAdmin_aspx VARCHAR(2)
, @ss_FullName2_aspx VARCHAR(128)
, @ss_HRAdmin VARCHAR(2)
, @ss_eRF_Agency VARCHAR(2)
, @ss_BudEntryAlways VARCHAR(2)
, @sv_APPL_MD_PATH VARCHAR(128)
, @sv_APPL_PHYSICAL_PATH VARCHAR(128)
, @sv_AUTH_TYPE VARCHAR(128)
, @sv_AUTH_USER VARCHAR(128)
, @sv_INSTANCE_META_PATH VARCHAR(128)
, @sv_LOCAL_ADDR VARCHAR(32)
, @sv_LOGON_USER VARCHAR(128)
, @sv_REMOTE_ADDR VARCHAR(32)
, @sv_REMOTE_HOST VARCHAR(32)
, @sv_REMOTE_USER VARCHAR(128)
, @sv_REQUEST_METHOD VARCHAR(16)
, @sv_SCRIPT_NAME VARCHAR(128)
, @sv_SERVER_NAME VARCHAR(128)
, @sv_SERVER_PORT VARCHAR(8)
, @sv_SERVER_PROTOCOL VARCHAR(16)
, @sv_SERVER_SOFTWARE VARCHAR(128)
, @sv_URL VARCHAR(128)
, @sv_HTTP_CONNECTION VARCHAR(128)
, @sv_HTTP_ACCEPT VARCHAR(1024)
, @sv_HTTP_ACCEPT_ENCODING VARCHAR(128)
, @sv_HTTP_ACCEPT_LANGUAGE VARCHAR(128)
, @sv_HTTP_COOKIE VARCHAR(1024)
, @sv_HTTP_HOST VARCHAR(128)
, @sv_HTTP_USER_AGENT VARCHAR(1024)
, @brwsr_computer_name VARCHAR(128)
, @brwsr_MachineName VARCHAR(128)
, @brwsr_Type VARCHAR(128)
, @brwsr_Browser VARCHAR(128)
, @brwsr_Version VARCHAR(16)
, @brwsr_MajorVersion VARCHAR(16)
, @brwsr_MinorVersion VARCHAR(16)
, @brwsr_Platform VARCHAR(128)
, @brwsr_Beta VARCHAR(16)
, @brwsr_Crawler VARCHAR(16)
, @brwsr_AOL VARCHAR(16)
, @brwsr_Win16 VARCHAR(16)
, @brwsr_Win32 VARCHAR(16)
, @brwsr_Frames VARCHAR(16)
, @brwsr_Tables VARCHAR(16)
, @brwsr_Cookies VARCHAR(16)
, @brwsr_VBScript VARCHAR(16)
, @brwsr_EcmaScriptVersion VARCHAR(16)
, @brwsr_JavaApplets VARCHAR(16)
, @brwsr_ActiveXControls VARCHAR(16)
, @brwsr_JavaScriptVersion VARCHAR(16)
)
AS
BEGIN
/*************************************************************************
Joe Kelly
2013-11-08 15:50:13.990
For collecting data about the browser a user is employing, called from
the default page in the portal
*************************************************************************/
SET NOCOUNT ON
DECLARE @errorMsg VARCHAR (MAX) = ''
BEGIN TRY
INSERT Foo.userBarValues (
sessionId
, ss_Username_aspx
, ss_Email_aspx
, ss_IsAdmin_aspx
, ss_ActualUsername_aspx
, ss_ActualIsAdmin_aspx
, ss_FullName2_aspx
, ss_HRAdmin
, ss_eRF_Agency
, ss_BudEntryAlways
, sv_APPL_MD_PATH
, sv_APPL_PHYSICAL_PATH
, sv_AUTH_TYPE
, sv_AUTH_USER
, sv_INSTANCE_META_PATH
, sv_LOCAL_ADDR
, sv_LOGON_USER
, sv_REMOTE_ADDR
, sv_REMOTE_HOST
, sv_REMOTE_USER
, sv_REQUEST_METHOD
, sv_SCRIPT_NAME
, sv_SERVER_NAME
, sv_SERVER_PORT
, sv_SERVER_PROTOCOL
, sv_SERVER_SOFTWARE
, sv_URL
, sv_HTTP_CONNECTION
, sv_HTTP_ACCEPT
, sv_HTTP_ACCEPT_ENCODING
, sv_HTTP_ACCEPT_LANGUAGE
, sv_HTTP_COOKIE
, sv_HTTP_HOST
, sv_HTTP_USER_AGENT
, brwsr_computer_name
, brwsr_MachineName
, brwsr_Type
, brwsr_Browser
, brwsr_Version
, brwsr_MajorVersion
, brwsr_MinorVersion
, brwsr_Platform
, brwsr_Beta
, brwsr_Crawler
, brwsr_AOL
, brwsr_Win16
, brwsr_Win32
, brwsr_Frames
, brwsr_Tables
, brwsr_Cookies
, brwsr_VBScript
, brwsr_EcmaScriptVersion
, brwsr_JavaApplets
, brwsr_ActiveXControls
, brwsr_JavaScriptVersion
)
SELECT
@sessionId
, @ss_Username_aspx
, @ss_Email_aspx
, @ss_IsAdmin_aspx
, @ss_ActualUsername_aspx
, @ss_ActualIsAdmin_aspx
, @ss_FullName2_aspx
, @ss_HRAdmin
, @ss_eRF_Agency
, @ss_BudEntryAlways
, @sv_APPL_MD_PATH
, @sv_APPL_PHYSICAL_PATH
, @sv_AUTH_TYPE
, @sv_AUTH_USER
, @sv_INSTANCE_META_PATH
, @sv_LOCAL_ADDR
, @sv_LOGON_USER
, @sv_REMOTE_ADDR
, @sv_REMOTE_HOST
, @sv_REMOTE_USER
, @sv_REQUEST_METHOD
, @sv_SCRIPT_NAME
, @sv_SERVER_NAME
, @sv_SERVER_PORT
, @sv_SERVER_PROTOCOL
, @sv_SERVER_SOFTWARE
, @sv_URL
, @sv_HTTP_CONNECTION
, @sv_HTTP_ACCEPT
, @sv_HTTP_ACCEPT_ENCODING
, @sv_HTTP_ACCEPT_LANGUAGE
, @sv_HTTP_COOKIE
, @sv_HTTP_HOST
, @sv_HTTP_USER_AGENT
, @brwsr_computer_name
, @brwsr_MachineName
, @brwsr_Type
, @brwsr_Browser
, @brwsr_Version
, @brwsr_MajorVersion
, @brwsr_MinorVersion
, @brwsr_Platform
, @brwsr_Beta
, @brwsr_Crawler
, @brwsr_AOL
, @brwsr_Win16
, @brwsr_Win32
, @brwsr_Frames
, @brwsr_Tables
, @brwsr_Cookies
, @brwsr_VBScript
, @brwsr_EcmaScriptVersion
, @brwsr_JavaApplets
, @brwsr_ActiveXControls
, @brwsr_JavaScriptVersion
END TRY
BEGIN CATCH
--
SELECT @errorMsg = foo.fnGetErrorTryCatch(0)
SELECT @sessionId = 'Error logging values for session: ' + @sessionId
EXEC dbo.ins_sys_error_log
'foo.insBarBrowserValues'
, @sessionId
, 0
, @errorMsg
, 1
END CATCH
END
Subscribe to:
Posts (Atom)