not so active anymore, yet still stuff and code that works in Perl, bash, sh, PLSQL, TSQL, NZPLSQL , XML, HTML, XSL, C#, Scala , Python, Teradata SQL, cmd batch scripts, Oracle , MySql some old Java stuff , Linux , DB2 , Sun Solaris , NSIS , VB 6.0 , some old Essbase VB API and plain English - all this in non-user friendly fashion combined with occasionally strong statements and opinions about IT best practices, Agile Development , energy ... dump end ...Wait - https://qto.fi
Search This Blog
2009-02-12
how-to debug in sql server 2005
/** Object: Table [dbo].[tbData_Debug] Script Date: 02/12/2009 22:30:03 **/ SET ANSI_NULLS ON GO
SET QUOTED_IDENTIFIER ON GO
SET ANSI_PADDING ON GO
CREATE TABLE [dbo].tbData_Debug NULL, [colDomain_User] varchar NULL, [colMsg] varchar NULL, [colDebugLevel] [int] NULL, [colDebugMsg] varchar NULL, [colPageName] varchar NULL, [colClassName] varchar NULL, [colMethodName] varchar NULL, [colMethodNameGui] varchar NULL, [colRet] [int] NULL, [colLineNumber] [int] NULL, [colLineNumberGui] [int] NULL, [colProcedureName] varchar NULL, [colProcedureStep] varchar NULL ) ON [PRIMARY]
GO
SET ANSI_PADDING OFF GO
USE [db] GO /** Object: StoredProcedure [dbo].[procUtils_AppDebug] Script Date: 02/12/2009 22:29:24 **/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO
ALTER PROCEDURE [dbo].[procUtils_AppDebug] (
@ret int = null OUT,
@msgIn varchar(4000) = null , -- the msg which the user has seen
@msgOut varchar(4000) = null OUT , -- the msg which the user has seen
@domain_user varchar(200) = null , -- the domain user echoing the message
@debugMsgIn varchar(4000) = null , -- the debug msg for internal use
@debugMsgOut varchar(4000) = null OUT, -- the debug msg for internal use
@pageName varchar(200) = null , -- the pageName originator of error
@className varchar(200) = null , -- the class Name orinator of error
@methodName varchar(200) = null , -- the methodName where the last error occured
@methodNameGui varchar(4000) = null , -- the methodNameOfTheGui where the last error occured
@lineNumber int = null , -- the line number of the line issueing the error
@lineNumberGui int = null, -- the line number of the line issueing the error
@procedureName varchar(200) = null , -- the procedureName currently envoked @procedureStep varchar(4000) = null -- the steps of the procedure concatenated )
AS
BEGIN -- proc start
SET NOCOUNT ON;
BEGIN TRY --begin try
declare @debugLevel int
select @debugLevel = Debug_Level from User_tb where Domain_Name = @domain_user
/*
select * from tbData_Debug order by 1 desc
delete from tbData_Debug
*/
insert into tbData_Debug ( colNiceTime , colDomain_User , colMsg , colDebugLevel ,
colDebugMsg , colPageName , colClassName , colMethodName , colMethodNameGui ,
colRet , colLineNumber , colLineNumberGui , colProcedureName , colProcedureStep) values ( dbo.funcGetNiceTime() , @domain_user , @msgIn , @debugLevel ,@debugMsgIn , @pageName , @className , @methodName ,@MethodNameGui , @ret , @lineNumber , @lineNumberGui , @procedureName , @procedureStep)
set @debugMsgOut = @debugMsgIn
set @msgOut = 'Action Registered'
set @ret = @@ERROR
return @ret
END TRY --end try
BEGIN CATCH
PRINT 'In CATCH block.
Error number: ' + CAST(ERROR_NUMBER() AS varchar(10)) + '
Error message: ' + ERROR_MESSAGE() + '
Error severity: ' + CAST(ERROR_SEVERITY() AS varchar(10)) + '
Error state: ' + CAST(ERROR_STATE() AS varchar(10)) + '
XACT_STATE: ' + CAST(XACT_STATE() AS varchar(10));
set @debugMsgOut = 'error at [procUtils_AppDebug]--- Error number: ' + CAST(ERROR_NUMBER() AS varchar(10)) + 'Error message: ' + ERROR_MESSAGE() + 'Error severity: ' +
CAST(ERROR_SEVERITY() AS varchar(10)) + 'Error state: ' + CAST(ERROR_STATE() AS varchar(10)) + 'XACT_STATE: ' + CAST(XACT_STATE() AS varchar(10))
set @msgIn= 'error while saving application error info into database'
insert into tbData_Debug ( colMsg ) values ( @msgIn )
set @debugMsgOut = @debugMsgIn + @debugMsgOut
set @msgOut = 'Action Registration failed'
set @ret = 1
END CATCH
return @ret
END --procedure end
/*
procUtils_AppDebug
Records events from the Application Layer
20090121
Yordan Georgiev
USE [db]
GO
DECLARE @return_value int,
@ret int,
@msgIn varchar(max),
@debugmsg varchar(4000)
SELECT @ret = 1
SELECT @msgIn = N'msg'
SELECT @debugmsg = N'before'
EXEC @return_value = [dbo].[procUtils_AppDebug]
@ret = @ret OUTPUT,
@msgIn = @msgIn OUTPUT,
@domain_user = N'domain_user',
@debugmsg = @debugmsg OUTPUT,
@methodName = N'methodName'
SELECT @ret as N'@ret',
@msgIn as N'@msgIn',
@debugmsg as N'@debugmsg'
SELECT 'Return Value' = @return_value
select * from tbData_Debug order by 1 desc
GO
*/
1 comment:
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!
About Me
Labels
Blog Archive
- November (1)
- December (1)
- November (1)
- January (3)
- December (1)
- November (2)
- August (7)
- July (1)
- May (3)
- April (1)
- March (5)
- February (1)
- January (1)
- December (7)
- November (1)
- October (2)
- September (3)
- August (4)
- July (1)
- June (1)
- May (7)
- April (5)
- March (3)
- January (2)
- December (3)
- November (1)
- October (5)
- September (3)
- July (3)
- April (1)
- March (4)
- February (4)
- November (2)
- September (5)
- August (3)
- June (3)
- May (6)
- April (8)
- March (1)
- February (4)
- January (1)
- December (5)
- November (4)
- October (7)
- September (3)
- August (3)
- May (1)
- April (2)
- March (1)
- December (5)
- November (5)
- October (4)
- September (4)
- August (1)
- July (13)
- June (1)
- May (13)
- April (14)
- March (10)
- February (7)
- January (3)
- December (4)
- November (3)
- October (8)
- September (5)
- August (9)
- July (4)
- May (10)
- April (6)
- March (11)
- February (4)
- January (13)
- December (19)
- November (15)
- October (32)
- September (16)
- August (26)
- July (37)
- June (34)
- May (26)
- April (32)
- March (26)
- February (8)
- December (2)
- November (5)
- October (10)
- September (17)
- August (6)
- July (15)
- June (24)
- May (26)
- April (29)
- March (18)
- February (26)
- January (16)
- December (7)
- November (16)
- October (4)
- September (10)
- June (3)
- May (21)
- April (4)
- March (13)
- February (3)
- January (14)
- December (12)
- November (1)
- October (3)
- September (6)
- August (2)
- July (4)
- June (4)
- May (3)
- April (11)
- March (11)
- February (16)
- January (5)
- December (22)
- November (23)
- October (5)
- July (14)
Translate with Google Translate
My Blog List
-
Getting the Current TabItem when the Tab is not selected in WPF - [image: Banner] This is a quick reminder to self on how to retrieve a TabItem from a WPF TabControl *when the tab is not currently selected* because I ru...1 week ago
-
Major solar energy project operational in western Michigan - TV reports 11,000 solar panels are installed on a 17-acre plot of land just south of Grand Valley State University's main campus in Allendale. Consumers ...8 years ago
-
-
-
great article, but I prefer the combination of backups and recovery services, have you ever heard about the service of fix sql sever mdf file, provided by Recovery Toolbox for SQL Server? Indeed, it is not possible to write a separate article for all database-related issues
ReplyDelete