Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Friday, March 30, 2012

Scripting a database

I would like to run a job to script a database in case of the database being
deleted. Is there a command to script a databse?
http://www.nigelrivett.net/DMOScriptAllDatabases.html
But you should really rely on backups for that.
"John" wrote:

> I would like to run a job to script a database in case of the database being
> deleted. Is there a command to script a databse?
|||Hi,
Why dont you backup your database daily once using the below command.
backup database <dbname> to disk='d:\backup\dbname.bak' with init
This backup fine can used to restore the entire data and objects incase ur
database is corrupted or deleted.
Thanks
Hari
MCDBA
"John" <John@.discussions.microsoft.com> wrote in message
news:06FF51AC-E494-463B-826A-25C5977EA89D@.microsoft.com...
>I would like to run a job to script a database in case of the database
>being
> deleted. Is there a command to script a databse?
|||You may want to try SCRPTXFR tool that comes along with SQL Server 2000.
This can help you script out database or any objects you want.
HTH
Saleem@.sqlnt.com
"John" wrote:

> I would like to run a job to script a database in case of the database being
> deleted. Is there a command to script a databse?
|||A bunch of options listed here:
http://www.karaszi.com/SQLServer/inf...ate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"John" <John@.discussions.microsoft.com> wrote in message
news:06FF51AC-E494-463B-826A-25C5977EA89D@.microsoft.com...
>I would like to run a job to script a database in case of the database being
> deleted. Is there a command to script a databse?

Scripting a database

I would like to run a job to script a database in case of the database being
deleted. Is there a command to script a databse?http://www.nigelrivett.net/DMOScriptAllDatabases.html
But you should really rely on backups for that.
"John" wrote:
> I would like to run a job to script a database in case of the database being
> deleted. Is there a command to script a databse?|||Hi,
Why dont you backup your database daily once using the below command.
backup database <dbname> to disk='d:\backup\dbname.bak' with init
This backup fine can used to restore the entire data and objects incase ur
database is corrupted or deleted.
Thanks
Hari
MCDBA
"John" <John@.discussions.microsoft.com> wrote in message
news:06FF51AC-E494-463B-826A-25C5977EA89D@.microsoft.com...
>I would like to run a job to script a database in case of the database
>being
> deleted. Is there a command to script a databse?|||You may want to try SCRPTXFR tool that comes along with SQL Server 2000.
This can help you script out database or any objects you want.
HTH
Saleem@.sqlnt.com
"John" wrote:
> I would like to run a job to script a database in case of the database being
> deleted. Is there a command to script a databse?|||A bunch of options listed here:
http://www.karaszi.com/SQLServer/info_generate_script.asp
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"John" <John@.discussions.microsoft.com> wrote in message
news:06FF51AC-E494-463B-826A-25C5977EA89D@.microsoft.com...
>I would like to run a job to script a database in case of the database being
> deleted. Is there a command to script a databse?sql

Tuesday, March 20, 2012

Script out objects

Is there any command to script out tables/stored procedures?
I want to make a process to script out tables every night.

thanks,"neo" <second714@.hotmail.com> wrote in message
news:155f8e7d.0311201526.39f956fb@.posting.google.c om...
> Is there any command to script out tables/stored procedures?
> I want to make a process to script out tables every night.
> thanks,

There's no TSQL command to do this, but you can use the SQLDMO interface to
generate the scripts. Although you could do it from a procedure using
sp_OACreate, it would probably be better to write an external script in your
preferred scripting language - VBScript, Perl, etc. - because it will be
much easier to work with the output files.

Simon|||any sample code in perl or VBScript?

Thanks,|||second714@.hotmail.com (neo) wrote in message news:<155f8e7d.0311211101.32d01304@.posting.google.com>...
> any sample code in perl or VBScript?
> Thanks,

Here's a snippet of VBScript (untested) to script all the tables in a
DB - check the docs for the constants available with the Script
method:

Set oSQL = WScript.CreateObject("SQLDMO.SQLServer2")
oSQL.Name = "MyServer"
oSQL.LoginSecure = True
oSQL.Connect

'Script all tables
For Each oTable In oSQL.Databases("MyDatabase").Tables
If Not oTable.SystemObject Then
oTable.Script 4 Or 262144 Or 520093696 Or 131072 Or 2 Or 64,
"C:\OutputFolder\" + oTable.Name + ".sql"
End If
Next

Simon

Friday, March 9, 2012

Script execution problem

When I try to execute my script using the rs command i canâ't
Generally I use to type:
rs â's http://myServer/reporrserver ; â'i myScript.rss
but they are some predefined values that donâ't allow me to execute my
command because it tries to look for the server:
http://http://myServer/reporrserver/reporrservices
if I change it like this
rs â's myServer â'i myScript.rss
it also does not works because it interpreted it like
http://myServer/reporrservices
Where can I change this default values'I have the same problem in one more server. I donâ't know if it has something
to do. But In the server was the SP1_en and over it I stalled a SP1_de. It
always have the same problem:
Could not connect to server: http://my_server/ReportService.asmx
"Soan" wrote:
> When I try to execute my script using the rs command i canâ't
> Generally I use to type:
> rs â's http://myServer/reporrserver ; â'i myScript.rss
> but they are some predefined values that donâ't allow me to execute my
> command because it tries to look for the server:
> http://http://myServer/reporrserver/reporrservices
> if I change it like this
> rs â's myServer â'i myScript.rss
> it also does not works because it interpreted it like
> http://myServer/reporrservices
> Where can I change this default values'
>

Saturday, February 25, 2012

SCPTXFR.EXE-- Problem with Drop procedure

hi there
I am using SCPTXFR.EXE to generate script of the database(for backup),using following command.

SCPTXFR.EXE /s abc /d aaa /P abc12345 /f D:\HSE0607\SCHEMA.sql /q/r/T

Now the script is generating fine, but what i find that there is no statment like
"if not exists(...) "
for the Stored Procedure( i had applied the /r parameter), for the Create Tables it is there.

Why there is no statment IF NOT EXISTS(...) for Stored Procedure?
I need this Line, how can i do this?
Regards,
Thanks.
Gurpreet S. Gill

hey nobody help me here, but i find the solution at

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=73290

Scorecard A SQL

I am looking for a method to measure SQL performance. For example:
1. execute a SQL first
2. immediately I issue a sql command command which will capture the CPU, IO
and memory used by the SQL commnad which I issued in step 1.
See Profiler in BOL.
"Josephine" <Josephine@.discussions.microsoft.com> wrote in message
news:946E50BF-FA5D-43F6-8D1B-535366F1B1F5@.microsoft.com...
> I am looking for a method to measure SQL performance. For example:
> 1. execute a SQL first
> 2. immediately I issue a sql command command which will capture the CPU,
IO
> and memory used by the SQL commnad which I issued in step 1.
|||Answered in .programming -- please refrain from multi-posting.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"Josephine" <Josephine@.discussions.microsoft.com> wrote in message
news:946E50BF-FA5D-43F6-8D1B-535366F1B1F5@.microsoft.com...
> I am looking for a method to measure SQL performance. For example:
> 1. execute a SQL first
> 2. immediately I issue a sql command command which will capture the CPU,
IO
> and memory used by the SQL commnad which I issued in step 1.

Scorecard A SQL

I am looking for a method to measure SQL performance. For example:
1. execute a SQL first
2. immediately I issue a sql command command which will capture the CPU, IO
and memory used by the SQL commnad which I issued in step 1.See Profiler in BOL.
"Josephine" <Josephine@.discussions.microsoft.com> wrote in message
news:946E50BF-FA5D-43F6-8D1B-535366F1B1F5@.microsoft.com...
> I am looking for a method to measure SQL performance. For example:
> 1. execute a SQL first
> 2. immediately I issue a sql command command which will capture the CPU,
IO
> and memory used by the SQL commnad which I issued in step 1.|||Answered in .programming -- please refrain from multi-posting.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Josephine" <Josephine@.discussions.microsoft.com> wrote in message
news:946E50BF-FA5D-43F6-8D1B-535366F1B1F5@.microsoft.com...
> I am looking for a method to measure SQL performance. For example:
> 1. execute a SQL first
> 2. immediately I issue a sql command command which will capture the CPU,
IO
> and memory used by the SQL commnad which I issued in step 1.

Scorecard A SQL

I am looking for a method to measure SQL performance. For example:
1. execute a SQL first
2. immediately I issue a sql command command which will capture the CPU, IO
and memory used by the SQL commnad which I issued in step 1.See Profiler in BOL.
"Josephine" <Josephine@.discussions.microsoft.com> wrote in message
news:946E50BF-FA5D-43F6-8D1B-535366F1B1F5@.microsoft.com...
> I am looking for a method to measure SQL performance. For example:
> 1. execute a SQL first
> 2. immediately I issue a sql command command which will capture the CPU,
IO
> and memory used by the SQL commnad which I issued in step 1.|||Answered in .programming -- please refrain from multi-posting.
--
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Josephine" <Josephine@.discussions.microsoft.com> wrote in message
news:946E50BF-FA5D-43F6-8D1B-535366F1B1F5@.microsoft.com...
> I am looking for a method to measure SQL performance. For example:
> 1. execute a SQL first
> 2. immediately I issue a sql command command which will capture the CPU,
IO
> and memory used by the SQL commnad which I issued in step 1.

Tuesday, February 21, 2012

SCOPE_IDENTITY returns decimal from SQL command

Hi,

I have an sqlCommand return the ID from the last inserted row. I use SELECT SCOPE_IDENTITY within the SQL.

When I call the function it returns a Decimal instead of an integer??

So I want to convert this to an integer, however this is not liked by the compiler since the overloaded method for the decimal conversion is obviously a decimal, but the ExecuteScalar parameter is of type object.

iReturnVal = decimal.ToInt32(_sqlCommand.ExecuteScalar()); <-- compiler complains...

So I changed to this:

iReturnValue = decimal.ToInt32((decimal)_sqlCommand.ExecuteScalar());

Can someone tell me if this is the right way to do it? Seems messy code to me...

swaino:

iReturnVal = decimal.ToInt32(_sqlCommand.ExecuteScalar()); <-- compiler complains...

Decimal.toint32? I thought it was convert.toint32?

|||

It should already be an integer.

|||

Welldecimal. provides loads of conversion functions.

Also ExecuteScalardoes return an object not an integer..