Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Monday, March 26, 2012

How to flush the buffer to trc file

I want to trace the user logins by using a stored procedure. This script (sp_login_trace) is created by the SQL Profiler tool. (Once this procedure works well, I will use sp_procoption to run it automatically everytime the SQL Server startup.)

After I successfully created sp_login_trace, I run it (exec sp_login_trace). The trace process is started and TraceID is 1. (I use select * from ::fn_trace_getinfo(default) to verify it). However the file size of login_trace.trc is always 0 even after I use Query Ananlysis or Eneterprise manager to let some users to login into the SQL Server instance. (when I use SQL Profiler to start a trace, the trace file size will increase along with users continaully login in). At that time if I use SQL Profiler to open the login_trace.trc file, the system will give me an error message: No data since Empty File.

After I stop and delete the trace process, I find that the file size of login_trace.trc becomes 128K and I can see the login records caught by sp_login_trace if I use SQL Profiler to open this file again.

How can I flush the buffer to trc file frequently without need of stopping trace process?

Thanks for helps in advance.

LeonHere is the script of sp_login_trace (Leon)

CREATE PROCEDURE sp_login_trace
AS
BEGIN
/************************************************** **/
/* The following statements contain the SQL Server Profiler-generated */
/* script to create the trace with the required events and data columns. */
/************************************************** **/
-- Create a queue
DECLARE @.rc int
DECLARE @.TraceID int
DECLARE @.maxfilesize bigint
SET @.maxfilesize = 5
EXEC @.rc = sp_trace_create @.TraceID output, 2,
N'C:\Allprojects\SQL_Server_2000\login_trace',
@.maxfilesize, NULL
IF(@.rc != 0) GOTO error

-- You can't script the client-side file and table.
-- Set the events.
declare @.on bit
set @.on = 1
exec sp_trace_setevent @.TraceID, 14, 1, @.on
exec sp_trace_setevent @.TraceID, 14, 6, @.on
exec sp_trace_setevent @.TraceID, 14, 9, @.on
exec sp_trace_setevent @.TraceID, 14, 10, @.on
exec sp_trace_setevent @.TraceID, 14, 11, @.on
exec sp_trace_setevent @.TraceID, 14, 12, @.on
exec sp_trace_setevent @.TraceID, 14, 13, @.on
exec sp_trace_setevent @.TraceID, 14, 14, @.on
exec sp_trace_setevent @.TraceID, 14, 16, @.on
exec sp_trace_setevent @.TraceID, 14, 17, @.on
exec sp_trace_setevent @.TraceID, 14, 18, @.on

-- Set the Filters
declare @.intfilter int
declare @.bigintfilter bigint

exec sp_trace_setfilter @.TraceID, 10, 0, 7, N'SQL Profiler'

-- Set the trace status to start.
EXEC sp_trace_setstatus @.TraceID, 1

GOTO finish

error:
SELECT ErrorCode=@.rc

finish:
END

GOsql

Friday, March 23, 2012

how to find which object belongs to which File group

Hi
We have a DB in which we have created two file groups. Both are currently
Primary file group. what is the best way to find out which objects are in
which file group?
Thanks,
This doesn't make sense. "Both are currently Primary file group." Only one
filegroup can be the primary filegroup.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> Hi
> We have a DB in which we have created two file groups. Both are currently
> Primary file group. what is the best way to find out which objects are in
> which file group?
> Thanks,
>
|||I can mail you screen shot of EM where two files are listed as primary file
groups.
Moh
"Tom Moreau" wrote:

> This doesn't make sense. "Both are currently Primary file group." Only one
> filegroup can be the primary filegroup.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada tom@.cips.ca
> www.pinpub.com
> "Moh" <mabbas@.Pier1.com> wrote in message
> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
>
>
|||That's not what you said. You said "we have created two file groups". Now,
you're saying you created two files. Which is it?
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:A0603CAB-EDF1-46BF-B449-D989432DF7DF@.microsoft.com...[vbcol=seagreen]
>I can mail you screen shot of EM where two files are listed as primary file
> groups.
> Moh
> "Tom Moreau" wrote:
|||By the way for your knowledge, you can have more than one files belongs to a
File group(Primary FG or any other). you can not have one file belongs to
more than one FG.
Does that mamke sense?
thx,
Moh
Sr DBA
Pier 1 Imports
mabbas@.Pier1.com
"Tom Moreau" wrote:

> This doesn't make sense. "Both are currently Primary file group." Only one
> filegroup can be the primary filegroup.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada tom@.cips.ca
> www.pinpub.com
> "Moh" <mabbas@.Pier1.com> wrote in message
> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
>
>
|||I'm already aware of that. So, what exactly is the problem?
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:D6BCED88-53DB-4DA8-BC41-00E355065EF0@.microsoft.com...[vbcol=seagreen]
> By the way for your knowledge, you can have more than one files belongs to
> a
> File group(Primary FG or any other). you can not have one file belongs to
> more than one FG.
> Does that mamke sense?
> thx,
> Moh
> --
> Sr DBA
> Pier 1 Imports
> mabbas@.Pier1.com
>
> "Tom Moreau" wrote:
|||a filegroup is composed of one or more files
Objects are placed on filegroups and not files
If you wanted to know on which filegroup an object is placed, use sp_help
@.objectname
or the undocumented sp_objectfilegroup @.objid
If you wanted to know the list of all objects that belong to a filegroup
you can query sysindexes and group by the result by groupid
Med Bouchenafa
"Moh" <mabbas@.Pier1.com> a crit dans le message de news:
B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> Hi
> We have a DB in which we have created two file groups. Both are currently
> Primary file group. what is the best way to find out which objects are in
> which file group?
> Thanks,
>
|||Dear M Abbas,
From your 3 posts in this Response, it is clear that you need to improve in
following areas:
1. English Language Skills: There are both grammatical as well as spelling
mistakes in your posts. Example of Grammatical Mistake: ‘Both are currently
Primary file group’. Example of Spelling Mistake: ‘….mamke sense’.
2. Behavioural Skills: Tom Moreau didn’t make any wrong statements. It is
you who made wrong statement in the 1st post by saying ‘…we have created two
file groups. Both are currently Primary file group’. Still, you have
expressed anger in your 3rd post.
3. SQL Server Skills.
Remember, that the first person to benefit from these improvements will be
you. So choice is yours.
"Moh" wrote:
[vbcol=seagreen]
> By the way for your knowledge, you can have more than one files belongs to a
> File group(Primary FG or any other). you can not have one file belongs to
> more than one FG.
> Does that mamke sense?
> thx,
> Moh
> --
> Sr DBA
> Pier 1 Imports
> mabbas@.Pier1.com
>
> "Tom Moreau" wrote:
sql

how to find which object belongs to which File group

Hi
We have a DB in which we have created two file groups. Both are currently
Primary file group. what is the best way to find out which objects are in
which file group?
Thanks,This doesn't make sense. "Both are currently Primary file group." Only one
filegroup can be the primary filegroup.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> Hi
> We have a DB in which we have created two file groups. Both are currently
> Primary file group. what is the best way to find out which objects are in
> which file group?
> Thanks,
>|||I can mail you screen shot of EM where two files are listed as primary file
groups.
Moh
"Tom Moreau" wrote:

> This doesn't make sense. "Both are currently Primary file group." Only on
e
> filegroup can be the primary filegroup.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada tom@.cips.ca
> www.pinpub.com
> "Moh" <mabbas@.Pier1.com> wrote in message
> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
>
>|||That's not what you said. You said "we have created two file groups". Now,
you're saying you created two files. Which is it?
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:A0603CAB-EDF1-46BF-B449-D989432DF7DF@.microsoft.com...[vbcol=seagreen]
>I can mail you screen shot of EM where two files are listed as primary file
> groups.
> Moh
> "Tom Moreau" wrote:
>|||By the way for your knowledge, you can have more than one files belongs to a
File group(Primary FG or any other). you can not have one file belongs to
more than one FG.
Does that mamke sense?
thx,
Moh
--
Sr DBA
Pier 1 Imports
mabbas@.Pier1.com
"Tom Moreau" wrote:

> This doesn't make sense. "Both are currently Primary file group." Only on
e
> filegroup can be the primary filegroup.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada tom@.cips.ca
> www.pinpub.com
> "Moh" <mabbas@.Pier1.com> wrote in message
> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
>
>|||I'm already aware of that. So, what exactly is the problem?
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:D6BCED88-53DB-4DA8-BC41-00E355065EF0@.microsoft.com...[vbcol=seagreen]
> By the way for your knowledge, you can have more than one files belongs to
> a
> File group(Primary FG or any other). you can not have one file belongs to
> more than one FG.
> Does that mamke sense?
> thx,
> Moh
> --
> Sr DBA
> Pier 1 Imports
> mabbas@.Pier1.com
>
> "Tom Moreau" wrote:
>|||a filegroup is composed of one or more files
Objects are placed on filegroups and not files
If you wanted to know on which filegroup an object is placed, use sp_help
@.objectname
or the undocumented sp_objectfilegroup @.objid
If you wanted to know the list of all objects that belong to a filegroup
you can query sysindexes and group by the result by groupid
Med Bouchenafa
"Moh" <mabbas@.Pier1.com> a crit dans le message de news:
B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> Hi
> We have a DB in which we have created two file groups. Both are currently
> Primary file group. what is the best way to find out which objects are in
> which file group?
> Thanks,
>|||Dear M Abbas,
From your 3 posts in this Response, it is clear that you need to improve in
following areas:
1. English Language Skills: There are both grammatical as well as spelling
mistakes in your posts. Example of Grammatical Mistake: ‘Both are currentl
y
Primary file group’. Example of Spelling Mistake: ‘….mamke sense’.
2. Behavioural Skills: Tom Moreau didn’t make any wrong statements. It is
you who made wrong statement in the 1st post by saying ‘…we have created
two
file groups. Both are currently Primary file group’. Still, you have
expressed anger in your 3rd post.
3. SQL Server Skills.
Remember, that the first person to benefit from these improvements will be
you. So choice is yours.
"Moh" wrote:
[vbcol=seagreen]
> By the way for your knowledge, you can have more than one files belongs to
a
> File group(Primary FG or any other). you can not have one file belongs to
> more than one FG.
> Does that mamke sense?
> thx,
> Moh
> --
> Sr DBA
> Pier 1 Imports
> mabbas@.Pier1.com
>
> "Tom Moreau" wrote:
>

how to find which object belongs to which File group

Hi
We have a DB in which we have created two file groups. Both are currently
Primary file group. what is the best way to find out which objects are in
which file group?
Thanks,This doesn't make sense. "Both are currently Primary file group." Only one
filegroup can be the primary filegroup.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> Hi
> We have a DB in which we have created two file groups. Both are currently
> Primary file group. what is the best way to find out which objects are in
> which file group?
> Thanks,
>|||I can mail you screen shot of EM where two files are listed as primary file
groups.
Moh
"Tom Moreau" wrote:
> This doesn't make sense. "Both are currently Primary file group." Only one
> filegroup can be the primary filegroup.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada tom@.cips.ca
> www.pinpub.com
> "Moh" <mabbas@.Pier1.com> wrote in message
> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> > Hi
> > We have a DB in which we have created two file groups. Both are currently
> > Primary file group. what is the best way to find out which objects are in
> > which file group?
> >
> > Thanks,
> >
> >
>
>|||That's not what you said. You said "we have created two file groups". Now,
you're saying you created two files. Which is it?
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:A0603CAB-EDF1-46BF-B449-D989432DF7DF@.microsoft.com...
>I can mail you screen shot of EM where two files are listed as primary file
> groups.
> Moh
> "Tom Moreau" wrote:
>> This doesn't make sense. "Both are currently Primary file group." Only
>> one
>> filegroup can be the primary filegroup.
>> --
>> Tom
>> ----
>> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
>> SQL Server MVP
>> Columnist, SQL Server Professional
>> Toronto, ON Canada tom@.cips.ca
>> www.pinpub.com
>> "Moh" <mabbas@.Pier1.com> wrote in message
>> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
>> > Hi
>> > We have a DB in which we have created two file groups. Both are
>> > currently
>> > Primary file group. what is the best way to find out which objects are
>> > in
>> > which file group?
>> >
>> > Thanks,
>> >
>> >
>>|||By the way for your knowledge, you can have more than one files belongs to a
File group(Primary FG or any other). you can not have one file belongs to
more than one FG.
Does that mamke sense?
thx,
Moh
--
Sr DBA
Pier 1 Imports
mabbas@.Pier1.com
"Tom Moreau" wrote:
> This doesn't make sense. "Both are currently Primary file group." Only one
> filegroup can be the primary filegroup.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada tom@.cips.ca
> www.pinpub.com
> "Moh" <mabbas@.Pier1.com> wrote in message
> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> > Hi
> > We have a DB in which we have created two file groups. Both are currently
> > Primary file group. what is the best way to find out which objects are in
> > which file group?
> >
> > Thanks,
> >
> >
>
>|||I'm already aware of that. So, what exactly is the problem?
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada tom@.cips.ca
www.pinpub.com
"Moh" <mabbas@.Pier1.com> wrote in message
news:D6BCED88-53DB-4DA8-BC41-00E355065EF0@.microsoft.com...
> By the way for your knowledge, you can have more than one files belongs to
> a
> File group(Primary FG or any other). you can not have one file belongs to
> more than one FG.
> Does that mamke sense?
> thx,
> Moh
> --
> Sr DBA
> Pier 1 Imports
> mabbas@.Pier1.com
>
> "Tom Moreau" wrote:
>> This doesn't make sense. "Both are currently Primary file group." Only
>> one
>> filegroup can be the primary filegroup.
>> --
>> Tom
>> ----
>> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
>> SQL Server MVP
>> Columnist, SQL Server Professional
>> Toronto, ON Canada tom@.cips.ca
>> www.pinpub.com
>> "Moh" <mabbas@.Pier1.com> wrote in message
>> news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
>> > Hi
>> > We have a DB in which we have created two file groups. Both are
>> > currently
>> > Primary file group. what is the best way to find out which objects are
>> > in
>> > which file group?
>> >
>> > Thanks,
>> >
>> >
>>|||a filegroup is composed of one or more files
Objects are placed on filegroups and not files
If you wanted to know on which filegroup an object is placed, use sp_help
@.objectname
or the undocumented sp_objectfilegroup @.objid
If you wanted to know the list of all objects that belong to a filegroup
you can query sysindexes and group by the result by groupid
Med Bouchenafa
"Moh" <mabbas@.Pier1.com> a écrit dans le message de news:
B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> Hi
> We have a DB in which we have created two file groups. Both are currently
> Primary file group. what is the best way to find out which objects are in
> which file group?
> Thanks,
>|||Dear M Abbas,
From your 3 posts in this Response, it is clear that you need to improve in
following areas:
1. English Language Skills: There are both grammatical as well as spelling
mistakes in your posts. Example of Grammatical Mistake: â'Both are currently
Primary file groupâ'. Example of Spelling Mistake: â'â?¦.mamke senseâ'.
2. Behavioural Skills: Tom Moreau didnâ't make any wrong statements. It is
you who made wrong statement in the 1st post by saying â'â?¦we have created two
file groups. Both are currently Primary file groupâ'. Still, you have
expressed anger in your 3rd post.
3. SQL Server Skills.
Remember, that the first person to benefit from these improvements will be
you. So choice is yours.
"Moh" wrote:
> By the way for your knowledge, you can have more than one files belongs to a
> File group(Primary FG or any other). you can not have one file belongs to
> more than one FG.
> Does that mamke sense?
> thx,
> Moh
> --
> Sr DBA
> Pier 1 Imports
> mabbas@.Pier1.com
>
> "Tom Moreau" wrote:
> > This doesn't make sense. "Both are currently Primary file group." Only one
> > filegroup can be the primary filegroup.
> >
> > --
> > Tom
> >
> > ----
> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> > SQL Server MVP
> > Columnist, SQL Server Professional
> > Toronto, ON Canada tom@.cips.ca
> > www.pinpub.com
> >
> > "Moh" <mabbas@.Pier1.com> wrote in message
> > news:B93809BB-695B-4EED-9CE0-B3154B7D8301@.microsoft.com...
> > > Hi
> > > We have a DB in which we have created two file groups. Both are currently
> > > Primary file group. what is the best way to find out which objects are in
> > > which file group?
> > >
> > > Thanks,

Monday, March 12, 2012

How to find out what it the the poison message.

Hallo,
I have some problems to handle the poison messages.

Messages are exchanged between 2 databases on the same SQL Server instance.
I created a Trigger on the insert , that call the sp that begin the conversation(10 minutes Timeout) and send the message to the target queue.

On the target queue I activated a SP and the main code is:

BEGIN TRANSACTION

WAIT FOR (Receive (1) ..) timeout 5000

IF (@.ErrorSave <> 0)

BEGIN

INSERT INTO [TestSender].[dbo].[tblErrorXMLMessages] VALUES ();

END

ELSE

if (@.messagetypeName = N'Message')

BEGIN

exec [dbo].[sp_ProcessMessage] @.message_body

END

ELSE IF (@.messagetypeName = N'EndOfStream')

BEGIN

END CONVERSATION @.dialog

END

COMMIT TRANSACTION

My communication has a strange behaviour:

if I type

Begin

insert into TriggerTable values(XMLMessage)

insert into TriggerTable values(XMLMessage)

....

insert into TriggerTable values(XMLMessage)

end

Everything work fine but If I write an insert of 1000 message coming from an another table and I use the

cursor login after I while the transmission stop because the Target queue become inactive.
I can see my messages stuck in the Initiator transmission_queue so I think that there is some Poison message that cause 5 rollback and disable the receiver queue.

First I would like to isolate the wrong message and carry on with the insert, my application doesn't have to stop the conversation or return any error, but If I use the Sql server Debugger I'm not able to debug the Target queue's stored procedure.

I suppose that some error happens on the Target queue's stored procedure but how can I first at all find it out?

Maybe it has something to do with the transition wrapped around the RECEIVE command?

thank you for any helps!

Marina B.

If an activated procedure hits and error it will report it to the ERRORLOG file as well as to the systen event log (EventVwr.exe). check there to see if any error is present.

You can determine if poison message happens by either monitoring with Profiler the Broker/Broker:Activation events or subscribying to an event notification (see CREATE EVENT NOTIFICATION in BOL) for the QUEUE_DISABLED event on the queue. But I cannot say how to determine which is the poisson message, this is application specific. You can try to turn off activation and manually run the procedure to see if it works as expected.

|||

Hi,
there was not error on the Event Log so after further investigation I found out that the error was raised by the sp that process the message.

Now I have anyway another small problem because I'm not able to avoid the rolleback on the receiving queue and the disabling of the Target queue.

The SP that process the message raise an Error to the caller (the Target queue's activation SP).

In the BEGIN catch I log the error on a table and I want to continue to process all the messages till the queue is empty.
But it seems that the the Target queue's activation SP always rollback because I can see the the Error is inserted 5 times into the log table and then the Target's queues is disabled.

This are the main parts of the code:

Target's queue activation SP:

Begin try

Begin Transaction

WAITFOR (

RECEIVE top(1) ....)

if (@.@.ROWCOUNT = 0)

BEGIN

ROLLBACK TRANSACTION

BREAK

END

SET @.ErrorSave = @.@.ERROR ;

IF (@.ErrorSave <> 0)

INSERT INTO tblLOG VALUES(...)
ELSE
exec sp_ProcessMessage @.Message
COMMIT
END TRANSACTION
END TRY

BEGIN CATCH

BEGIN

INSERT INTO tblLOG values(...)
COMMIT

END

END CATCH


This is the exec sp_ProcessMessage @.Message
BEGIN TRY

BEGIN TRANSACTION
... Do something that cause an error
COMMIT
END TRY
BEGIN CATCH

IF XACT_STATE() <> 0

BEGIN

ROLLBACK TRANSACTION ;

END

exec [dbo].usp_RethrowError;

END CATCH

the usp_RethrowError stored procedure raise the error to the caller.

How can I avoid the Rollback in case something goes wrong in the SP that Process the message?
I suppose that in the moment I use a try...catch block in the Target's queue activation SP I have also to delete the statements:

SET @.ErrorSave = @.@.ERROR ;

IF (@.ErrorSave <> 0)

INSERT INTO tblLOG VALUES(...)

because is case of error on the receive command the sp will execute the code in the BEGIN CATCH..END CATCH..isn't?

Thank you

Marina B.

How to find out what it the the poison message.

Hallo,
I have some problems to handle the poison messages.

Messages are exchanged between 2 databases on the same SQL Server instance.
I created a Trigger on the insert , that call the sp that begin the conversation(10 minutes Timeout) and send the message to the target queue.

On the target queue I activated a SP and the main code is:

BEGIN TRANSACTION

WAIT FOR (Receive (1) ..) timeout 5000

IF (@.ErrorSave <> 0)

BEGIN

INSERT INTO [TestSender].[dbo].[tblErrorXMLMessages] VALUES ();

END

ELSE

if (@.messagetypeName = N'Message')

BEGIN

exec [dbo].[sp_ProcessMessage] @.message_body

END

ELSE IF (@.messagetypeName = N'EndOfStream')

BEGIN

END CONVERSATION @.dialog

END

COMMIT TRANSACTION

My communication has a strange behaviour:

if I type

Begin

insert into TriggerTable values(XMLMessage)

insert into TriggerTable values(XMLMessage)

....

insert into TriggerTable values(XMLMessage)

end

Everything work fine but If I write an insert of 1000 message coming from an another table and I use the

cursor login after I while the transmission stop because the Target queue become inactive.
I can see my messages stuck in the Initiator transmission_queue so I think that there is some Poison message that cause 5 rollback and disable the receiver queue.

First I would like to isolate the wrong message and carry on with the insert, my application doesn't have to stop the conversation or return any error, but If I use the Sql server Debugger I'm not able to debug the Target queue's stored procedure.

I suppose that some error happens on the Target queue's stored procedure but how can I first at all find it out?

Maybe it has something to do with the transition wrapped around the RECEIVE command?

thank you for any helps!

Marina B.

If an activated procedure hits and error it will report it to the ERRORLOG file as well as to the systen event log (EventVwr.exe). check there to see if any error is present.

You can determine if poison message happens by either monitoring with Profiler the Broker/Broker:Activation events or subscribying to an event notification (see CREATE EVENT NOTIFICATION in BOL) for the QUEUE_DISABLED event on the queue. But I cannot say how to determine which is the poisson message, this is application specific. You can try to turn off activation and manually run the procedure to see if it works as expected.

|||

Hi,
there was not error on the Event Log so after further investigation I found out that the error was raised by the sp that process the message.

Now I have anyway another small problem because I'm not able to avoid the rolleback on the receiving queue and the disabling of the Target queue.

The SP that process the message raise an Error to the caller (the Target queue's activation SP).

In the BEGIN catch I log the error on a table and I want to continue to process all the messages till the queue is empty.
But it seems that the the Target queue's activation SP always rollback because I can see the the Error is inserted 5 times into the log table and then the Target's queues is disabled.

This are the main parts of the code:

Target's queue activation SP:

Begin try

Begin Transaction

WAITFOR (

RECEIVE top(1) ....)

if (@.@.ROWCOUNT = 0)

BEGIN

ROLLBACK TRANSACTION

BREAK

END

SET @.ErrorSave = @.@.ERROR ;

IF (@.ErrorSave <> 0)

INSERT INTO tblLOG VALUES(...)
ELSE
exec sp_ProcessMessage @.Message
COMMIT
END TRANSACTION
END TRY

BEGIN CATCH

BEGIN

INSERT INTO tblLOG values(...)
COMMIT

END

END CATCH


This is the exec sp_ProcessMessage @.Message
BEGIN TRY

BEGIN TRANSACTION
... Do something that cause an error
COMMIT
END TRY
BEGIN CATCH

IF XACT_STATE() <> 0

BEGIN

ROLLBACK TRANSACTION ;

END

exec [dbo].usp_RethrowError;

END CATCH

the usp_RethrowError stored procedure raise the error to the caller.

How can I avoid the Rollback in case something goes wrong in the SP that Process the message?
I suppose that in the moment I use a try...catch block in the Target's queue activation SP I have also to delete the statements:

SET @.ErrorSave = @.@.ERROR ;

IF (@.ErrorSave <> 0)

INSERT INTO tblLOG VALUES(...)

because is case of error on the receive command the sp will execute the code in the BEGIN CATCH..END CATCH..isn't?

Thank you

Marina B.

How to find out Usersinfo using JDBC Connection to SQL Server

Hi..
I want to find out the List of users created in SQL Server.
Im using type 4 Driver to Connect SQL Server.
Regards
maruthi.List of active users, users for a database or logins for the sql server ?|||select * from master.dbo.syslogins
select * from master.dbo.sysxlogins
select * from your_database.dbo.sysusers|||Thanks

the problem is solved.

How to find out PublicKeyBlob

I have created a custom authentication for Reporting Services, and it works great if I edit the RsSvrPolicy.congif like the following:

<CodeGroup class="UnionCodeGroup" version="1" Name="SecurityExtensionCodeGroup" Description="Code group for the security extension" PermissionSetName="FullTrust">
<IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer\bin\myfile.dll" />

But the guideline says a strong named assemly is better, so I created a strong named assembly and registered it in the GAC, but how do I find out the PublicKeyBlob to enter in the config file?

Regards AndreasUse 'sn -Tp assemblyfilename' from a VisualStudio command prompt.|||After you run the command, I think if you RightClick -> SelectAll, then hit the Enter key, it should copy the entire command prompt contents to the clipboard for pasting.|||

Ahh, thank you!

// Andreas

Friday, March 9, 2012

how to find out if a column has a default (sp_bindefault)

How do I find out if a column has a default bound to it (created with
sp_bindefault)?See if you can massage the query below:
SELECT c.name, OBJECT_NAME(c.cdefault)
FROM syscolumns c
WHERE OBJECTPROPERTY(c.cdefault, 'IsConstraint') = 1 ;
Anith|||Jacobus Terhorst wrote:
> How do I find out if a column has a default bound to it (created with
> sp_bindefault)?
It's undocumented and not supported, but you can use sp_MShelpcolumns.
Have a look at the text column.
create table A12345 (
col1 int not null default 5,
col2 nvarchar(10) not null default N'ABC')
exec sp_MShelpcolumns N'[dbo].[A12345]', @.orderby = 'id'
go
Drop Table A12345
Go
David Gugick
Imceda Software
www.imceda.com|||Thank you!
Jacobus Terhorst
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:uMDkACpJFHA.1172@.TK2MSFTNGP12.phx.gbl...
> See if you can massage the query below:
> SELECT c.name, OBJECT_NAME(c.cdefault)
> FROM syscolumns c
> WHERE OBJECTPROPERTY(c.cdefault, 'IsConstraint') = 1 ;
> --
> Anith
>

How to Find Out Check Columns?

Hi,
I'm working on a database having default constraint names created by SQL
Server 2000. Is it possible to find out which columns the check works on or
even to see the check code?
TIA,
Axel DahmenScript the constraints from the Object Browser in Query Analyzer.
OR:
SELECT * FROM information_schema.check_constraints
David Portas
SQL Server MVP
--|||Try,
use northwind
go
select
object_name(so.parent_obj),
col_name(so.parent_obj, so.info),
sc.text
from
sysobjects as so
inner join
syscomments as sc
on so.[id] = sc.[id]
where
so.xtype = 'C'
and so.parent_obj = object_id('dbo.Products')
go
Microsoft said:
"Querying the system tables directly may not provide accurate information if
system tables are changed in future releases."
AMB
"Axel Dahmen" wrote:

> Hi,
> I'm working on a database having default constraint names created by SQL
> Server 2000. Is it possible to find out which columns the check works on o
r
> even to see the check code?
> TIA,
> Axel Dahmen
>
>|||Great! Thanks a lot!
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> schrieb im
Newsbeitrag news:1108664961.589752.136520@.l41g2000cwc.googlegroups.com...
> Script the constraints from the Object Browser in Query Analyzer.
> OR:
> SELECT * FROM information_schema.check_constraints
> --
> David Portas
> SQL Server MVP
> --
>

How to find objects by owner

I have an application wich generates database objects (mostly views) within
the application itself. So I have a bunch of views created by a user who I
have to delete but I can't do it because he is owning objects.
Can I write a query to list al the objects owned by this user?
Regardsselect name from sysobjects where uid = user_id('NameOfOwner')
"Zekske" wrote:
> I have an application wich generates database objects (mostly views) within
> the application itself. So I have a bunch of views created by a user who I
> have to delete but I can't do it because he is owning objects.
> Can I write a query to list al the objects owned by this user?
> Regards|||You could use the inbuilt views - just change 'dbo' to your user...
-- tables and views
select * from information_schema.tables
where table_schema = 'dbo'
-- stored procs and functions
select routine_name from information_schema.routines
where routine_schema = 'dbo'
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

How to find objects by owner

I have an application wich generates database objects (mostly views) within
the application itself. So I have a bunch of views created by a user who I
have to delete but I can't do it because he is owning objects.
Can I write a query to list al the objects owned by this user?
Regards
select name from sysobjects where uid = user_id('NameOfOwner')
"Zekske" wrote:

> I have an application wich generates database objects (mostly views) within
> the application itself. So I have a bunch of views created by a user who I
> have to delete but I can't do it because he is owning objects.
> Can I write a query to list al the objects owned by this user?
> Regards
|||You could use the inbuilt views - just change 'dbo' to your user...
-- tables and views
select * from information_schema.tables
where table_schema = 'dbo'
-- stored procs and functions
select routine_name from information_schema.routines
where routine_schema = 'dbo'
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

How to find objects by owner

I have an application wich generates database objects (mostly views) within
the application itself. So I have a bunch of views created by a user who I
have to delete but I can't do it because he is owning objects.
Can I write a query to list al the objects owned by this user?
Regardsselect name from sysobjects where uid = user_id('NameOfOwner')
"Zekske" wrote:

> I have an application wich generates database objects (mostly views) withi
n
> the application itself. So I have a bunch of views created by a user who I
> have to delete but I can't do it because he is owning objects.
> Can I write a query to list al the objects owned by this user?
> Regards|||You could use the inbuilt views - just change 'dbo' to your user...
-- tables and views
select * from information_schema.tables
where table_schema = 'dbo'
-- stored procs and functions
select routine_name from information_schema.routines
where routine_schema = 'dbo'
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

Sunday, February 19, 2012

How to find a table...

Hi all,
I have a large database with many tables created by a 3rd party vendor.
I would like to be able to find which table a field belongs to without
searching through every single table. Is there some tool out there to
enable such a search?
ThanksSelect * from INFORMATION_SCHEMA.COLUMNS Where Column_Name like
'<YourColumnName>'
HTH, Jens Suessmeyer.|||To find all occurences of a *column* named "foo" use
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME='foo'
"AGB" <andyglbl@.gmail.com> wrote in message
news:1126623946.728072.130780@.f14g2000cwb.googlegroups.com...
> Hi all,
> I have a large database with many tables created by a 3rd party vendor.
> I would like to be able to find which table a field belongs to without
> searching through every single table. Is there some tool out there to
> enable such a search?
> Thanks
>|||Here's an example, that searches for tables with a column name of 'Alias':
SELECT TABLE_SCHEMA AS TableOwner, TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'Alias'
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"AGB" <andyglbl@.gmail.com> wrote in message
news:1126623946.728072.130780@.f14g2000cwb.googlegroups.com...
Hi all,
I have a large database with many tables created by a 3rd party vendor.
I would like to be able to find which table a field belongs to without
searching through every single table. Is there some tool out there to
enable such a search?
Thanks|||There is a feature in Query Analyzer for searching objects across a server
by name and/or object type. Look under the menu option Tools.. Object
Search.. New..
"AGB" <andyglbl@.gmail.com> wrote in message
news:1126623946.728072.130780@.f14g2000cwb.googlegroups.com...
> Hi all,
> I have a large database with many tables created by a 3rd party vendor.
> I would like to be able to find which table a field belongs to without
> searching through every single table. Is there some tool out there to
> enable such a search?
> Thanks
>|||hi,
All replies to this will solve the problem ... no doubt about this.
There is one interesting tool to perform such activities more in advance
SQLcompare...from redgate.
thanxs
Kishor
"AGB" wrote:

> Hi all,
> I have a large database with many tables created by a 3rd party vendor.
> I would like to be able to find which table a field belongs to without
> searching through every single table. Is there some tool out there to
> enable such a search?
> Thanks
>