Showing posts with label process. Show all posts
Showing posts with label process. Show all posts

Friday, March 30, 2012

is it possible to put the raiseerror in a text file or show it to the user after its been

I am in process of building a website where the user can upload files and then those files are loaded in to a sql server database. I am using some sprocs to scrub the data and then insert them into the production database.. And in my sprpc before and after updating or inserting a record or scrubing... i am returning the count by raising an error. or returning the rownumber where the error occured.. is there any way i can get the raise error part or whatever error i get while scrubing the data and relay it back to the user in a user freindly way or in a text file... or the best thing is can i open smalll window where i can show them what processing is goin on and alert them if there are any errors...

Any help will be appreciated.

Regards

Karen

Take a look forSqlException.Errors. Any SqlError object has the number of error and another informations.

PS.: To another databases, take a look forOleDbException.Errors.

|||

Hi Karenros,

Based on my understanding, you want to use Raiserror to generate an error message and pass it to the client user. Client user may get an alerting message or write it to a text file when getting the error message. If I've misunderstood you ,please feel free to tell me, thanks.

You can put your sqlcommand in a try block and in your catch block, write sqlconnection.errors.message to a text file. Please remember do not assign the severity value of your error message more than 19, or else it maybe cause terminate your connection. Sample code is like the following:

 try { con.Open(); cmd.ExecuteNonQuery(); }catch (SqlException ex) {using(StreamWriter sw=new StreamWriter("your text log file path here")) {foreach (SqlError errin ex.Errors) sw.WriteLine(err.Message+"\n"); } }
Hope my suggestion helps
|||

Chen,

Thanks for your answer. yeah and thats exactly that i wanted to do... so that user would know if the import process was successful or not...

I have tried using sqlexception before with no luck.. may be i didnt import the right header files in order for that work and i have also seen on msdn that we need a sqlinfomessage class or something like to do it.. Pls correct me if i am wrong...

anyways i am gonna give it a try and will let you know...

Regards

Karen

|||

Below is an example of how you can use the InfoMessage event handler:

First you'll have to create an event handler for this event like below:

con.Open();
con.InfoMessage +=new SqlInfoMessageEventHandler(con_InfoMessage);// here i've registered for the event
... set up the command object
cmd.NotificationAutoEnlist =true;
cmd.ExecuteNonQuery();

Then you can go on and write any code you want in that event handler method.

private void con_InfoMessage(object sender, SqlInfoMessageEventArgs e)
{
// your file writing code goes here. The eventArgs e holds errors, messages, source etc.
// you can just use e.ToString() and everything is there for you.
}

Hope this will help.

|||

Hi Karenros,

I've tested the sqlexception code on my local machine and it does work fine. So, maybe you have made some mistakes somewhere else.

However, I think you can also trydhimant 's solution. That's really a good method to solve your problem. thanks

is it possible to process the cube using vb.net/c# which exists in the remote server?

Hi

can we process the cube exists in the remote system, using vb.net/c#

i am able to process in the same system, where analysis service available.

i couln't process this from the client system.

is there any soluctions?

You can use either the AMO or ADOMD libraries to send processing commands to a remote server.

The AMO library is easier to work with for admin tasks, but you would have to redeploy the dll's. Where as any client that has to query the cubes will already need have ADOMD installed.

The following send an XMLA processing command using ADOMD, all you need to do is to create a console application, add a reference to Microsoft.AnalysisServices.AdomdClient and paste in the following:

Code Snippet

Sub Main()

Dim serverName As String = "Server1"

Dim databaseName As String = "Adventure Works DW"

Dim databaseID As String = databaseName

Dim cubeID As String = "Adventure Works"

Dim cn As New AdomdConnection("Provider=MSOLAP;Data Source=" & serverName & ";Initial Catalog=" & databaseName)

Console.WriteLine("Opening Connection...")

cn.Open()

Dim cmd As AdomdCommand

cmd = cn.CreateCommand()

cmd.CommandType = CommandType.Text

cmd.CommandText = "<Batch xmlns=""http://schemas.microsoft.com/analysisservices/2003/engine""><Parallel><Process> <Object>" & _

"<DatabaseID>" & DatabaseID & "</DatabaseID>" & _

"<CubeID>" & cubeID & "</CubeID> " & _

"</Object><Type>ProcessFull</Type><WriteBackTableCreation>UseExisting</WriteBackTableCreation> </Process> </Parallel> </Batch>"

Try

Console.WriteLine("Executing Command...")

cmd.ExecuteNonQuery()

Console.WriteLine("Command Complete")

Catch ex As Exception

Console.WriteLine(" --== ERROR ==--")

Console.WriteLine(ex.Message)

Console.WriteLine()

Finally

cn.Close()

Console.WriteLine("Finished")

End Try

End Sub

|||

Hi Darren

I tried your solution using AdoMd 8.0 on AS 2005,

but it seems that no data are refreshed,

neverthless the command text is executed without any error

Do I miss any other instruction (i.e: 'comitt transaction', .)?

Thanks

|||

I don't think ADOMD 8.0 has the execute method you need 9.0 to work with AS2005.

I just double checked and if your account has permission to process the server, database and cube properties are set correctly it should work. Try running a profiler session on the server and see if there are any errors being thrown at that end.

Monday, March 19, 2012

Is it Possible to a KILL a Process when Process Id is dynamic?

Hi,
I would like to kill a process using the KILL Statement. But the
Process id is dynamic. How can I kill that process?
Example:
Declare @.spid Numeric
SELECT @.spid = spid FROM SPIDTBL
KILL @.spid
Is this possible? How can I do this?
Sevugan.Cuse the process name to determine the spid?
You won't get what you expect,
you get what you deserve, include lessons.
"Sevugan" <Sevugan@.discussions.microsoft.com> wrote in message news:5A855EF7-56B3-4C66-8EF5
-D51DFAEBEC90@.microsoft.com...
> Hi,
> I would like to kill a process using the KILL Statement. But the
> Process id is dynamic. How can I kill that process?
>
> Example:
> Declare @.spid Numeric
> SELECT @.spid = spid FROM SPIDTBL
> KILL @.spid
> Is this possible? How can I do this?
>
> Sevugan.C|||Hi
You have to use Dynamic SQL to do that.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Sevugan" wrote:

> Hi,
> I would like to kill a process using the KILL Statement. But the
> Process id is dynamic. How can I kill that process?
>
> Example:
> Declare @.spid Numeric
> SELECT @.spid = spid FROM SPIDTBL
> KILL @.spid
> Is this possible? How can I do this?
>
> Sevugan.C|||Hi,
DECLARE @.lngProcessId NUMERIC
DECLARE @.svSQL VARCHAR(1000)
SET lngProcessId = 51
SET @.svSQL = 'KILL ' + CONVERT(VARCHAR(10), @.lngProcessId)
--PRINT @.svSQL
EXEC @.svSQL
I have used like the above statements block.
I am executing this inside a stored procedure. I am getting an error like th
is
"Could not find stored procedure 'KILL 51'."
How can I resolve this?
Regards,
Sevugan.C
"Mike Epprecht (SQL MVP)" wrote:
> Hi
> You have to use Dynamic SQL to do that.
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
>
> "Sevugan" wrote:
>|||EXEC (@.svSQL)
If you EXECute a SQL string you have to enclose it in parenthesis, otherwise
it is treated as a procedure name.
Jacco Schalkwijk
SQL Server MVP
"Sevugan" <Sevugan@.discussions.microsoft.com> wrote in message
news:596AD9F2-78A3-4D50-BF89-13FA3F6E0802@.microsoft.com...
> Hi,
> DECLARE @.lngProcessId NUMERIC
> DECLARE @.svSQL VARCHAR(1000)
> SET lngProcessId = 51
> SET @.svSQL = 'KILL ' + CONVERT(VARCHAR(10), @.lngProcessId)
> --PRINT @.svSQL
> EXEC @.svSQL
> I have used like the above statements block.
> I am executing this inside a stored procedure. I am getting an error like
> this
> "Could not find stored procedure 'KILL 51'."
> How can I resolve this?
>
> Regards,
> Sevugan.C
>
> "Mike Epprecht (SQL MVP)" wrote:
>

Friday, March 9, 2012

Is it better to run maintenance sequentially or pralell

we have a maintenance process which does various dbcc maintenance tasks such
as dbreindex, indexdefrag and updateusage. This process can take over 4
hours for some of the databases.
Is there any drawback to running these maintenance processes parallel on all
databases or is it better to run them sequentially?
Hi
There is no issue with running them in parallel, but, can your disk
subsystem keep up? These taks are very IO intensive.
If they run in parallel, the sum of all the jobs might decrease, but each
individual job will take longer to complete.
Regards
Mike
"DBA72" wrote:

> we have a maintenance process which does various dbcc maintenance tasks such
> as dbreindex, indexdefrag and updateusage. This process can take over 4
> hours for some of the databases.
> Is there any drawback to running these maintenance processes parallel on all
> databases or is it better to run them sequentially?

Is it better to run maintenance sequentially or pralell

we have a maintenance process which does various dbcc maintenance tasks such
as dbreindex, indexdefrag and updateusage. This process can take over 4
hours for some of the databases.
Is there any drawback to running these maintenance processes parallel on all
databases or is it better to run them sequentially?Hi
There is no issue with running them in parallel, but, can your disk
subsystem keep up? These taks are very IO intensive.
If they run in parallel, the sum of all the jobs might decrease, but each
individual job will take longer to complete.
Regards
Mike
"DBA72" wrote:

> we have a maintenance process which does various dbcc maintenance tasks su
ch
> as dbreindex, indexdefrag and updateusage. This process can take over 4
> hours for some of the databases.
> Is there any drawback to running these maintenance processes parallel on a
ll
> databases or is it better to run them sequentially?

Is it better to run maintenance sequentially or pralell

we have a maintenance process which does various dbcc maintenance tasks such
as dbreindex, indexdefrag and updateusage. This process can take over 4
hours for some of the databases.
Is there any drawback to running these maintenance processes parallel on all
databases or is it better to run them sequentially?Hi
There is no issue with running them in parallel, but, can your disk
subsystem keep up? These taks are very IO intensive.
If they run in parallel, the sum of all the jobs might decrease, but each
individual job will take longer to complete.
Regards
Mike
"DBA72" wrote:
> we have a maintenance process which does various dbcc maintenance tasks such
> as dbreindex, indexdefrag and updateusage. This process can take over 4
> hours for some of the databases.
> Is there any drawback to running these maintenance processes parallel on all
> databases or is it better to run them sequentially?

Wednesday, March 7, 2012

Is is necessary for a table which will be part of the Replication process to have a and Primary

Hi there,

We're going to use replication on our database. There are tables without any primary key.

Is a primary key necessary for replication?

I have also antoher question: We want to replicate the whole OLTP database (size 30 GB).

Is snapshot replication a suitable mechanisme for this? I thougt snapshot replication overwrites all of the data, not only changed data. Or should we use another replication method?

Thanks in advance,

Patrick de Jong

A primary key is necessary to replicate an article so that a unique record can always be found. Snapshotting a 30gb everytime might not be such a great idea. Transactional is probably a better way to go, depending on your situation.
Tim|||

Yes you need to have a primary key on each table for replication.

Depending on how often your data changes and how frequently you need to have the subscriber updated is the best way to decide if snapshot replication is the best method.

Typically snapshot is not the best option unless you have a very high data change rate and you only need the subscriber updated once or twice per day (or less frequently).

|||

Thanks for the answer's. The really helped me.

1.) My customer has te deside on which fields the pk must come.

2.) I think we will use transactional replication.

Greetz,

Patrick de Jong

|||

Hi Friends,

1.Yes a table involved in Transactional replication should have a primary key defined.Also if u hav opted for transactional publication with updating subscriber,a unique identifier is required for a table.

2.Since it is a OLTP Database it keeps changing frequently,my suggestion would be to go for Transactional Replication.

Always prefer Snapshot replication for datas which do not change frequently (OLAP environment)

Rgds

Deepak

|||

Thanks Deepak,

Today we've made a list of tables without a PK. It seems to be no problem to add the missing PK's because the tabels had an identity which was used as some sort of PK. Tomorrow we will test transactional replication.

Greetz,

Patrick de Jong