Monday, March 26, 2012
Running Transac SQL in Command Line
I currently have a problem where I need to create a backup from MSSQL, via a command line, ideally from a batch script. This is on a PC. Each machine has SQL Server 2000 on.
I just need to know the code that dos will tell it to run the sql statement. Ideally the command will also give the directory to place the backup.
Regards MiloJFunny that you should ask! There is a KB article just for you, #241937 (http://support.microsoft.com/default.aspx?scid=kb;en-us;241397) that describes in detail just what you want.
-PatP|||Pat, that's perfect you are 100% on the money, much obliged
Running totals: Custom Reset via Formula
I have attached a screenshot to help make up for my inability to describe the situation I'm dealing with here.
I have three groups within a report that currently use distinct Running Totals fields that Reset at the group levels that I assigned. I am attempting to create a single Running Totals field that will reset depending on which Group is being calculated at the moment so that I don't have to have a separate Running Totals object for each and every group. I'm not sure how to do this or write this formula as I'm new to Crystal Reports and am used to SQL Reporting Services where this evaluation is automatically done for you (I was spoiled I guess).
For example, if the Running Totals field control is in Group #1, I want it to reset at Group #1, and Group#2 to reset at Group #2.
So basically I'm attempting to use a formula to create a Reset point (view screenshot for detail) that is determined by which group the data is being calculated in. Is this possible? I realize that it is possible by simply creating a new running total object for each group, but this seems completely redundant and overly time consuming for larger reports where there are multiple groups.
I'm developing the report with Crystal Reports within Visual Studio 2005 if that helps any.
Please let me know if I can attach a screen shot or give more information to make my task clear.
Thanks!Either this will answer your question or I've totaly missed the point! (again..ahem)!
Enter a Running Total against the required field. In the Evaluate section select On Change of Group and select your relevant group header.
Very simple or completely wrong! I'll let you make your mind up!
Take it easy
Rob|||Either this will answer your question or I've totaly missed the point! (again..ahem)!
Enter a Running Total against the required field. In the Evaluate section select On Change of Group and select your relevant group header.
Very simple or completely wrong! I'll let you make your mind up!
Take it easy
Rob
Thanks for giving it a shot, Rob. =]
Yeah, I knew about the On Change of Group. I'm able to create a new running totals field for each individual group, but that's what I want to avoid. Instead of selecting the exact group, I'm trying to find a way to code it so that the field examines which group it is currently being evaluated in so that I don't have to create a running totals field for each group as I have a lot of fields that I'm getting the sum for in each group. This would cut my work by a third (or 1/4th for some reports as there will be 4 groups with running totals).|||Actually, a running total has to be placed in an appropreate group footer.
If it has to be reset on change of group#1, it has to be placed in GF1.
If it has to be reset on change of group#2, it has to be placed in GF2 but not in any other one.
How are you planning to solve that problem?|||Try to solve your problem with a new table, view or query where the subtotals are included
I use Crystal in all my projects but I know that it has limits ( or myself ) and always try to make my reports as simple as I can by resolving almost all the stuff at programming side
Friday, March 23, 2012
Running the same query on multiple servers
do this via query analyzer and would like to cut down the time it takes
to switch servers.
Is there a tool I can configure multiple connections on and run the same
query on selected servers.
Thanks
Dilan
create linked servers and run the queries as
select ... from servername.databasename.objectname
Dandy Weyn
[MCSE-MCSA-MCDBA-MCDST-MCT Community Leader]
SQL Server Technologist
http://www.dandyman.net
Check my SQL Server Resource Pages at http://www.dandyman.net/sql
"Dilan A" <dilan.a@.youtelus.net> wrote in message
news:up7hf.129920$S4.96172@.edtnps84...
> Hi, I periodically run the same query on multiple servers. Currently I do
> this via query analyzer and would like to cut down the time it takes to
> switch servers.
> Is there a tool I can configure multiple connections on and run the same
> query on selected servers.
> Thanks
> Dilan
|||Dandy Weyn [Dandyman] wrote:
> create linked servers and run the queries as
> select ... from servername.databasename.objectname
>
Thanks. I neglected to mention that the statements are always almost
updates to existing stored procedures and are supplied by our vendor as
patches. I received them as attachments in emails and have to save them
and then run them on about 8 servers.
|||You can either use DMO or oSql to do this pretty easily. Both methods allow
you to easily connect to another server and issue the same commands. You do
have to write some code but it should only be a few lines and a google
search will most likely find some examples.
Andrew J. Kelly SQL MVP
"Dilan A" <dilan.a@.youtelus.net> wrote in message
news:up7hf.129920$S4.96172@.edtnps84...
> Hi, I periodically run the same query on multiple servers. Currently I do
> this via query analyzer and would like to cut down the time it takes to
> switch servers.
> Is there a tool I can configure multiple connections on and run the same
> query on selected servers.
> Thanks
> Dilan
|||I tend to just use a batch file e.g. create 3 folders Output,Servers,Source
under a main folder (in my example it's DBADeploy). Create a batchfile as
below called deploy.bat in C:\DBADeploy
@.echo off
FOR /F %%f in (C:\DBADeploy\Servers\servers.txt) do
C:\DBADeploy\Source\Update.bat %%f
In the Servers folder create a file called servers.txt which is a list of
the target servers
In the Source folder create a file called update.sql with you code in it
(including USE database statements) and a batch file called Update.bat with
the contents below
@.echo off
set server=%1
set outputtemp=%1
set outputtemp=%outputtemp:\=_%
set outputfile="C:\DBADeploy\Output\%outputtemp%.txt"
osql -S %server% -d master -n -E -w 200 -h-1 -l 15 -i
"C:\DBADeploy\Source\update.sql" -o %outputfile%
echo Completed %1
Once that's setup then anything you want to deploy you can just stick in
update.sql and run deploy.bat and you're done. You can check the output for
each server in the Output folder.
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Dilan A" <dilan.a@.youtelus.net> wrote in message
news:up7hf.129920$S4.96172@.edtnps84...
> Hi, I periodically run the same query on multiple servers. Currently I do
> this via query analyzer and would like to cut down the time it takes to
> switch servers.
> Is there a tool I can configure multiple connections on and run the same
> query on selected servers.
> Thanks
> Dilan
Tuesday, March 20, 2012
Running SQL Server Enterprise 2005 on MS Virtual Server
Running SQL Server in a virtual machine should work. I do this for scenario testing all the time.
The usual suspects for connectivity problems in virtual machines are whether the virtual network adapter is attached to the host's network adapter (vs. the "local adapter" that can't be seen outside the virtual server environment) and the host's firewall getting in the way of other computer's talking to the virtual machine.
The typical issues with SQL Server connectivity also apply to SQL Servers running in virtual machines. Make sure SQL Server is configured to listen to TCP/IP connections on the virtual network adapter that is mapped to the host's network adapter. Also, make sure that the firewall in your virtual machine is allowing external connections to SQL Server's port.
|||We are running some test environments on Virtual Server.
We haven't experienced any issues so far.