Showing posts with label helloi. Show all posts
Showing posts with label helloi. Show all posts

Thursday, March 29, 2012

executing SQL script from Command promt not working

Hello
I am trying to execute SQl script from command prom like this :

C:\Inetput\wwwroot> osql -U sa -P -i MyComics.sql

(uid=sa and pwd=)

and I got the result like this :

[Shared Memory]SQl Server deos not exist or access denied
[Shared Memory]Connection Open (Connect()).

I already check the SQL server , it's running.
what do I do now?

Thanks in advanceAre you certain that the user name and password is correct? Are you certain that this instance of SQL Server is the main instance and not a named instance?|||Hello

thank for the response.

from my understanding sa is the default user name of SQL Server 2000 and password is blank. I did not set any password for my SQL server.

I'm really new to SQL server, if you have any advice I'll appreciate.|||Try osql -E <other parameters, except user and password
-E uses a trusted connection. Unless you set an sa password while installing SQL Server, SQL Server is set to use Windows authentication. You need to specify Mixed Mode authentication. You can change to mixed mode security in Enterprise Manager. Right click database, select properties, set Authentication to SQL Server and Windows. Make sure you set a good sa password. DO NOT leave it as blank!

Tuesday, March 27, 2012

EXECUTING PACKAGES from vb.net

Hello:
I have a web application from where I need to execute a DTS,
my platform is SQL 2000 and .net 2003. From a Vb.net module I want to
execute the package, my question is: does the package need to be STRUCTURED
STORAGE FILE or could it be SQL SERVER package (local to the server) in
order to be executed from .NET.
- If I can execute the local SQL package , how can I do it?
- If I can only execute STRUCTURED STORAGE FILE, how can I get ride off of
the multiple versions that are created everytime the package is opened and I
make any update on it.
ThanksGina Hernandez wrote:
> Hello:
> I have a web application from where I need to execute a DTS,
> my platform is SQL 2000 and .net 2003. From a Vb.net module I want
to
> execute the package, my question is: does the package need to be STRUCTUR
ED
> STORAGE FILE or could it be SQL SERVER package (local to the server) in
> order to be executed from .NET.
> - If I can execute the local SQL package , how can I do it?
> - If I can only execute STRUCTURED STORAGE FILE, how can I get ride off o
f
> the multiple versions that are created everytime the package is opened and
I
> make any update on it.
> Thanks
>
I assume you could go both ways, or you could use the dts com class in
.NET, without using a storage file or an sql package.
Steven|||> execute the package, my question is: does the package need to be
> STRUCTURED STORAGE FILE or could it be SQL SERVER package (local to the
> server) in order to be executed from .NET.
To expand on Steven's response, you can use the DtsPackage LoadFromSqlServer
or LoadFromStorageFile methods depending on the package location.

> how can I get ride off of the multiple versions that are created everytime
> the package is opened and I make any update on it.
If you delete the file before saving (or save to a new name and rename),
only the current version is saved.
Hope this helps.
Dan Guzman
SQL Server MVP
"Gina Hernandez" <pdwhitt@.nospam.wdsinc.com> wrote in message
news:uIHXLnlBGHA.3156@.TK2MSFTNGP12.phx.gbl...
> Hello:
> I have a web application from where I need to execute a DTS,
> my platform is SQL 2000 and .net 2003. From a Vb.net module I want
> to execute the package, my question is: does the package need to be
> STRUCTURED STORAGE FILE or could it be SQL SERVER package (local to the
> server) in order to be executed from .NET.
> - If I can execute the local SQL package , how can I do it?
> - If I can only execute STRUCTURED STORAGE FILE, how can I get ride off
> of the multiple versions that are created everytime the package is opened
> and I make any update on it.
> Thanks
>

Executing osql commands through batch file

Hello

I have a script ,which runs with osql

The script is :

osql -E
declare @.cmd nvarchar(1000)
declare @.cmd2 nvarchar(1000)
declare @.state1 varchar(100)
declare @.message varchar(100)
set @.message = ''
-- Build command to determine state of SQLSERVERAGENT service on Master Server
SET @.CMD = 'create table #state (state varchar(2000))' + char(10) +
'declare @.cmdx varchar(1000)' + char(10) +
'insert into #state EXEC master..xp_servicecontrol ''''QueryState'''', ''''SQLSERVERAGENT'' +
+ char(10) + 'select @.state=state from #state' + char(10) +
'drop table #state'
-- Build command to execute command that determines state of service being monitored
set @.cmd2 = 'declare @.state varchar(100)' + char(10) +
'exec ' + rtrim(@.@.servername) + '.master.dbo.sp_executesql N''' + @.CMD + ''',' +
'N''@.state varchar(100) out'',' +
'@.state out' + char(10) +
'set @.state1 = @.state'
-- Execute command and return state of service being monitored
exec master.dbo.sp_executesql @.cmd2,N'@.state1 varchar(100) out',@.state1 out
-- Is the service that was monitored not
IF (UPPER(@.state1) <> 'RUNNING.')
--if @.state1 <1 'Running.'
begin
-- Display message that primary monitor is down
select @.message = @.message+char(13)+ @.@.servername + ' -' + 'Sql Server Agent Not Running'+char(13)
print 'Master server "' + rtrim(@.@.servername) + '" for monitoring is not available.'
exec master.dbo.xp_smtp_sendmail

It works fine when I run it on the command line prompt.
And I receive a mail , if the server agent is running.

But when I save it as bat file and try to run , it stops and doesnot even give an error.

Can anyone let me know what I can do.

ThanksHello

I have got it working.

Just I need to use :

osql -E -iC:\serveragent.sql -oC:\outputfile.txt

Thanks

Monday, March 12, 2012

execute stored procedure durning merge replication

Hello
I have merge replication with dynamic filters and I have to create
dynamically table just before merge replication starts. Is there any
possibility of exec stored procedure durnig merge replication or just
before it?
Thanks in advance,
marcin
Hi
My problem is more complicated.
I create dynamicly subscription from Pocket PC where I set Host_Name for
dynamic filters.
How can I add merge agent job from source code ?
Any ideas ?
Thanks,
Marcin
Paul Ibison wrote:

> Sure - just add another step to the merge agent's job and
> change the workflow accordingly. I have had issues with
> using sp_start_job in job steps - there is no guarantee
> that a step will complete fully before the next one
> starts, but in the case of a script call this should be
> ok.
> Rgds,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>