Showing posts with label exec. Show all posts
Showing posts with label exec. Show all posts

Tuesday, March 27, 2012

getting the backup exec sql agent to work

i know this topic has been covered and i've searched but i can't find the answer.

-SQL server is a diffrent server than my backup server
-i've installed the sql agent option on the backup exec server
-i've installed the client network utility on the remote server

the backup server doesn't see the SQL server databases. any thoughts

could it be a security issue?

thanks!If your production server and the backup servers are different, then you can not schedule the backup of the production server DB on the backup server.
What you need to do is :
1. Verify if the SQLServerAgent service is running with the domain account, not with localsystem account.
2. Map a drive of the backup server to the production server.Give all the rights to the user account, with which the SQLServerAgent service is running.
3. On a production server , schedule a job for backup of the Prod DB to the backup server. and in the backup folder name specify the complete UNC. e.g \\servername\sharename\file.bak.

May be this will help you out.

Thanks|||And also ensure simlar netlib protocol used to connect from remote (backup) server to sQL Server.

The best method is to perform local backup on SQL server and then copy the file across the network, this way you can reduce overhead of stressing SQL during backup process.|||Originally posted by Satya
And also ensure simlar netlib protocol used to connect from remote (backup) server to sQL Server.

The best method is to perform local backup on SQL server and then copy the file across the network, this way you can reduce overhead of stressing SQL during backup process.

ok, one problem though... the sql agent isn't running. the option has been installed, but i can't deploy the agent to the sql server, assuming it's the same method as deploying the windows 2000 remote agent.|||Tried restarting the SQLAgent?|||Originally posted by Satya
Tried restarting the SQLAgent?

unfortunately there is no sql agent "service" on either the sql server or the backup server. when i say that the option has been installed, i mean that the serial number has been added, but i feel that the agent isn't in fact installed.|||SQLAgent will be installed by default alongwith SQL Server installation.
Check whether any issues in starting the service on SQL Server via Enterprise Manager.|||Originally posted by Satya
SQLAgent will be installed by default alongwith SQL Server installation.
Check whether any issues in starting the service on SQL Server via Enterprise Manager.

ok thanks, i've actually schedule a reboot on both server's. i'll post any issues tomorrow. thanks again.|||ok, sql agent service, sql server service are both running fine on the sql server. i think my issue is installing the backup exec sql agent, how do i install this on a remote server?|||Refer to the vendor's documentation about installation.|||Dude, I've got the same problem with my Backup Exec Agent for SQL and Exchange. Neither are listed on the install options remotely window. I've found an easy way around this is to install the full backup exec on you SQL server, that is if it can handle it. In that installation, install the SQL agent. Then you get the little SQL server icon on the thing.

MOD: Edited to remove unnecessary comments.|||Little piece of advice, if you are using Backup Exec, don't use the open files option. It doesn't get along with SQL Server 2000 too well. Also, just backup the backup file directory. Make sure you tell it to skip the program directory with SQL Server in it and the directories with your data and log files. Otherwise you could have several long nights in front of you.

Monday, March 19, 2012

getting results of sp_pkeys in a recordset

Please tell me how to achieve this.

rsPrimaryKey.Open "exec sp_pkeys 'dbo.tmpQuestionnaireDumpReport'"

doesn't work

rsPrimaryKey.Open "sp_pkeys 'dbo.tmpQuestionnaireDumpReport'"

doesn't work either.

I know in Query Analyzer, sp_pkeys 'dbo.tmpQuestionnaireDumpReport'
works.

Please help.Check this one:

<% LANGUAGE="VBScript" %>
<% Response.Expires =0 %>
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
<%

Session("db")="DSN=homebudget;UID=sa;PWD=;"

Set Session("dbcon") = Server.CreateObject("ADODB.Connection")

Session("dbcon").Open Session("db")

set execommand = Server.CreateObject("ADODB.Command")

execommand.CommandText = "sp_pkeys"
execommand.ActiveConnection = Session("dbcon")
execommand.CommandType = &H0004

execommand.Parameters.Append execommand.CreateParameter("table",200,&H0001,8000)

execommand("table")="test"

set rs=execommand.execute

response.write rs(0)+"<br>"
response.write rs(1)

rs.close
set rs=nothing


%>

</BODY>
</HTML>|||Thank you Snail, but I tried that already. The command object doesn't work with sp_pkeys in VB. It would work with any other stored procedure that you define yourself.
This is what worked for me:

select Column_Name
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS t
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE c
ON t.Constraint_Name = c.Constraint_Name
where t.table_name = 'lkuDataAudit'
AND t.Constraint_Type = 'PRIMARY KEY'|||Originally posted by archnam
Thank you Snail, but I tried that already. The command object doesn't work with sp_pkeys in VB. It would work with any other stored procedure that you define yourself.
This is what worked for me:

select Column_Name
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS t
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE c
ON t.Constraint_Name = c.Constraint_Name
where t.table_name = 'lkuDataAudit'
AND t.Constraint_Type = 'PRIMARY KEY'

It works in ASP it has to work in VB (I did not test it in VB).
You have to run command as stored procedure for sp_pkeys.

Friday, February 24, 2012

Getting Error while using exec statement

Hi

I am trying to use exec statement like this

Code Snippet

declare @.a varchar(10)

declare @.b varchar(10)

declare @.c varchar(20)

set @.a = 'SomeData'

select @.c = '@.b=' +'@.a'

exec ('select ' + @.c)

but i am getting this error

Must declare the variable '@.a'.

well we can achieve above problem using

Code Snippet

set @.a = 'SomeData'

select @.b=@.a

select @.b

but i am expecting like this (because i am building a formula)

exec ('select ' + @.c)

please advice

Thanks

You have a scope problem; the '@.a' variable is not known in the domain of your exec string. The scope of the code that is run as part of an "exec string" is completely separate from the scope of the code that compiled the exec string. Therefore, none of your variables -- @.a, @.b, or @.c -- have any meaning from within the execution scope of what gets done while your "exec string" is being performed. You might want to use the "sp_executesql" stored procedure in this case so that you might be able to use these variables as parameters.

Here are some previous posts on the subject:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1087502&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=660466&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=578918&SiteID=1

You also need to understand that there are some inherent problems with dynamic SQL. This article might provide some insights:

Dynamic SQL - The Curse and Blessings of Dynamic SQL
http://www.sommarskog.se/dynamic_sql.html

|||

I've used like this

Code Snippet

set @.a = 'SomeData'

select @.c = '@.b=' +'@.a'

EXEC sp_executesql N'select @.c'

but this time i got this Error

Must declare the variable '@.c'.

please advice

Thanks

|||

You must also pass the parameter to sp_executesql (any the parameters included in the string.

Try something like this:

Code Snippet

set @.a = 'SomeData'

select @.c = '@.b=' +'@.a'

EXECUTE sp_executesql N'SELECT @.c', @.c

Of course, SELECT @.B='SomeData' isn't going to make a lot of sense and will cause an error.

But hey, you just asked for help with passing the parameter -not writing valide SQL statements...

|||

The following sample might help you to understand..

Code Snippet

Declare @.a as int

Declare @.b as int

Declare @.result as varchar(100)

Declare @.FormulaQuery as nvarchar(100)

Set @.a = 10

Set @.b = 20

select @.FormulaQuery = 'Set @.result = (@.b + @.a)'

EXECUTE sp_executesql

@.FormulaQuery --Your Computable Expression/Formula

, N'@.a int, @.b int, @.result int output' -- All the Param definitions

, @.a -- First Param value

, @.b -- Second Param value

, @.result output -- Third Param value which return the value from the expression

Select @.result