Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Thursday, March 29, 2012

Automating installation of ODBC data source

Is there a script anyone has that will automate the addition of an
access database to the OBDC datasources in control panel.

ThanksHere's something that I did in Kixtart for our environment. It was last
November, so I don't recall all the details. Some key values I would expect to
vary, as I have six (6) scripts for all the data sources we have. I figured out
what to do by checking the registry, and creating a script that would duplicate
what I had done manually.

Also, since it was three (3) PCs ago, I don't recall what OS it was. Since I've
been here, I've had three (3) PCs. This one is XP, the previous was w2k and the
first? MAY have been NT. I mention this as I don't know if it'll require any
changes in the script.

Here it is (between the lines of '=========='):
==========
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;
; Kixtart script - create Data Source Entries for HTE applications ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;
; ;
; 11-10-03 tcs initial creation date. ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;
;
; *** NOTE ***
;
; Path to 'cwbodbc.dll' must be modified as necessary. For example,
; as originally written, the path is:
;
; d:\IBM\Client Access\Shared\cwbodbc.dll
;
; which was correct for the machine upon which this script was developed.
;
;================================================= ====================
;
;Setup ODBC for HTE DB2 database [Begin]
;Create the necessary keys, values and expressions for current user.
$CR=chr(13)
$HteDSN='Finance'
$KeyBase='HKEY_CURRENT_USER\Software\ODBC\ODBC.INI '
$Key1='$KeyBase\ODBC Data Sources'
$Key2='$KeyBase\$HteDSN'
if existkey($Key2) ; key doesn't exist, so create it.
$result=addkey($Key2)
$result=writevalue($Key1,'$HteDSN','Client Access ODBC Driver
(32-bit)','REG_SZ')

$result=writevalue($Key2,'AllowDataCompression','0 ','REG_SZ')
$result=writevalue($Key2,'AllowUnsupportedChar','0 ','REG_SZ')
$result=writevalue($Key2,'AlwaysScrollable','0','R EG_SZ')
$result=writevalue($Key2,'BlockSizeKB','32','REG_S Z')
$result=writevalue($Key2,'CCSID','','REG_SZ')
$result=writevalue($Key2,'CommitMode','0','REG_SZ' )
$result=writevalue($Key2,'ConnectionType','0','REG _SZ')
$result=writevalue($Key2,'DateFormat','5','REG_SZ' )
$result=writevalue($Key2,'DateSeparator','1','REG_ SZ')
$result=writevalue($Key2,'Decimal','0','REG_SZ')
$result=writevalue($Key2,'DefaultLibraries','atlib , prlib, pilib, gmlib,
fmlib, mrlib, crlib, gflib, falib, wflib, lxlib, malib','REG_SZ')
$result=writevalue($Key2,'DefaultPkgLibrary','QGPL ','REG_SZ')
$result=writevalue($Key2,'Description','Client Access Express ODBC data
source','REG_SZ')
$result=writevalue($Key2,'Driver','d:\IBM\Client
Access\Shared\cwbodbc.dll','REG_SZ')
$result=writevalue($Key2,'ExtendedDynamic','0','RE G_SZ')
$result=writevalue($Key2,'ForceTranslation','0','R EG_SZ')
$result=writevalue($Key2,'LanguageID','ENU','REG_S Z')
$result=writevalue($Key2,'LazyClose','0','REG_SZ')
$result=writevalue($Key2,'LibraryView','0','REG_SZ ')
$result=writevalue($Key2,'ManagedDataSource','0',' REG_SZ')
$result=writevalue($Key2,'MaxFieldLength','32','RE G_SZ')
$result=writevalue($Key2,'Naming','0','REG_SZ')
$result=writevalue($Key2,'ODBCRemarks','0','REG_SZ ')
$result=writevalue($Key2,'PreFetch','0','REG_SZ')
$result=writevalue($Key2,'RecordBlocking','2','REG _SZ')
$result=writevalue($Key2,'SearchPattern','1','REG_ SZ')
$result=writevalue($Key2,'Signon','0','REG_SZ')
$result=writevalue($Key2,'SortSequence','0','REG_S Z')
$result=writevalue($Key2,'SortTable','','REG_SZ')
$result=writevalue($Key2,'SortWeight','0','REG_SZ' )
$result=writevalue($Key2,'SSL','2','REG_SZ')
$result=writevalue($Key2,'System','10.4.1.1','REG_ SZ')
$result=writevalue($Key2,'TimeFormat','0','REG_SZ' )
$result=writevalue($Key2,'TimeSeparator','0','REG_ SZ')
$result=writevalue($Key2,'TranslationDLL','','REG_ SZ')
$result=writevalue($Key2,'TranslationOption','','R EG_SZ')
$result=writevalue($Key2,'','','REG_SZ')
$result=writevalue($Key2,'','','REG_SZ')
$result=writevalue($Key2,'','','REG_SZ')
$result=writevalue($Key2,'','','REG_SZ')
endif
;Setup ODBC for HTE DB2 Server [End]
==========
I don't think that I fully finished, so I'd tread lightly, but hopefully this'll
get you started.

Tom

On Wed, 23 Jul 2003 10:49:53 +0000 (UTC), SkunkDave
<dave_casserly@.totalise.co.uk> wrote:

>Is there a script anyone has that will automate the addition of an
>access database to the OBDC datasources in control panel.
>Thanks

Automating Generate Script in Command Line

Hello,
Is there a way to automate Generate Script in 2005, so by clicking a link it
generates script which is using a command line and not using Management
Studio Tasks->Generate Script ?
--
MikeMike
There are a new objects library SQL SMO (.NET) to deal with such reports.
Previously we used ( and if you still have SQL Server 2000) SQL DMO object
library
"Mike9900" <Mike9900@.discussions.microsoft.com> wrote in message
news:3F3E26B8-C60A-4E37-A7DC-87BA9A515A1D@.microsoft.com...
> Hello,
> Is there a way to automate Generate Script in 2005, so by clicking a link
> it
> generates script which is using a command line and not using Management
> Studio Tasks->Generate Script ?
> --
> Mike|||What do you want to script ?
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--|||SQl Server 2005 database.
--
Mike
"Jens" wrote:

> What do you want to script ?
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>

Tuesday, March 27, 2012

Automating Daily Database Inserts.

Hi can anybody please provide me information on how i can automate a vb.net script to insert records in to a SQL Server database everyday. I know that the Scheduled Tasks tool in Control Panel must be used but i am not sure about the VB.net code. Opening up the DB and inserting records is no problem its just geting the script to run using the Scheduled Tasks tool. Any other type of script that opens up a DB or updates it even a vb.net script that executes using the Scheduled Tasks tool would be helpful.

Thanks in advance for the help.

ImranDoes it have to be run via DotNet? It would be simpler if you could have the Sql Server Agent run some SQL or execute a sproc. Alternatively you could have DTS do it and Sql Server Agent would trigger the DTS package.

If you need to create the scheudle from DotNet you would need to create a Service that manages when things run and then at the appropriate time trigger your code. If you need to go this route I can post some code to get you started but it will be in C# so you'll have to translate.|||The service is the best idea.

Simply, yet very bad and chessy, but effective, is to build an aspx page that performs the work, and place the following command in a batch file:


"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://MyScriptURL"

You could then use the built in Scheduler (AT.exe from a command prompt) within 2000 or NT4, or any other scheduler, to run the batch file nightly.

Of course, the great risk here is anyone can fire that URL at anytime and then it runs more than once. If it's a critical, must be bullet-proof task, go with the service. If you want something quick and dirty, that's temporary, give the above a shot.

Brian|||McMurdoStation

i was going to post a question in the forum about this and i saw this thread.
can you give some advice on how to get started...link to some tutorial, i am writing a vb.net app tht will call some SP's ( the Sp's will add transactions to customer transactions table). i need to create an html file (i can already do this). basically i have the whole prog working. i can run it manually. i just need to schedule it so it runs automatically every night ( at the specified time).

thanks.|||This article should get you started for creating a DotNet scheduler service.|||Hi McMurdoStation,
yes could you post the code please.

Thanks for the help.|||Hi Brian,
is the command that you specified above the only command that needs to go in to the batch file or do some other commands need to be put in there. In other words do i need to create a file called for example updatedb.bat and put the following bit of code in to it in the following way.


C:\Program Files\Internet Explorer\IEXPLORE.EXE http://localhost/metrics/updatedb.aspx

or do some other bits of code need to go in there aswell? Thanks for your help its much appreciated.|||All you should need is the above one line of code. You can test it by running it from a cmd prompt yourself. All it does is fire IE with the address that follows, and of course, the page renders.

If you can schedule that command, w/o having to use a batch file, then that will work as well. It's just nice to keep the comand in a batch file so it can be updated w/o having to touch a scheduler.

I, again, do recommend the service. My idea is just a temp or short-term workaround.

Brian|||ASPNester,

The link posted above describes how to create a scheduler service with VB.Net. It's probably easier to work from that rather than try to translate my C# code.|||thanks McMurdoStation...will spend some tiem trying to go through the article and understanding it.
thanks.|||Brian thanks, the code worked.

However as you mention its not really an ideal method. Do you know of any web sites that have tutorials for creating "Windows?" Service, or any books that have instructions on creating window services, the URL that McDurmock gave uses Visual Studio so its not really much use for me.

Thanks for all you r help anyway.|||Wrox has a good book called "Visual Basic .NET Windows Services Handbook". It's just under 200 pages, and meant to get you going fast. However, it assumes you have VS.NET. Of course, you don't need VS.NET. It shows most code, so you should be able to get by.

I've only written one service, but was up to speed in just a few days with the book

ISBN 1-86100-772-8, ~$30.

Brian|||ok mate thanks for all your help.

Automatics restore script

I am setting up a job to automatically restore the standby database.
This is to test our tape backups. I need to passon the latest full
backup and log file names to the tape system to extract the files. How
do I get the file names? I would like to store these file names in temp
table and pass on to tape system one by one to extract it to local
disk. Do I need to query the msdb of primary or backup directory?
Please suggest sql to achieve this.
Thanks
Tram
If you do SQL Backups then you shouldn't need to know the file names because
the backup is referenced by database name. Are you doing file system
backups? That's not recommended unless you detach the database first.
Query the sysfiles system table for the physical file names.
David Portas
SQL Server MVP
|||A I need to restore from third party tape subsyste, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.
|||A I need to restore from third party tape subsystem, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.
|||A I need to restore from third party tape subsystem, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.
|||Hi
If it is 3rd party, ask the 3rd party vendor how you can script a restore
using their command line tools.
If SQL Server did not back the data up itself (to disk or a backup device
that it can control) it can't get the data back for you by itself.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"tram" <tram_e@.hotmail.com> wrote in message
news:1117887893.908844.130200@.f14g2000cwb.googlegr oups.com...
>A I need to restore from third party tape subsystem, the enterprise
> manager doen't recognize the restore fle anmes. I have to develop the
> script to retiriev the latest backup and logs therafter.
>
|||Thirty party vendor has command to resore the files. I have to passon
the filename as parameter, that is latest bak file and corresponding
trn files.
|||Hi
Have you looked at the backupfile and backupset tables in msdb to see if it
has what you need?
John
"tram" <tram_e@.hotmail.com> wrote in message
news:1117889003.683361.325430@.g43g2000cwa.googlegr oups.com...
> Thirty party vendor has command to resore the files. I have to passon
> the filename as parameter, that is latest bak file and corresponding
> trn files.
>

Automatics restore script

I am setting up a job to automatically restore the standby database.
This is to test our tape backups. I need to passon the latest full
backup and log file names to the tape system to extract the files. How
do I get the file names? I would like to store these file names in temp
table and pass on to tape system one by one to extract it to local
disk. Do I need to query the msdb of primary or backup directory?
Please suggest sql to achieve this.
Thanks
TramIf you do SQL Backups then you shouldn't need to know the file names because
the backup is referenced by database name. Are you doing file system
backups? That's not recommended unless you detach the database first.
Query the sysfiles system table for the physical file names.
--
David Portas
SQL Server MVP
--|||A I need to restore from third party tape subsyste, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.|||A I need to restore from third party tape subsystem, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.|||A I need to restore from third party tape subsystem, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.|||Hi
If it is 3rd party, ask the 3rd party vendor how you can script a restore
using their command line tools.
If SQL Server did not back the data up itself (to disk or a backup device
that it can control) it can't get the data back for you by itself.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"tram" <tram_e@.hotmail.com> wrote in message
news:1117887893.908844.130200@.f14g2000cwb.googlegroups.com...
>A I need to restore from third party tape subsystem, the enterprise
> manager doen't recognize the restore fle anmes. I have to develop the
> script to retiriev the latest backup and logs therafter.
>|||Thirty party vendor has command to resore the files. I have to passon
the filename as parameter, that is latest bak file and corresponding
trn files.|||Hi
Have you looked at the backupfile and backupset tables in msdb to see if it
has what you need?
John
"tram" <tram_e@.hotmail.com> wrote in message
news:1117889003.683361.325430@.g43g2000cwa.googlegroups.com...
> Thirty party vendor has command to resore the files. I have to passon
> the filename as parameter, that is latest bak file and corresponding
> trn files.
>sql

Automatics restore script

I am setting up a job to automatically restore the standby database.
This is to test our tape backups. I need to passon the latest full
backup and log file names to the tape system to extract the files. How
do I get the file names? I would like to store these file names in temp
table and pass on to tape system one by one to extract it to local
disk. Do I need to query the msdb of primary or backup directory?
Please suggest sql to achieve this.
Thanks
TramIf you do SQL Backups then you shouldn't need to know the file names because
the backup is referenced by database name. Are you doing file system
backups? That's not recommended unless you detach the database first.
Query the sysfiles system table for the physical file names.
David Portas
SQL Server MVP
--|||A I need to restore from third party tape subsyste, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.|||A I need to restore from third party tape subsystem, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.|||A I need to restore from third party tape subsystem, the enterprise
manager doen't recognize the restore fle anmes. I have to develop the
script to retiriev the latest backup and logs therafter.|||Hi
If it is 3rd party, ask the 3rd party vendor how you can script a restore
using their command line tools.
If SQL Server did not back the data up itself (to disk or a backup device
that it can control) it can't get the data back for you by itself.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"tram" <tram_e@.hotmail.com> wrote in message
news:1117887893.908844.130200@.f14g2000cwb.googlegroups.com...
>A I need to restore from third party tape subsystem, the enterprise
> manager doen't recognize the restore fle anmes. I have to develop the
> script to retiriev the latest backup and logs therafter.
>|||Thirty party vendor has command to resore the files. I have to passon
the filename as parameter, that is latest bak file and corresponding
trn files.|||Hi
Have you looked at the backupfile and backupset tables in msdb to see if it
has what you need?
John
"tram" <tram_e@.hotmail.com> wrote in message
news:1117889003.683361.325430@.g43g2000cwa.googlegroups.com...
> Thirty party vendor has command to resore the files. I have to passon
> the filename as parameter, that is latest bak file and corresponding
> trn files.
>

Automatically Transfer logins/users to a script file

For DR purposes, I need to have a job that automatically scripts out the
creation of the logins and users for a database.
Looked at using sp_helprevlogin, but that is for different versions of SQL.
Looked at SCPTXFR to script out MASTER, but it is not including the logins,
only users.
Anyone have any ideas?
Hi
"Kristen" wrote:

> For DR purposes, I need to have a job that automatically scripts out the
> creation of the logins and users for a database.
> Looked at using sp_helprevlogin, but that is for different versions of SQL.
> Looked at SCPTXFR to script out MASTER, but it is not including the logins,
> only users.
> Anyone have any ideas?
Have you looked at DMO and the logins collection?
John
|||No....I will look into that. Thanks!
"John Bell" wrote:

> Hi
> "Kristen" wrote:
>
> Have you looked at DMO and the logins collection?
> John
|||Can you think of another way that does not entail alot of programming?
"John Bell" wrote:

> Hi
> "Kristen" wrote:
>
> Have you looked at DMO and the logins collection?
> John
|||Hi
"Kristen" wrote:

> Can you think of another way that does not entail alot of programming?
>
I would expect the DMO to take less then 12 lines of code!
I don't reallty see why you have an issue with sp_help_rev_login, it will
reside in the master database and have the same interface regardless of SQL
Server version!
Why not just backup the system databases?
John
|||> I would expect the DMO to take less then 12 lines of code!
I'm not certain how well DMO handles SID number and password, so make sure you verify this. Based on
for what purpose you want this script, it might be very important for the logins to have the same
SID and pwd as in the originating SQL Server, so make sure you check that DMO does it the right way.
This is, btw, the beauty of using sp_help_revlogin.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:8B6C82C3-6A1E-4EE0-B6FF-B5385176DA9F@.microsoft.com...
> Hi
> "Kristen" wrote:
>
> I would expect the DMO to take less then 12 lines of code!
> I don't reallty see why you have an issue with sp_help_rev_login, it will
> reside in the master database and have the same interface regardless of SQL
> Server version!
> Why not just backup the system databases?
> John
>

Automatically Transfer logins/users to a script file

For DR purposes, I need to have a job that automatically scripts out the
creation of the logins and users for a database.
Looked at using sp_helprevlogin, but that is for different versions of SQL.
Looked at SCPTXFR to script out MASTER, but it is not including the logins,
only users.
Anyone have any ideas?Hi
"Kristen" wrote:
> For DR purposes, I need to have a job that automatically scripts out the
> creation of the logins and users for a database.
> Looked at using sp_helprevlogin, but that is for different versions of SQL.
> Looked at SCPTXFR to script out MASTER, but it is not including the logins,
> only users.
> Anyone have any ideas?
Have you looked at DMO and the logins collection?
John|||No....I will look into that. Thanks!
"John Bell" wrote:
> Hi
> "Kristen" wrote:
> > For DR purposes, I need to have a job that automatically scripts out the
> > creation of the logins and users for a database.
> > Looked at using sp_helprevlogin, but that is for different versions of SQL.
> > Looked at SCPTXFR to script out MASTER, but it is not including the logins,
> > only users.
> > Anyone have any ideas?
> Have you looked at DMO and the logins collection?
> John|||Can you think of another way that does not entail alot of programming?
"John Bell" wrote:
> Hi
> "Kristen" wrote:
> > For DR purposes, I need to have a job that automatically scripts out the
> > creation of the logins and users for a database.
> > Looked at using sp_helprevlogin, but that is for different versions of SQL.
> > Looked at SCPTXFR to script out MASTER, but it is not including the logins,
> > only users.
> > Anyone have any ideas?
> Have you looked at DMO and the logins collection?
> John|||Hi
"Kristen" wrote:
> Can you think of another way that does not entail alot of programming?
>
I would expect the DMO to take less then 12 lines of code!
I don't reallty see why you have an issue with sp_help_rev_login, it will
reside in the master database and have the same interface regardless of SQL
Server version!
Why not just backup the system databases?
John|||> I would expect the DMO to take less then 12 lines of code!
I'm not certain how well DMO handles SID number and password, so make sure you verify this. Based on
for what purpose you want this script, it might be very important for the logins to have the same
SID and pwd as in the originating SQL Server, so make sure you check that DMO does it the right way.
This is, btw, the beauty of using sp_help_revlogin.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:8B6C82C3-6A1E-4EE0-B6FF-B5385176DA9F@.microsoft.com...
> Hi
> "Kristen" wrote:
>> Can you think of another way that does not entail alot of programming?
> I would expect the DMO to take less then 12 lines of code!
> I don't reallty see why you have an issue with sp_help_rev_login, it will
> reside in the master database and have the same interface regardless of SQL
> Server version!
> Why not just backup the system databases?
> John
>

Automatically Transfer logins/users to a script file

For DR purposes, I need to have a job that automatically scripts out the
creation of the logins and users for a database.
Looked at using sp_helprevlogin, but that is for different versions of SQL.
Looked at SCPTXFR to script out MASTER, but it is not including the logins,
only users.
Anyone have any ideas?Hi
"Kristen" wrote:

> For DR purposes, I need to have a job that automatically scripts out the
> creation of the logins and users for a database.
> Looked at using sp_helprevlogin, but that is for different versions of SQL
.
> Looked at SCPTXFR to script out MASTER, but it is not including the logins
,
> only users.
> Anyone have any ideas?
Have you looked at DMO and the logins collection?
John|||No....I will look into that. Thanks!
"John Bell" wrote:

> Hi
> "Kristen" wrote:
>
> Have you looked at DMO and the logins collection?
> John|||Can you think of another way that does not entail alot of programming?
"John Bell" wrote:

> Hi
> "Kristen" wrote:
>
> Have you looked at DMO and the logins collection?
> John|||Hi
"Kristen" wrote:

> Can you think of another way that does not entail alot of programming?
>
I would expect the DMO to take less then 12 lines of code!
I don't reallty see why you have an issue with sp_help_rev_login, it will
reside in the master database and have the same interface regardless of SQL
Server version!
Why not just backup the system databases?
John|||> I would expect the DMO to take less then 12 lines of code!
I'm not certain how well DMO handles SID number and password, so make sure y
ou verify this. Based on
for what purpose you want this script, it might be very important for the lo
gins to have the same
SID and pwd as in the originating SQL Server, so make sure you check that DM
O does it the right way.
This is, btw, the beauty of using sp_help_revlogin.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:8B6C82C3-6A1E-4EE0-B6FF-B5385176DA9F@.microsoft.com...
> Hi
> "Kristen" wrote:
>
> I would expect the DMO to take less then 12 lines of code!
> I don't reallty see why you have an issue with sp_help_rev_login, it will
> reside in the master database and have the same interface regardless of SQ
L
> Server version!
> Why not just backup the system databases?
> John
>|||If you contact me, I will share a script. It will script logins,
users, system and database role membership, and indiviudal grants with
passwords preserved in SQL Server 2005.
Terry

automatically stop/restart sql service

I would like to be able to automatically stop a sql service running on sql
2005 express, use a script to transfer files over to another server and
restart the service automatically.
Any ideas of how I can do this?
You can use a batch file that does a net stop, copy and net start. Schedule
it with task scheduler.
Jason Massie
Web: http://statisticsio.com
RSS: http://feeds.feedburner.com/statisticsio
"pete0085" <pete0085@.discussions.microsoft.com> wrote in message
news:63C59DBE-8BBF-4967-BFB4-EDEF3DA0B84C@.microsoft.com...
>I would like to be able to automatically stop a sql service running on sql
> 2005 express, use a script to transfer files over to another server and
> restart the service automatically.
> Any ideas of how I can do this?
|||When it does a copy and it's only copying one file, not the entire directory.
The directory has 4 folders and 1 readme file and it's copying the readme
file.
Any ideas?
"Jason Massie" wrote:

> You can use a batch file that does a net stop, copy and net start. Schedule
> it with task scheduler.
>
> --
> Jason Massie
> Web: http://statisticsio.com
> RSS: http://feeds.feedburner.com/statisticsio
> "pete0085" <pete0085@.discussions.microsoft.com> wrote in message
> news:63C59DBE-8BBF-4967-BFB4-EDEF3DA0B84C@.microsoft.com...
>
>
|||xcopy /S
Documentation for the other switches is available by running xcopy /?
Jason Massie
Web: http://statisticsio.com
RSS: http://feeds.feedburner.com/statisticsio
"pete0085" <pete0085@.discussions.microsoft.com> wrote in message
news:752C5BDF-A76C-48E3-8D9F-013739AE87AE@.microsoft.com...[vbcol=seagreen]
> When it does a copy and it's only copying one file, not the entire
> directory.
> The directory has 4 folders and 1 readme file and it's copying the readme
> file.
> Any ideas?
> "Jason Massie" wrote:
sql

automatically stop/restart sql service

I would like to be able to automatically stop a sql service running on sql
2005 express, use a script to transfer files over to another server and
restart the service automatically.
Any ideas of how I can do this?You can use a batch file that does a net stop, copy and net start. Schedule
it with task scheduler.
Jason Massie
Web: http://statisticsio.com
RSS: http://feeds.feedburner.com/statisticsio
"pete0085" <pete0085@.discussions.microsoft.com> wrote in message
news:63C59DBE-8BBF-4967-BFB4-EDEF3DA0B84C@.microsoft.com...
>I would like to be able to automatically stop a sql service running on sql
> 2005 express, use a script to transfer files over to another server and
> restart the service automatically.
> Any ideas of how I can do this?|||When it does a copy and it's only copying one file, not the entire directory.
The directory has 4 folders and 1 readme file and it's copying the readme
file.
Any ideas?
"Jason Massie" wrote:
> You can use a batch file that does a net stop, copy and net start. Schedule
> it with task scheduler.
>
> --
> Jason Massie
> Web: http://statisticsio.com
> RSS: http://feeds.feedburner.com/statisticsio
> "pete0085" <pete0085@.discussions.microsoft.com> wrote in message
> news:63C59DBE-8BBF-4967-BFB4-EDEF3DA0B84C@.microsoft.com...
> >I would like to be able to automatically stop a sql service running on sql
> > 2005 express, use a script to transfer files over to another server and
> > restart the service automatically.
> >
> > Any ideas of how I can do this?
>
>|||xcopy /S
Documentation for the other switches is available by running xcopy /?
--
Jason Massie
Web: http://statisticsio.com
RSS: http://feeds.feedburner.com/statisticsio
"pete0085" <pete0085@.discussions.microsoft.com> wrote in message
news:752C5BDF-A76C-48E3-8D9F-013739AE87AE@.microsoft.com...
> When it does a copy and it's only copying one file, not the entire
> directory.
> The directory has 4 folders and 1 readme file and it's copying the readme
> file.
> Any ideas?
> "Jason Massie" wrote:
>> You can use a batch file that does a net stop, copy and net start.
>> Schedule
>> it with task scheduler.
>>
>> --
>> Jason Massie
>> Web: http://statisticsio.com
>> RSS: http://feeds.feedburner.com/statisticsio
>> "pete0085" <pete0085@.discussions.microsoft.com> wrote in message
>> news:63C59DBE-8BBF-4967-BFB4-EDEF3DA0B84C@.microsoft.com...
>> >I would like to be able to automatically stop a sql service running on
>> >sql
>> > 2005 express, use a script to transfer files over to another server and
>> > restart the service automatically.
>> >
>> > Any ideas of how I can do this?
>>

Automatically script out a table & indexes - script needed (2005)

I'm trying to automate an auto-export of a table on a daily basis,
using BCP. I'm using native format for the BCP because the text in
one of the fields can encompass pretty much any ASCII characters, and
using the other options (including the null terminator, stuff like
|||, etc) hasn't worked particularly well.
So, I'm archiving out a table on a daily basis. I want to script out
the table at the same time; that way, if there are any table changes,
an import will still work.
How can I do this? I've been digging through google for scripts with
no luck. Ideally I'd like a table-creation script, along with CREATE
INDEX statements.
Anybody have a script handy for this? I know it can be done by using
the system tables, but I'm hoping to avoid reinventing the wheel.
Thanks in advance.
Michael
M Bourgon (bourgon@.gmail.com) writes:
> I'm trying to automate an auto-export of a table on a daily basis,
> using BCP. I'm using native format for the BCP because the text in
> one of the fields can encompass pretty much any ASCII characters, and
> using the other options (including the null terminator, stuff like
>|||, etc) hasn't worked particularly well.
> So, I'm archiving out a table on a daily basis. I want to script out
> the table at the same time; that way, if there are any table changes,
> an import will still work.
> How can I do this? I've been digging through google for scripts with
> no luck. Ideally I'd like a table-creation script, along with CREATE
> INDEX statements.
> Anybody have a script handy for this? I know it can be done by using
> the system tables, but I'm hoping to avoid reinventing the wheel.
> Thanks in advance.
If you are on SQL 2005, you would use SMO for the scripting and on SQL 2000
it would be DMO. No, I don't have any examples, I have stayed away from
both.
Personally, I would prefer the definition of the table to be under version
control and be content with that.
But why use BCP as a backup tool? Why not simply BACKUP? Or are you
trying to tell us that this is the only table in a big database that
you want to back up?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
|||Kalen has written this script
SELECT type_desc,object_name(ic.object_id) as object_name , index_name =
i.name,
'column' = c.name,
'column usage' = CASE ic.is_included_column
WHEN 0 then 'KEY'
ELSE 'INCLUDED'
END
FROM sys.index_columns ic JOIN sys.columns c
ON ic.object_id = c.object_id
AND ic.column_id = c.column_id
JOIN sys.indexes i
ON i.object_id = ic.object_id
AND i.index_id = ic.index_id
"M Bourgon" <bourgon@.gmail.com> wrote in message
news:1184085398.736952.162110@.o61g2000hsh.googlegr oups.com...
> I'm trying to automate an auto-export of a table on a daily basis,
> using BCP. I'm using native format for the BCP because the text in
> one of the fields can encompass pretty much any ASCII characters, and
> using the other options (including the null terminator, stuff like
> |||, etc) hasn't worked particularly well.
> So, I'm archiving out a table on a daily basis. I want to script out
> the table at the same time; that way, if there are any table changes,
> an import will still work.
> How can I do this? I've been digging through google for scripts with
> no luck. Ideally I'd like a table-creation script, along with CREATE
> INDEX statements.
> Anybody have a script handy for this? I know it can be done by using
> the system tables, but I'm hoping to avoid reinventing the wheel.
> Thanks in advance.
> Michael
>
|||On Jul 10, 4:48 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> Personally, I would prefer the definition of the table to be under version
> control and be content with that.
We're working on implementing several changes, that's one of them.

> But why use BCP as a backup tool? Why not simply BACKUP? Or are you
> trying to tell us that this is the only table in a big database that
> you want to back up?
Nope. We're working on moving to Partitioned Tables, but right
now we have home-grown partitioning, and we need to deal with old
"partitions".
|||M Bourgon (bourgon@.gmail.com) writes:
> On Jul 10, 4:48 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> Nope. We're working on moving to Partitioned Tables, but right
> now we have home-grown partitioning, and we need to deal with old
> "partitions".
And the scripting is part of that? Maybe you could give more details?
If the main purpose is that the import of the BCP in native format will
work, maybe it sufficient to save the format file with the table? You
can create a format file from BCP with the format option. (You use "format"
in place of "in" or "out".)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
|||On Jul 11, 4:03 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> M Bourgon (bour...@.gmail.com) writes:
>
> And the scripting is part of that? Maybe you could give more details?
Sure. We have a large table that constantly has new records added. We
want to be able to go back historically and pull from this data set.
The way we currently do it is to keep several days (the "hot" data)
available in one table (whilst auto-archiving 1 days' data out to a
table on a daily basis) several weeks available by a partitioned view,
and archive the older tables. This way, when we get requests for
older data, we can easily look in a set of tables for the results. We
split it up by day due to volume, and also because most of our
requests are "this subset of data, from date A to date B, further
filtered". We've discussed different ways of keeping the data
available, as what takes up the least amount of space is not
necessarily the easiest to query. I like the idea of keeping the data
in a database because then we can easily query it, and we don't have
to worry about any issues (i.e. if we save it out, and the table
format changes, we're don't run into issues months from now when we
try to load the data).
One question you'll probably ask - how do you create the one-days-
worth-of-data table? Unfortunately, that's just a dumb script also,
destined to break if we wind up changing the format of the table.

> If the main purpose is that the import of the BCP in native format will
> work, maybe it sufficient to save the format file with the table? You
> can create a format file from BCP with the format option. (You use "format"
> in place of "in" or "out".)
Can the format file be used instead of DDL? I'll have to try it.
Thanks.
|||M Bourgon (bourgon@.gmail.com) writes:
> Sure. We have a large table that constantly has new records added. We
> want to be able to go back historically and pull from this data set.
> The way we currently do it is to keep several days (the "hot" data)
> available in one table (whilst auto-archiving 1 days' data out to a
> table on a daily basis) several weeks available by a partitioned view,
> and archive the older tables. This way, when we get requests for
> older data, we can easily look in a set of tables for the results. We
> split it up by day due to volume, and also because most of our
> requests are "this subset of data, from date A to date B, further
> filtered".
Maybe a very nave and silly question, but what about a clustered index
on the big table? If you have a date range and clustered index to match
that range, it's fairly irrelevant if the table has 500 million rows.
The major reasons to partition a table I know of are:
1) Being able to quickly drop old data or add new data, by shifting
a table out or in.
2) Spread the load over different file groups.
But it sounds that you in your case keep the data, so that reason to
partition is out.

> We've discussed different ways of keeping the data available, as what
> takes up the least amount of space is not necessarily the easiest to
> query. I like the idea of keeping the data in a database because then
> we can easily query it, and we don't have to worry about any issues
> (i.e. if we save it out, and the table format changes, we're don't run
> into issues months from now when we try to load the data).
But if you keep the data in the database, why then BCP?

> One question you'll probably ask - how do you create the one-days-
> worth-of-data table? Unfortunately, that's just a dumb script also,
> destined to break if we wind up changing the format of the table.
I don't see that much of a problem. I would not expect frequent schema
changes to a table of this size. Having to update one script extra
when you actually do is not that big deal. Although for a plain copy,
you could use SELECT INTO. That would not give the constraints,
triggers and indexes though.
What I am a little more curious is what happens to all those daily
tables that all of a sudden has an obsolete definition.

> Can the format file be used instead of DDL? I'll have to try it.
No, format file has nothing to do with DLL. But my thinking was that
if you saved the BCP file, and then want to import three months later,
the format files relates the format of the file. Assuming that you only
add new columns at the end not drop any, it would import out of the box.
Else you would have to edit column-mapping in the format file.
If you want to script the table, the you are probably best off with DMO
on SQL 2000 and SMO on SQL 2005. I have not worked with either, so I can't
help.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
|||On Jul 17, 4:37 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
(sorry for delay on response)

> Maybe a very nave and silly question, but what about a clustered index
> on the big table? If you have a date range and clustered index to match
> that range, it's fairly irrelevant if the table has 500 million rows.
Right. The problem isn't accessing the data in a reasonable amount of
time, it's space issues. We need to have X days available, but we
also need to be able to move it offline (and back online if we need to
query it) in order to free up space. Disk space is cheap, but it's
not that cheap.

> The major reasons to partition a table I know of are:
> 1) Being able to quickly drop old data or add new data, by shifting
> a table out or in.
> 2) Spread the load over different file groups.
3) Make sure of disk space.

> But if you keep the data in the database, why then BCP?
As the data ages, it needs to be pulled out.

> I don't see that much of a problem. I would not expect frequent schema
> changes to a table of this size. Having to update one script extra
> when you actually do is not that big deal. Although for a plain copy,
> you could use SELECT INTO. That would not give the constraints,
> triggers and indexes though.
Okay. I was hoping there was a way to do it.

> What I am a little more curious is what happens to all those daily
> tables that all of a sudden has an obsolete definition.
The change in definition will be relatively minor. Instead of an INT
field (for ID, for instance), we need to move to BIGINT.

> If you want to script the table, the you are probably best off with DMO
> on SQL 2000 and SMO on SQL 2005. I have not worked with either, so I can't
> help.
Fair enough. I appreciate all the help, Erland. Thank you.
sql

Sunday, March 25, 2012

Automatically script out a table & indexes - script needed (2005)

I'm trying to automate an auto-export of a table on a daily basis,
using BCP. I'm using native format for the BCP because the text in
one of the fields can encompass pretty much any ASCII characters, and
using the other options (including the null terminator, stuff like
|||, etc) hasn't worked particularly well.

So, I'm archiving out a table on a daily basis. I want to script out
the table at the same time; that way, if there are any table changes,
an import will still work.

How can I do this? I've been digging through google for scripts with
no luck. Ideally I'd like a table-creation script, along with CREATE
INDEX statements.

Anybody have a script handy for this? I know it can be done by using
the system tables, but I'm hoping to avoid reinventing the wheel.
Thanks in advance.

MichaelM Bourgon (bourgon@.gmail.com) writes:

Quote:

Originally Posted by

I'm trying to automate an auto-export of a table on a daily basis,
using BCP. I'm using native format for the BCP because the text in
one of the fields can encompass pretty much any ASCII characters, and
using the other options (including the null terminator, stuff like
>|||, etc) hasn't worked particularly well.
>
So, I'm archiving out a table on a daily basis. I want to script out
the table at the same time; that way, if there are any table changes,
an import will still work.
>
How can I do this? I've been digging through google for scripts with
no luck. Ideally I'd like a table-creation script, along with CREATE
INDEX statements.
>
Anybody have a script handy for this? I know it can be done by using
the system tables, but I'm hoping to avoid reinventing the wheel.
Thanks in advance.


If you are on SQL 2005, you would use SMO for the scripting and on SQL 2000
it would be DMO. No, I don't have any examples, I have stayed away from
both.

Personally, I would prefer the definition of the table to be under version
control and be content with that.

But why use BCP as a backup tool? Why not simply BACKUP? Or are you
trying to tell us that this is the only table in a big database that
you want to back up?

--
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|||Kalen has written this script
SELECT type_desc,object_name(ic.object_id) as object_name , index_name =
i.name,

'column' = c.name,

'column usage' = CASE ic.is_included_column

WHEN 0 then 'KEY'

ELSE 'INCLUDED'

END

FROM sys.index_columns ic JOIN sys.columns c

ON ic.object_id = c.object_id

AND ic.column_id = c.column_id

JOIN sys.indexes i

ON i.object_id = ic.object_id

AND i.index_id = ic.index_id

"M Bourgon" <bourgon@.gmail.comwrote in message
news:1184085398.736952.162110@.o61g2000hsh.googlegr oups.com...

Quote:

Originally Posted by

I'm trying to automate an auto-export of a table on a daily basis,
using BCP. I'm using native format for the BCP because the text in
one of the fields can encompass pretty much any ASCII characters, and
using the other options (including the null terminator, stuff like
|||, etc) hasn't worked particularly well.
>
So, I'm archiving out a table on a daily basis. I want to script out
the table at the same time; that way, if there are any table changes,
an import will still work.
>
How can I do this? I've been digging through google for scripts with
no luck. Ideally I'd like a table-creation script, along with CREATE
INDEX statements.
>
Anybody have a script handy for this? I know it can be done by using
the system tables, but I'm hoping to avoid reinventing the wheel.
Thanks in advance.
>
Michael
>

Automatically script out a table & indexes - script needed (2005)

I'm trying to automate an auto-export of a table on a daily basis,
using BCP. I'm using native format for the BCP because the text in
one of the fields can encompass pretty much any ASCII characters, and
using the other options (including the null terminator, stuff like
|||, etc) hasn't worked particularly well.
So, I'm archiving out a table on a daily basis. I want to script out
the table at the same time; that way, if there are any table changes,
an import will still work.
How can I do this? I've been digging through google for scripts with
no luck. Ideally I'd like a table-creation script, along with CREATE
INDEX statements.
Anybody have a script handy for this? I know it can be done by using
the system tables, but I'm hoping to avoid reinventing the wheel.
Thanks in advance.
MichaelM Bourgon (bourgon@.gmail.com) writes:
> I'm trying to automate an auto-export of a table on a daily basis,
> using BCP. I'm using native format for the BCP because the text in
> one of the fields can encompass pretty much any ASCII characters, and
> using the other options (including the null terminator, stuff like
>|||, etc) hasn't worked particularly well.
> So, I'm archiving out a table on a daily basis. I want to script out
> the table at the same time; that way, if there are any table changes,
> an import will still work.
> How can I do this? I've been digging through google for scripts with
> no luck. Ideally I'd like a table-creation script, along with CREATE
> INDEX statements.
> Anybody have a script handy for this? I know it can be done by using
> the system tables, but I'm hoping to avoid reinventing the wheel.
> Thanks in advance.
If you are on SQL 2005, you would use SMO for the scripting and on SQL 2000
it would be DMO. No, I don't have any examples, I have stayed away from
both.
Personally, I would prefer the definition of the table to be under version
control and be content with that.
But why use BCP as a backup tool? Why not simply BACKUP? Or are you
trying to tell us that this is the only table in a big database that
you want to back up?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx|||Kalen has written this script
SELECT type_desc,object_name(ic.object_id) as object_name , index_name =i.name,
'column' = c.name,
'column usage' = CASE ic.is_included_column
WHEN 0 then 'KEY'
ELSE 'INCLUDED'
END
FROM sys.index_columns ic JOIN sys.columns c
ON ic.object_id = c.object_id
AND ic.column_id = c.column_id
JOIN sys.indexes i
ON i.object_id = ic.object_id
AND i.index_id = ic.index_id
"M Bourgon" <bourgon@.gmail.com> wrote in message
news:1184085398.736952.162110@.o61g2000hsh.googlegroups.com...
> I'm trying to automate an auto-export of a table on a daily basis,
> using BCP. I'm using native format for the BCP because the text in
> one of the fields can encompass pretty much any ASCII characters, and
> using the other options (including the null terminator, stuff like
> |||, etc) hasn't worked particularly well.
> So, I'm archiving out a table on a daily basis. I want to script out
> the table at the same time; that way, if there are any table changes,
> an import will still work.
> How can I do this? I've been digging through google for scripts with
> no luck. Ideally I'd like a table-creation script, along with CREATE
> INDEX statements.
> Anybody have a script handy for this? I know it can be done by using
> the system tables, but I'm hoping to avoid reinventing the wheel.
> Thanks in advance.
> Michael
>|||On Jul 10, 4:48 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> Personally, I would prefer the definition of the table to be under version
> control and be content with that.
We're working on implementing several changes, that's one of them.
> But why use BCP as a backup tool? Why not simply BACKUP? Or are you
> trying to tell us that this is the only table in a big database that
> you want to back up?
Nope. :) We're working on moving to Partitioned Tables, but right
now we have home-grown partitioning, and we need to deal with old
"partitions".|||M Bourgon (bourgon@.gmail.com) writes:
> On Jul 10, 4:48 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
>> But why use BCP as a backup tool? Why not simply BACKUP? Or are you
>> trying to tell us that this is the only table in a big database that
>> you want to back up?
> Nope. :) We're working on moving to Partitioned Tables, but right
> now we have home-grown partitioning, and we need to deal with old
> "partitions".
And the scripting is part of that? Maybe you could give more details?
If the main purpose is that the import of the BCP in native format will
work, maybe it sufficient to save the format file with the table? You
can create a format file from BCP with the format option. (You use "format"
in place of "in" or "out".)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx|||On Jul 11, 4:03 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> M Bourgon (bour...@.gmail.com) writes:
> > On Jul 10, 4:48 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> >> But why use BCP as a backup tool? Why not simply BACKUP? Or are you
> >> trying to tell us that this is the only table in a big database that
> >> you want to back up?
> > Nope. :) We're working on moving to Partitioned Tables, but right
> > now we have home-grown partitioning, and we need to deal with old
> > "partitions".
> And the scripting is part of that? Maybe you could give more details?
Sure. We have a large table that constantly has new records added. We
want to be able to go back historically and pull from this data set.
The way we currently do it is to keep several days (the "hot" data)
available in one table (whilst auto-archiving 1 days' data out to a
table on a daily basis) several weeks available by a partitioned view,
and archive the older tables. This way, when we get requests for
older data, we can easily look in a set of tables for the results. We
split it up by day due to volume, and also because most of our
requests are "this subset of data, from date A to date B, further
filtered". We've discussed different ways of keeping the data
available, as what takes up the least amount of space is not
necessarily the easiest to query. I like the idea of keeping the data
in a database because then we can easily query it, and we don't have
to worry about any issues (i.e. if we save it out, and the table
format changes, we're don't run into issues months from now when we
try to load the data).
One question you'll probably ask - how do you create the one-days-
worth-of-data table? Unfortunately, that's just a dumb script also,
destined to break if we wind up changing the format of the table.
> If the main purpose is that the import of the BCP in native format will
> work, maybe it sufficient to save the format file with the table? You
> can create a format file from BCP with the format option. (You use "format"
> in place of "in" or "out".)
Can the format file be used instead of DDL? I'll have to try it.
Thanks.|||M Bourgon (bourgon@.gmail.com) writes:
> Sure. We have a large table that constantly has new records added. We
> want to be able to go back historically and pull from this data set.
> The way we currently do it is to keep several days (the "hot" data)
> available in one table (whilst auto-archiving 1 days' data out to a
> table on a daily basis) several weeks available by a partitioned view,
> and archive the older tables. This way, when we get requests for
> older data, we can easily look in a set of tables for the results. We
> split it up by day due to volume, and also because most of our
> requests are "this subset of data, from date A to date B, further
> filtered".
Maybe a very naïve and silly question, but what about a clustered index
on the big table? If you have a date range and clustered index to match
that range, it's fairly irrelevant if the table has 500 million rows.
The major reasons to partition a table I know of are:
1) Being able to quickly drop old data or add new data, by shifting
a table out or in.
2) Spread the load over different file groups.
But it sounds that you in your case keep the data, so that reason to
partition is out.
> We've discussed different ways of keeping the data available, as what
> takes up the least amount of space is not necessarily the easiest to
> query. I like the idea of keeping the data in a database because then
> we can easily query it, and we don't have to worry about any issues
> (i.e. if we save it out, and the table format changes, we're don't run
> into issues months from now when we try to load the data).
But if you keep the data in the database, why then BCP?
> One question you'll probably ask - how do you create the one-days-
> worth-of-data table? Unfortunately, that's just a dumb script also,
> destined to break if we wind up changing the format of the table.
I don't see that much of a problem. I would not expect frequent schema
changes to a table of this size. Having to update one script extra
when you actually do is not that big deal. Although for a plain copy,
you could use SELECT INTO. That would not give the constraints,
triggers and indexes though.
What I am a little more curious is what happens to all those daily
tables that all of a sudden has an obsolete definition.
>> If the main purpose is that the import of the BCP in native format will
>> work, maybe it sufficient to save the format file with the table? You
>> can create a format file from BCP with the format option. (You use
>> "format" in place of "in" or "out".)
> Can the format file be used instead of DDL? I'll have to try it.
No, format file has nothing to do with DLL. But my thinking was that
if you saved the BCP file, and then want to import three months later,
the format files relates the format of the file. Assuming that you only
add new columns at the end not drop any, it would import out of the box.
Else you would have to edit column-mapping in the format file.
If you want to script the table, the you are probably best off with DMO
on SQL 2000 and SMO on SQL 2005. I have not worked with either, so I can't
help.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx|||On Jul 17, 4:37 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
(sorry for delay on response)
> Maybe a very na=EFve and silly question, but what about a clustered index
> on the big table? If you have a date range and clustered index to match
> that range, it's fairly irrelevant if the table has 500 million rows.
Right. The problem isn't accessing the data in a reasonable amount of
time, it's space issues. We need to have X days available, but we
also need to be able to move it offline (and back online if we need to
query it) in order to free up space. Disk space is cheap, but it's
not that cheap.
> The major reasons to partition a table I know of are:
> 1) Being able to quickly drop old data or add new data, by shifting
> a table out or in.
> 2) Spread the load over different file groups.
3) Make sure of disk space. :)
> But if you keep the data in the database, why then BCP?
As the data ages, it needs to be pulled out.
> I don't see that much of a problem. I would not expect frequent schema
> changes to a table of this size. Having to update one script extra
> when you actually do is not that big deal. Although for a plain copy,
> you could use SELECT INTO. That would not give the constraints,
> triggers and indexes though.
Okay. I was hoping there was a way to do it.
> What I am a little more curious is what happens to all those daily
> tables that all of a sudden has an obsolete definition.
The change in definition will be relatively minor. Instead of an INT
field (for ID, for instance), we need to move to BIGINT.
> If you want to script the table, the you are probably best off with DMO
> on SQL 2000 and SMO on SQL 2005. I have not worked with either, so I can't
> help.
Fair enough. I appreciate all the help, Erland. Thank you.

Automatically script out a table & indexes - script needed (2005)

I'm trying to automate an auto-export of a table on a daily basis,
using BCP. I'm using native format for the BCP because the text in
one of the fields can encompass pretty much any ASCII characters, and
using the other options (including the null terminator, stuff like
|||, etc) hasn't worked particularly well.
So, I'm archiving out a table on a daily basis. I want to script out
the table at the same time; that way, if there are any table changes,
an import will still work.
How can I do this? I've been digging through google for scripts with
no luck. Ideally I'd like a table-creation script, along with CREATE
INDEX statements.
Anybody have a script handy for this? I know it can be done by using
the system tables, but I'm hoping to avoid reinventing the wheel.
Thanks in advance.
MichaelM Bourgon (bourgon@.gmail.com) writes:
> I'm trying to automate an auto-export of a table on a daily basis,
> using BCP. I'm using native format for the BCP because the text in
> one of the fields can encompass pretty much any ASCII characters, and
> using the other options (including the null terminator, stuff like
>|||, etc) hasn't worked particularly well.
> So, I'm archiving out a table on a daily basis. I want to script out
> the table at the same time; that way, if there are any table changes,
> an import will still work.
> How can I do this? I've been digging through google for scripts with
> no luck. Ideally I'd like a table-creation script, along with CREATE
> INDEX statements.
> Anybody have a script handy for this? I know it can be done by using
> the system tables, but I'm hoping to avoid reinventing the wheel.
> Thanks in advance.
If you are on SQL 2005, you would use SMO for the scripting and on SQL 2000
it would be DMO. No, I don't have any examples, I have stayed away from
both.
Personally, I would prefer the definition of the table to be under version
control and be content with that.
But why use BCP as a backup tool? Why not simply BACKUP? Or are you
trying to tell us that this is the only table in a big database that
you want to back up?
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|||Kalen has written this script
SELECT type_desc,object_name(ic.object_id) as object_name , index_name =
i.name,
'column' = c.name,
'column usage' = CASE ic.is_included_column
WHEN 0 then 'KEY'
ELSE 'INCLUDED'
END
FROM sys.index_columns ic JOIN sys.columns c
ON ic.object_id = c.object_id
AND ic.column_id = c.column_id
JOIN sys.indexes i
ON i.object_id = ic.object_id
AND i.index_id = ic.index_id
"M Bourgon" <bourgon@.gmail.com> wrote in message
news:1184085398.736952.162110@.o61g2000hsh.googlegroups.com...
> I'm trying to automate an auto-export of a table on a daily basis,
> using BCP. I'm using native format for the BCP because the text in
> one of the fields can encompass pretty much any ASCII characters, and
> using the other options (including the null terminator, stuff like
> |||, etc) hasn't worked particularly well.
> So, I'm archiving out a table on a daily basis. I want to script out
> the table at the same time; that way, if there are any table changes,
> an import will still work.
> How can I do this? I've been digging through google for scripts with
> no luck. Ideally I'd like a table-creation script, along with CREATE
> INDEX statements.
> Anybody have a script handy for this? I know it can be done by using
> the system tables, but I'm hoping to avoid reinventing the wheel.
> Thanks in advance.
> Michael
>|||On Jul 10, 4:48 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> Personally, I would prefer the definition of the table to be under version
> control and be content with that.
We're working on implementing several changes, that's one of them.

> But why use BCP as a backup tool? Why not simply BACKUP? Or are you
> trying to tell us that this is the only table in a big database that
> you want to back up?
Nope. We're working on moving to Partitioned Tables, but right
now we have home-grown partitioning, and we need to deal with old
"partitions".|||M Bourgon (bourgon@.gmail.com) writes:
> On Jul 10, 4:48 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> Nope. We're working on moving to Partitioned Tables, but right
> now we have home-grown partitioning, and we need to deal with old
> "partitions".
And the scripting is part of that? Maybe you could give more details?
If the main purpose is that the import of the BCP in native format will
work, maybe it sufficient to save the format file with the table? You
can create a format file from BCP with the format option. (You use "format"
in place of "in" or "out".)
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|||On Jul 11, 4:03 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
> M Bourgon (bour...@.gmail.com) writes:
>
> And the scripting is part of that? Maybe you could give more details?
Sure. We have a large table that constantly has new records added. We
want to be able to go back historically and pull from this data set.
The way we currently do it is to keep several days (the "hot" data)
available in one table (whilst auto-archiving 1 days' data out to a
table on a daily basis) several weeks available by a partitioned view,
and archive the older tables. This way, when we get requests for
older data, we can easily look in a set of tables for the results. We
split it up by day due to volume, and also because most of our
requests are "this subset of data, from date A to date B, further
filtered". We've discussed different ways of keeping the data
available, as what takes up the least amount of space is not
necessarily the easiest to query. I like the idea of keeping the data
in a database because then we can easily query it, and we don't have
to worry about any issues (i.e. if we save it out, and the table
format changes, we're don't run into issues months from now when we
try to load the data).
One question you'll probably ask - how do you create the one-days-
worth-of-data table? Unfortunately, that's just a dumb script also,
destined to break if we wind up changing the format of the table.

> If the main purpose is that the import of the BCP in native format will
> work, maybe it sufficient to save the format file with the table? You
> can create a format file from BCP with the format option. (You use "format
"
> in place of "in" or "out".)
Can the format file be used instead of DDL? I'll have to try it.
Thanks.|||M Bourgon (bourgon@.gmail.com) writes:
> Sure. We have a large table that constantly has new records added. We
> want to be able to go back historically and pull from this data set.
> The way we currently do it is to keep several days (the "hot" data)
> available in one table (whilst auto-archiving 1 days' data out to a
> table on a daily basis) several weeks available by a partitioned view,
> and archive the older tables. This way, when we get requests for
> older data, we can easily look in a set of tables for the results. We
> split it up by day due to volume, and also because most of our
> requests are "this subset of data, from date A to date B, further
> filtered".
Maybe a very nave and silly question, but what about a clustered index
on the big table? If you have a date range and clustered index to match
that range, it's fairly irrelevant if the table has 500 million rows.
The major reasons to partition a table I know of are:
1) Being able to quickly drop old data or add new data, by shifting
a table out or in.
2) Spread the load over different file groups.
But it sounds that you in your case keep the data, so that reason to
partition is out.

> We've discussed different ways of keeping the data available, as what
> takes up the least amount of space is not necessarily the easiest to
> query. I like the idea of keeping the data in a database because then
> we can easily query it, and we don't have to worry about any issues
> (i.e. if we save it out, and the table format changes, we're don't run
> into issues months from now when we try to load the data).
But if you keep the data in the database, why then BCP?

> One question you'll probably ask - how do you create the one-days-
> worth-of-data table? Unfortunately, that's just a dumb script also,
> destined to break if we wind up changing the format of the table.
I don't see that much of a problem. I would not expect frequent schema
changes to a table of this size. Having to update one script extra
when you actually do is not that big deal. Although for a plain copy,
you could use SELECT INTO. That would not give the constraints,
triggers and indexes though.
What I am a little more curious is what happens to all those daily
tables that all of a sudden has an obsolete definition.

> Can the format file be used instead of DDL? I'll have to try it.
No, format file has nothing to do with DLL. But my thinking was that
if you saved the BCP file, and then want to import three months later,
the format files relates the format of the file. Assuming that you only
add new columns at the end not drop any, it would import out of the box.
Else you would have to edit column-mapping in the format file.
If you want to script the table, the you are probably best off with DMO
on SQL 2000 and SMO on SQL 2005. I have not worked with either, so I can't
help.
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|||On Jul 17, 4:37 pm, Erland Sommarskog <esq...@.sommarskog.se> wrote:
(sorry for delay on response)

> Maybe a very na=EFve and silly question, but what about a clustered index
> on the big table? If you have a date range and clustered index to match
> that range, it's fairly irrelevant if the table has 500 million rows.
Right. The problem isn't accessing the data in a reasonable amount of
time, it's space issues. We need to have X days available, but we
also need to be able to move it offline (and back online if we need to
query it) in order to free up space. Disk space is cheap, but it's
not that cheap.

> The major reasons to partition a table I know of are:
> 1) Being able to quickly drop old data or add new data, by shifting
> a table out or in.
> 2) Spread the load over different file groups.
3) Make sure of disk space.

> But if you keep the data in the database, why then BCP?
As the data ages, it needs to be pulled out.

> I don't see that much of a problem. I would not expect frequent schema
> changes to a table of this size. Having to update one script extra
> when you actually do is not that big deal. Although for a plain copy,
> you could use SELECT INTO. That would not give the constraints,
> triggers and indexes though.
Okay. I was hoping there was a way to do it.

> What I am a little more curious is what happens to all those daily
> tables that all of a sudden has an obsolete definition.
The change in definition will be relatively minor. Instead of an INT
field (for ID, for instance), we need to move to BIGINT.

> If you want to script the table, the you are probably best off with DMO
> on SQL 2000 and SMO on SQL 2005. I have not worked with either, so I can't
> help.
Fair enough. I appreciate all the help, Erland. Thank you.

Tuesday, March 20, 2012

automatic script with SQL Server 2000

Hello,
Newbie question:
How can you set a SQL Server 2000 script which will launch automaticly every
day ?
Thanks for your help!One way would be to create a SQL Server JOB, and designate the time to
execute. (That 'JOB' could be running a Stored Procedure -for example.)
--
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Newbie" <newbie@.beginers.com> wrote in message
news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
> Hello,
> Newbie question:
> How can you set a SQL Server 2000 script which will launch automaticly
> every
> day ?
> Thanks for your help!
>
>|||Thanks Arnie,
The script is alredy written. How can I create the job which'll launch it ?
(NB : I'm a very beginner;-)
Thanks again
"Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
> One way would be to create a SQL Server JOB, and designate the time to
> execute. (That 'JOB' could be running a Stored Procedure -for example.)
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
> > Hello,
> > Newbie question:
> > How can you set a SQL Server 2000 script which will launch automaticly
> > every
> > day ?
> > Thanks for your help!
> >
> >
> >
>|||In Enterprise Mangler, expand down through your server until you get to SQL
Server Agent, and then Jobs.
Right click on the right pane, and select 'New Job'. Most of the rest will
be reasonably explanitory. You can look up SQL Agent Jobs in Books on Line.
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Newbie" <newbie@.beginers.com> wrote in message
news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
> Thanks Arnie,
> The script is alredy written. How can I create the job which'll launch it
> ?
> (NB : I'm a very beginner;-)
> Thanks again
> "Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
> news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
>> One way would be to create a SQL Server JOB, and designate the time to
>> execute. (That 'JOB' could be running a Stored Procedure -for example.)
>> --
>> Arnie Rowland*
>> "To be successful, your heart must accompany your knowledge."
>>
>> "Newbie" <newbie@.beginers.com> wrote in message
>> news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
>> > Hello,
>> > Newbie question:
>> > How can you set a SQL Server 2000 script which will launch automaticly
>> > every
>> > day ?
>> > Thanks for your help!
>> >
>> >
>> >
>>
>|||Thanks a lot Arnie !
That's great !
Newbie
"Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
news:%23NBhNaHpGHA.3564@.TK2MSFTNGP03.phx.gbl...
> In Enterprise Mangler, expand down through your server until you get to
SQL
> Server Agent, and then Jobs.
> Right click on the right pane, and select 'New Job'. Most of the rest will
> be reasonably explanitory. You can look up SQL Agent Jobs in Books on
Line.
>
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
> > Thanks Arnie,
> > The script is alredy written. How can I create the job which'll launch
it
> > ?
> > (NB : I'm a very beginner;-)
> > Thanks again
> >
> > "Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
> > news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
> >> One way would be to create a SQL Server JOB, and designate the time to
> >> execute. (That 'JOB' could be running a Stored Procedure -for example.)
> >>
> >> --
> >> Arnie Rowland*
> >> "To be successful, your heart must accompany your knowledge."
> >>
> >>
> >>
> >> "Newbie" <newbie@.beginers.com> wrote in message
> >> news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
> >> > Hello,
> >> > Newbie question:
> >> > How can you set a SQL Server 2000 script which will launch
automaticly
> >> > every
> >> > day ?
> >> > Thanks for your help!
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
>|||Arnie,
In the Command section of the New job Step, how I said to launch the
ScriptXX ?
"Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
news:%23NBhNaHpGHA.3564@.TK2MSFTNGP03.phx.gbl...
> In Enterprise Mangler, expand down through your server until you get to
SQL
> Server Agent, and then Jobs.
> Right click on the right pane, and select 'New Job'. Most of the rest will
> be reasonably explanitory. You can look up SQL Agent Jobs in Books on
Line.
>
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
> > Thanks Arnie,
> > The script is alredy written. How can I create the job which'll launch
it
> > ?
> > (NB : I'm a very beginner;-)
> > Thanks again
> >
> > "Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
> > news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
> >> One way would be to create a SQL Server JOB, and designate the time to
> >> execute. (That 'JOB' could be running a Stored Procedure -for example.)
> >>
> >> --
> >> Arnie Rowland*
> >> "To be successful, your heart must accompany your knowledge."
> >>
> >>
> >>
> >> "Newbie" <newbie@.beginers.com> wrote in message
> >> news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
> >> > Hello,
> >> > Newbie question:
> >> > How can you set a SQL Server 2000 script which will launch
automaticly
> >> > every
> >> > day ?
> >> > Thanks for your help!
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
>|||You can just copy and paste the script into the window.
--
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Newbie" <newbie@.beginers.com> wrote in message
news:ONmdioHpGHA.1140@.TK2MSFTNGP05.phx.gbl...
> Arnie,
> In the Command section of the New job Step, how I said to launch the
> ScriptXX ?
> "Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
> news:%23NBhNaHpGHA.3564@.TK2MSFTNGP03.phx.gbl...
>> In Enterprise Mangler, expand down through your server until you get to
> SQL
>> Server Agent, and then Jobs.
>> Right click on the right pane, and select 'New Job'. Most of the rest
>> will
>> be reasonably explanitory. You can look up SQL Agent Jobs in Books on
> Line.
>>
>> --
>> Arnie Rowland*
>> "To be successful, your heart must accompany your knowledge."
>>
>> "Newbie" <newbie@.beginers.com> wrote in message
>> news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
>> > Thanks Arnie,
>> > The script is alredy written. How can I create the job which'll launch
> it
>> > ?
>> > (NB : I'm a very beginner;-)
>> > Thanks again
>> >
>> > "Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
>> > news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
>> >> One way would be to create a SQL Server JOB, and designate the time to
>> >> execute. (That 'JOB' could be running a Stored Procedure -for
>> >> example.)
>> >>
>> >> --
>> >> Arnie Rowland*
>> >> "To be successful, your heart must accompany your knowledge."
>> >>
>> >>
>> >>
>> >> "Newbie" <newbie@.beginers.com> wrote in message
>> >> news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
>> >> > Hello,
>> >> > Newbie question:
>> >> > How can you set a SQL Server 2000 script which will launch
> automaticly
>> >> > every
>> >> > day ?
>> >> > Thanks for your help!
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>|||Arnie,
Thanks a lot !
"Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
news:Oz9bVGJpGHA.756@.TK2MSFTNGP05.phx.gbl...
> You can just copy and paste the script into the window.
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:ONmdioHpGHA.1140@.TK2MSFTNGP05.phx.gbl...
> > Arnie,
> > In the Command section of the New job Step, how I said to launch the
> > ScriptXX ?
> >
> > "Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
> > news:%23NBhNaHpGHA.3564@.TK2MSFTNGP03.phx.gbl...
> >> In Enterprise Mangler, expand down through your server until you get to
> > SQL
> >> Server Agent, and then Jobs.
> >>
> >> Right click on the right pane, and select 'New Job'. Most of the rest
> >> will
> >> be reasonably explanitory. You can look up SQL Agent Jobs in Books on
> > Line.
> >>
> >>
> >> --
> >> Arnie Rowland*
> >> "To be successful, your heart must accompany your knowledge."
> >>
> >>
> >>
> >> "Newbie" <newbie@.beginers.com> wrote in message
> >> news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
> >> > Thanks Arnie,
> >> > The script is alredy written. How can I create the job which'll
launch
> > it
> >> > ?
> >> > (NB : I'm a very beginner;-)
> >> > Thanks again
> >> >
> >> > "Arnie Rowland" <arnie@.1568.com> a écrit dans le message de
> >> > news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
> >> >> One way would be to create a SQL Server JOB, and designate the time
to
> >> >> execute. (That 'JOB' could be running a Stored Procedure -for
> >> >> example.)
> >> >>
> >> >> --
> >> >> Arnie Rowland*
> >> >> "To be successful, your heart must accompany your knowledge."
> >> >>
> >> >>
> >> >>
> >> >> "Newbie" <newbie@.beginers.com> wrote in message
> >> >> news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
> >> >> > Hello,
> >> >> > Newbie question:
> >> >> > How can you set a SQL Server 2000 script which will launch
> > automaticly
> >> >> > every
> >> >> > day ?
> >> >> > Thanks for your help!
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>

automatic script with SQL Server 2000

Hello,
Newbie question:
How can you set a SQL Server 2000 script which will launch automaticly every
day ?
Thanks for your help!One way would be to create a SQL Server JOB, and designate the time to
execute. (That 'JOB' could be running a Stored Procedure -for example.)
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Newbie" <newbie@.beginers.com> wrote in message
news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
> Hello,
> Newbie question:
> How can you set a SQL Server 2000 script which will launch automaticly
> every
> day ?
> Thanks for your help!
>
>|||Thanks Arnie,
The script is alredy written. How can I create the job which'll launch it ?
(NB : I'm a very beginner;-)
Thanks again
"Arnie Rowland" <arnie@.1568.com> a crit dans le message de
news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
> One way would be to create a SQL Server JOB, and designate the time to
> execute. (That 'JOB' could be running a Stored Procedure -for example.)
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:Of6IaxGpGHA.3600@.TK2MSFTNGP04.phx.gbl...
>|||In Enterprise Mangler, expand down through your server until you get to SQL
Server Agent, and then Jobs.
Right click on the right pane, and select 'New Job'. Most of the rest will
be reasonably explanitory. You can look up SQL Agent Jobs in Books on Line.
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Newbie" <newbie@.beginers.com> wrote in message
news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
> Thanks Arnie,
> The script is alredy written. How can I create the job which'll launch it
> ?
> (NB : I'm a very beginner;-)
> Thanks again
> "Arnie Rowland" <arnie@.1568.com> a crit dans le message de
> news:udsgS%23GpGHA.3324@.TK2MSFTNGP05.phx.gbl...
>|||Thanks a lot Arnie !
That's great !
Newbie
"Arnie Rowland" <arnie@.1568.com> a crit dans le message de
news:%23NBhNaHpGHA.3564@.TK2MSFTNGP03.phx.gbl...
> In Enterprise Mangler, expand down through your server until you get to
SQL
> Server Agent, and then Jobs.
> Right click on the right pane, and select 'New Job'. Most of the rest will
> be reasonably explanitory. You can look up SQL Agent Jobs in Books on
Line.
>
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
it[vbcol=seagreen]
automaticly[vbcol=seagreen]
>|||Arnie,
In the Command section of the New job Step, how I said to launch the
ScriptXX ?
"Arnie Rowland" <arnie@.1568.com> a crit dans le message de
news:%23NBhNaHpGHA.3564@.TK2MSFTNGP03.phx.gbl...
> In Enterprise Mangler, expand down through your server until you get to
SQL
> Server Agent, and then Jobs.
> Right click on the right pane, and select 'New Job'. Most of the rest will
> be reasonably explanitory. You can look up SQL Agent Jobs in Books on
Line.
>
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:Oyd1ZGHpGHA.4188@.TK2MSFTNGP03.phx.gbl...
it[vbcol=seagreen]
automaticly[vbcol=seagreen]
>|||You can just copy and paste the script into the window.
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Newbie" <newbie@.beginers.com> wrote in message
news:ONmdioHpGHA.1140@.TK2MSFTNGP05.phx.gbl...
> Arnie,
> In the Command section of the New job Step, how I said to launch the
> ScriptXX ?
> "Arnie Rowland" <arnie@.1568.com> a crit dans le message de
> news:%23NBhNaHpGHA.3564@.TK2MSFTNGP03.phx.gbl...
> SQL
> Line.
> it
> automaticly
>|||Arnie,
Thanks a lot !
"Arnie Rowland" <arnie@.1568.com> a crit dans le message de
news:Oz9bVGJpGHA.756@.TK2MSFTNGP05.phx.gbl...
> You can just copy and paste the script into the window.
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
> "Newbie" <newbie@.beginers.com> wrote in message
> news:ONmdioHpGHA.1140@.TK2MSFTNGP05.phx.gbl...
launch[vbcol=seagreen]
to[vbcol=seagreen]
>

Automatic script out database objects to file

Hi champs,

It is possible to script the databases , tables and all other objects, out to a SQL file.

Is there a way to control this with a script?

For instance, want to run a script that schripts only all the tables out to a result -SQL script.

Or a script that scripts out all the constraints and user defined variables to a SQL result script.

Is this possible to do in a SQL script?

/Many thanks

YOu can use the SMO classes for that with iterating through the information of the object collections, but you can′t do that in TSQL easily.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

automatic script generation

Hi,
Is it possible to automate the 'All tasks - generate
sqlscripts' for tables and stored procs thru SQL
enterprise manager. I want the scripts to be automatically
generated monthly instead of doing manually - pls help.
regards,
bharathbharath,
Make and application that leverages the SQL-DMO libraries.
There are classes which can be used to generate scripts.
You may also use sp_OA* procs instead of a little app,
but I have done so, and I will advise you that
it is an exercise in tedium. Better to make a little app.
See "SQL-DMO" in Books Online.
James Hokes
"bharath" <anonymous@.discussions.microsoft.com> wrote in message
news:62ce01c3e625$7ecfec80$a001280a@.phx.gbl...
> Hi,
> Is it possible to automate the 'All tasks - generate
> sqlscripts' for tables and stored procs thru SQL
> enterprise manager. I want the scripts to be automatically
> generated monthly instead of doing manually - pls help.
> regards,
> bharath|||Hi,
JAmes.. thanks a lot.. can u give me an example so that i
understand better (regarding the apps)...
regards,
bharath
>--Original Message--
>bharath,
>Make and application that leverages the SQL-DMO libraries.
>There are classes which can be used to generate scripts.
>You may also use sp_OA* procs instead of a little app,
>but I have done so, and I will advise you that
>it is an exercise in tedium. Better to make a little app.
>See "SQL-DMO" in Books Online.
>James Hokes
>"bharath" <anonymous@.discussions.microsoft.com> wrote in
message
>news:62ce01c3e625$7ecfec80$a001280a@.phx.gbl...
>> Hi,
>> Is it possible to automate the 'All tasks - generate
>> sqlscripts' for tables and stored procs thru SQL
>> enterprise manager. I want the scripts to be
automatically
>> generated monthly instead of doing manually - pls help.
>> regards,
>> bharath
>
>.
>|||For sp_OA* variant, you can find a nice script at
http://support.microsoft.com/default.aspx?scid=kb;en-us;233392.
--
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"bharath" <anonymous@.discussions.microsoft.com> wrote in message
news:658a01c3e629$6bd589b0$a401280a@.phx.gbl...
> Hi,
> JAmes.. thanks a lot.. can u give me an example so that i
> understand better (regarding the apps)...
> regards,
> bharath
> >--Original Message--
> >bharath,
> >
> >Make and application that leverages the SQL-DMO libraries.
> >There are classes which can be used to generate scripts.
> >
> >You may also use sp_OA* procs instead of a little app,
> >but I have done so, and I will advise you that
> >it is an exercise in tedium. Better to make a little app.
> >
> >See "SQL-DMO" in Books Online.
> >
> >James Hokes
> >
> >"bharath" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:62ce01c3e625$7ecfec80$a001280a@.phx.gbl...
> >> Hi,
> >>
> >> Is it possible to automate the 'All tasks - generate
> >> sqlscripts' for tables and stored procs thru SQL
> >> enterprise manager. I want the scripts to be
> automatically
> >> generated monthly instead of doing manually - pls help.
> >>
> >> regards,
> >> bharath
> >
> >
> >.
> >|||There is also a nice program to do this that is included in Ken Hendersons
new book "SQL Server Architecture"
--
Wayne Snyder MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
(Please respond only to the newsgroups.)
I support the Professional Association for SQL Server
(www.sqlpass.org)
"bharath" <anonymous@.discussions.microsoft.com> wrote in message
news:62ce01c3e625$7ecfec80$a001280a@.phx.gbl...
> Hi,
> Is it possible to automate the 'All tasks - generate
> sqlscripts' for tables and stored procs thru SQL
> enterprise manager. I want the scripts to be automatically
> generated monthly instead of doing manually - pls help.
> regards,
> bharath|||bharath,
Well, off the top of my head, there's an SQL Server class, and first you
create an instance of that.
Then there's the databases collection off of the Server class, and you drill
down through the object hierarchy to get at the .Script method of the actual
object you're interested in.
There are separate collections for Tables, Views, StoredProcedures, etc.
Anyhow, there are a bizzillion flags you can set, such as whether or not to
include permissions, indexes, triggers, etc.
As I said, all the documentation you'll ever need is in Books Online, so I
can't really give you 'sample code'. I don't even know what language you're
planning to write it in.
James Hokes
"bharath" <anonymous@.discussions.microsoft.com> wrote in message
news:658a01c3e629$6bd589b0$a401280a@.phx.gbl...
> Hi,
> JAmes.. thanks a lot.. can u give me an example so that i
> understand better (regarding the apps)...
> regards,
> bharath
> >--Original Message--
> >bharath,
> >
> >Make and application that leverages the SQL-DMO libraries.
> >There are classes which can be used to generate scripts.
> >
> >You may also use sp_OA* procs instead of a little app,
> >but I have done so, and I will advise you that
> >it is an exercise in tedium. Better to make a little app.
> >
> >See "SQL-DMO" in Books Online.
> >
> >James Hokes
> >
> >"bharath" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:62ce01c3e625$7ecfec80$a001280a@.phx.gbl...
> >> Hi,
> >>
> >> Is it possible to automate the 'All tasks - generate
> >> sqlscripts' for tables and stored procs thru SQL
> >> enterprise manager. I want the scripts to be
> automatically
> >> generated monthly instead of doing manually - pls help.
> >>
> >> regards,
> >> bharath
> >
> >
> >.
> >|||Dejan,
That articles does not mention the sp_OA* variation on this concept.
Looks more like VBA in Microsoft Access.
James Hokes
"Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@.avtenta.si> wrote in
message news:#5FRhuj5DHA.488@.TK2MSFTNGP12.phx.gbl...
> For sp_OA* variant, you can find a nice script at
> http://support.microsoft.com/default.aspx?scid=kb;en-us;233392.
> --
> Dejan Sarka, SQL Server MVP
> Associate Mentor
> Solid Quality Learning
> More than just Training
> www.SolidQualityLearning.com
> "bharath" <anonymous@.discussions.microsoft.com> wrote in message
> news:658a01c3e629$6bd589b0$a401280a@.phx.gbl...
> > Hi,
> >
> > JAmes.. thanks a lot.. can u give me an example so that i
> > understand better (regarding the apps)...
> >
> > regards,
> > bharath
> >
> > >--Original Message--
> > >bharath,
> > >
> > >Make and application that leverages the SQL-DMO libraries.
> > >There are classes which can be used to generate scripts.
> > >
> > >You may also use sp_OA* procs instead of a little app,
> > >but I have done so, and I will advise you that
> > >it is an exercise in tedium. Better to make a little app.
> > >
> > >See "SQL-DMO" in Books Online.
> > >
> > >James Hokes
> > >
> > >"bharath" <anonymous@.discussions.microsoft.com> wrote in
> > message
> > >news:62ce01c3e625$7ecfec80$a001280a@.phx.gbl...
> > >> Hi,
> > >>
> > >> Is it possible to automate the 'All tasks - generate
> > >> sqlscripts' for tables and stored procs thru SQL
> > >> enterprise manager. I want the scripts to be
> > automatically
> > >> generated monthly instead of doing manually - pls help.
> > >>
> > >> regards,
> > >> bharath
> > >
> > >
> > >.
> > >
>sql