Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Sunday, March 11, 2012

[scripts] prompting user

please, how to promt user in mu sql 2005 script? For example, I need user to
confirm some operations.. .

Thx in advance"fireball" <fireball@.onet.kropka.euwrote in message
news:emdkdr$7ro$1@.nemesis.news.tpi.pl...

Quote:

Originally Posted by

please, how to promt user in mu sql 2005 script? For example, I need user
to confirm some operations.. .
>


Unless something has changed in T-SQL 2005 that I'm not aware of, you can't.

Quote:

Originally Posted by

Thx in advance
>

|||that is cruel.|||so, I neither I can't call one script from another (from the batch I run),
right?

:(|||"fireball" <fireball@.onet.kropka.euwrote in message
news:eme57k$mnn$1@.nemesis.news.tpi.pl...

Quote:

Originally Posted by

so, I neither I can't call one script from another (from the batch I run),
right?


No, you can do that.

Quote:

Originally Posted by

>
:(
>

|||fireball (fireball@.onet.kropka.eu) writes:

Quote:

Originally Posted by

please, how to promt user in mu sql 2005 script? For example, I need
user to confirm some operations.. .


The answer is you don't. SQL Server is a server application, and
server applications communicate with client applications, not with
end users.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Sql is 4gl and asking it to do 3gl operations like prompts and loops
and if then else logic should be illegal although now allowed.

fireball wrote:

Quote:

Originally Posted by

please, how to promt user in mu sql 2005 script? For example, I need user to
confirm some operations.. .
>
Thx in advance

|||well,
is that possible at least, to exit script on given condition?|||fireball wrote:

Quote:

Originally Posted by

well,
is that possible at least, to exit script on given condition?


Do you want a return code or not? If you don't want a return code
then you can wirite:
If <conditionReturn
If you want a return code then you need to use a stored proc and inside
the procedure you can write:
If <conditionreturn 100
In your application you can check for status of the called procedure
and take action based on that.|||fireball (fireball@.onet.kropka.eu) writes:

Quote:

Originally Posted by

is that possible at least, to exit script on given condition?


Depends on how run it. In SQLCMD or OSQL you can exit immediately
by using a RAISERROR with state 127:

RAISERROR('Got a good reson for taking the easy way out now', 16, 127)

This does not work from Query Analyzer or Mgmt Studio.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Uzytkownik "Erland Sommarskog" <esquel@.sommarskog.senapisal w wiadomosci

Quote:

Originally Posted by

RAISERROR('Got a good reson for taking the easy way out now', 16, 127)


Uzytkownik <othellomy@.yahoo.comnapisal w wiadomosci

Quote:

Originally Posted by

If <conditionReturn


all this hepled.

Saturday, February 11, 2012

@working_directory

We are trying to create generic scripts to enable/configure replication at
various customer sites that purchase our product. As I have no way of
knowing which drive they will use for data and log file storage I would like
to set the @.working_directory parameter for sp_adddistpublisher to null.
Will this cause the default UNC (\\<servername>\<drive letter>$\Program
Files\Microsoft SQL Server\MSSQL\ReplData) to be used?
Thanks,
Mark
Hi Mark, the SQL2005 version of sp_adddistpublisher will provide the
behavior that you want but unfortunately the change has not been (and will
unlikey be) backported to any versions of SQL2000. In SQL2005, we use the
following xp_instance_regread call to find out the root data folder path of
SQL Server so you may be able to do something similar:
EXECUTE @.retcode = master.dbo.xp_instance_regread
'HKEY_LOCAL_MACHINE',
'SOFTWARE\Microsoft\MSSQLServer\Setup',
'SQLDataRoot',
@.param = @.working_directory OUTPUT,
@.no_output = 'no_output'
Hope that helps.
-Raymond
"mrprice" <mrprice@.discussions.microsoft.com> wrote in message
news:22060AF0-414E-4BA0-8C98-FA643FCFB83C@.microsoft.com...
> We are trying to create generic scripts to enable/configure replication at
> various customer sites that purchase our product. As I have no way of
> knowing which drive they will use for data and log file storage I would
> like
> to set the @.working_directory parameter for sp_adddistpublisher to null.
> Will this cause the default UNC (\\<servername>\<drive letter>$\Program
> Files\Microsoft SQL Server\MSSQL\ReplData) to be used?
> Thanks,
> Mark
>
|||Raymond,
As it needs to be a UNC, I'm doing this? Look reasonable?
DECLARE @.retcode INT
DECLARE @.pubworkingdir SYSNAME
EXECUTE @.retcode = master.dbo.xp_instance_regread
'HKEY_LOCAL_MACHINE',
'SOFTWARE\Microsoft\MSSQLServer\Replication',
'WorkingDirectory',
@.pubworkingdir OUTPUT,
'no_output'
SET @.pubworkingdir = '\\' + @.@.SERVERNAME + '\' + REPLACE(@.pubworkingdir,
':', '$')
Thanks,
Mark
|||You may want to use serverproperty('MachineName') instead of @.@.servername to
get the "real" server name. Other than that, your code snippet looks fine to
me (you should, of course, test it extensively in your environment...)
"mrprice" <mrprice@.discussions.microsoft.com> wrote in message
news:060F1CA5-EDCE-4EC8-824A-CD5F12F05D21@.microsoft.com...
> Raymond,
> As it needs to be a UNC, I'm doing this? Look reasonable?
> DECLARE @.retcode INT
> DECLARE @.pubworkingdir SYSNAME
> EXECUTE @.retcode = master.dbo.xp_instance_regread
> 'HKEY_LOCAL_MACHINE',
> 'SOFTWARE\Microsoft\MSSQLServer\Replication',
> 'WorkingDirectory',
> @.pubworkingdir OUTPUT,
> 'no_output'
> SET @.pubworkingdir = '\\' + @.@.SERVERNAME + '\' + REPLACE(@.pubworkingdir,
> ':', '$')
> Thanks,
> Mark

Thursday, February 9, 2012

@@servername returns NULL

I am trying to script out the creation of database scripts. I am trying
to use @.@.servername in the statement. I found out the select
@.@.servername returns NULL. I used sp_dropserver to drop any servernames
first, restarted SQL, ran sp_addserver 'servername' to add the
servername, restarted SQL. select @.@.servername still returns NULL...

Any ideas why this may be happening?

Thanks,

TGru

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!tgru (tgru@.devdex.com) writes:
> I am trying to script out the creation of database scripts. I am trying
> to use @.@.servername in the statement. I found out the select
> @.@.servername returns NULL. I used sp_dropserver to drop any servernames
> first, restarted SQL, ran sp_addserver 'servername' to add the
> servername, restarted SQL. select @.@.servername still returns NULL...
> Any ideas why this may be happening?

Did you specify 'local' as the second parameter to sp_addserver?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland is the man!!

Thanks, I battle syntax on a daily basis...

TGru

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!