Use Batch File To Update SQL

Apr 15, 2004

Ok.. I thought I could do this but I can't get this to work.. I need to create a batch file to run an sql update statement.. This is simple but I can't get it to wortk.. How do I do it?

View 4 Replies


ADVERTISEMENT

Create Batch File That Will Run Update Statement And Schedule It To Run?

Oct 7, 2013

Is there a way to create a Batch file that will run an Update Statement and schedule it to run?I've used bcp to extract data to a txt file before, but i'm not sure if an Update can be performed.I'm using SQL Server 2008 R2 Express Edition so i don't have Server Agent available.

View 7 Replies View Related

Passing Parameters To Batch File And Executing Batch File Loop

Aug 7, 2007

HELP,

I need to take a variable from a tabel in SQL Server pass to a Batch file and execute the batch file. Right now I can exec the batch file with XP_CMDSHELL but how can I pass the variable to the batch file and loop through all the variables.

Please help

Phil

View 4 Replies View Related

SQLCMD Batch File With Script In Batch File

Dec 5, 2006

I am using the following batch file to execute a script that creates a db and all its objects in the local sql express:

sqlcmd -S (local)SQLExpress -i C:CreateDB.sql

This works fine, but I'm wondering if there's an easy way to put the script in the batch file, so users don't have to worry about putting the script in the C drive. I tried getting rid of the i parameter and pasting the script from the sql file into the batch file, but it didn't work.

Thanks,

Dave

View 1 Replies View Related

Batch Update

Aug 12, 2007

Hai, i would like to do Bulk update to avoid the round trip to the database.
Means, In my UI im dsiplaying all the employee details who are related to one particular dept. Now i want to update the bonus to all the employees based on their category. UI changes are refelected in the Datatable(.NET). Finally the datatable changes i would like to update in the Database.
how can i do that..
sample code pls.
im very very new to sql

View 3 Replies View Related

Management Studio Express && SQLcmd: Syntax Errors In Executing A MS-DOS Batch File && A Microsoft SQL Server Query File?

Nov 2, 2007

Hi all,
I have the "Northwind" database in my Sql Server Management Studio Express.

In my C:ProSSEAppsSamplesForChapter02Chapter02 folder, I have the following 2 files:
(1) ListColumnValues (MS-DOS Batch File)
sqlcmd -S .sqlexpress -v DBName = "Northwind" CName = "CompanyName" TName =
"Shippers" -i c:prosseappschapter02ListListColumnVales.sql -o
c:prosseappschapter02ColumnValuesOut.rpt
(2) ListColumnValues (Microsoft SQL Server Query File)
USE $(Northwind)
GO
SELECT $(CompanyName) FROM $(Shippers)
GO
When I ran the following SQLcmd:
C:ProSSEAppsSamplesForChapter02Chapter02>ListColumnValues.bat
I got the following "ColumnValuesOut.rpt" with error messages:

'Northwind' scripting variable not defined.
Msg 102, Level 15, State 1, Server L1P2P3SQLEXPRESS, Line 1
Incorrect syntax near '$'.
'CompanyName' scripting variable not defined.
'Shippers' scripting variable not defined.
Msg 102, Level 15, State 1, Server L1P2P3SQLEXPRESS, Line 1
Incorrect syntax near 'CompanyName'.

I copied these T-SQL statements from a book and I do not know how to correct them.
Please help and tell me how to correct these errors.

Thanks in advance,
Scott Chang




View 3 Replies View Related

Batch File To Copy File And Append Date

Jan 5, 2005

The Sql Server database can only see the local drive.

I would like to set up a batch file that will copy a SQL Server

backup file from the local drive to the network drive. I would

like to append the file date to the end of the copied file. I

assume a batch file can accomplish this but I am new to batch

file writing. Does anyone have code that they already created

for this sort of task??

Thank you!

View 13 Replies View Related

SQLBulkCopy Vs. Batch Update

Apr 17, 2007

I have a collection of around 16000 records, and have been trying to find the best way to update the information in the DB. I have done alot of reading about both BulkCopy and Batch Update, but haven't come to any clear solutions as to which performs better. I am not doing any inserting, just getting a dataset from the DB, changing the values, them want to update the Db again. Thanks for any help. Mick 

View 8 Replies View Related

Batch Update Of A SQL Table

Jul 1, 2007

Can anyone help a beginner with some T-SQL which runs as a scheduled stored procedure to update a table with is then accessed via an ASP web application.
 I have a table called Loans which contains a calculated column which will indicate in days if a loan item is late and also each row has a charges column to reflect a charge for late returns.
In a seperate table I have a charge per day for late returns.  I read this into a variable @LateCharges
I'd like to consutruct some T-SQL to scan through the Loans table and for every row where Status is not 'Returned' I woule like it to update the charges column based on the DaysLate column*@Latecharges
Any help much appreciated.
Regards
Clive

View 3 Replies View Related

Batch Update In Stored Procedure

Feb 26, 2004

The following code is a part of my stored procedure MySP. I would like to update Users table with input variable @userIDs which has the following format:

101, 102, 103

I got the error message:

Syntax error converting the varchar value '101, 102, 103' to a column of data type int.

Obviously, UserID has datatype int. How can I write this SP?


CREATE PROCEDURE dbo.MySP
@userIDs varchar(100)
AS
SET NOCOUNT ON

BEGIN TRANSACTION

UPDATE Users SET IsActive = 1 WHERE UserID IN (@userIDs)

IF @@ERROR <> 0
ROLLBACK TRANSACTION
ELSE
COMMIT TRANSACTION

SET NOCOUNT OFF

View 8 Replies View Related

Strange Exception - Batch Update

Apr 19, 2007

Can anyone help me understand what this means:




Code Snippet

java.sql.BatchUpdateException: com.microsoft.sqlserver.jdbc.SQLServerException: The IOBuffer.process operation returned an unknown packet type:0. Index:41. End:83.TDS_DONEINPROC(-1) TDS_DONEPROC(-2) TDS_DONE(-3) TDS_COLMETADATA(-127)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(Unknown Source)




I'm trying to do a very simple batch update.

View 7 Replies View Related

Checking For Unique Constraints During A Batch Update

Jan 28, 2004

hello .
i have a grid for a table that gets updated with recordset.updatebatch
for a multi-user application.

the problem is that some of the table fields have to be unique

now imagine the next situation.

user A opens the form
user B opens the form
user A writes '1000' in the unique field
user A saves the recordset with updatebatch

user B writes '1000' in the unique field
user B saves the recordset with updatebatch

now there will be two records with the field '1000' !

how can i avoid this ?
i cannot check for unique during the update event of the grid
because it should check during the time it is saving and not
when it is just entering data without having updated the recordset

thanks !

View 2 Replies View Related

Database Change In Batch Update SQL Script

Oct 31, 2007

I used "OLE DB Command"(row by row) for update but because i found that very very slow i decided to try batch update. I check what is for insert and what is for update and those things that are for update i save to temp table. Then i run this:
update [ODS].[dbo].[Adres]
SET
[MutatieDatumEinde] = stAdres.MutatieDatumEinde,
[StraatNaam] = stAdres.StraatNaam,
[HuisNummer] = stAdres.HuisNummer,
[HuisNummerToevoeging] = stAdres.HuisNummerToevoeging,
[Postkode] = stAdres.Postkode,
[Plaats] = stAdres.Plaats,
[Land] = stAdres.Land,
[IndicatiePTTAdresStandaard] = stAdres.IndicatiePTTAdresStandaard,
[KodeHerkomstAdres] = stAdres.KodeHerkomstAdres,
[VervalDatum] = stAdres.VervalDatum,
[BronODS] = stAdres.BronODS
from
[ODS].[dbo].[Adres] oAdres
inner join [M2O_Stage].[dbo].[ODS_Adres] stAdres
on oAdres.InstNr = stAdres.InstNr and
oAdres.TypeAdres = stAdres.TypeAdres and
oAdres.MutatieDatumAanvang = stAdres.MutatieDatumAanvang
where stAdres.IsInsert = '0'


I run this as an "execute sql task". Everything is running as it should and speed is incomparable, but.. i have problem to make this generic... what i mean is.. db names will change.
How can i make db names dynamic here ?

p.s. i just got idea .. i could probably make dynamic sql statement in script component and then run it there... but does anyone have a better idea ?

View 3 Replies View Related

Help With Batch File

Jan 22, 2002

hi,
I need some help in accomplishing this task.

I want to design a DTS task which will:
a)copy a certain given files from one directory to another
b)import the files into the tables
c)upon successful import delete the files from the original directory.

I done know much about scripting and need help in figuring out steps a) and c).
thanks
Zoey

View 2 Replies View Related

Batch File

Sep 13, 2001

Do u know how to write a batch file
for example i will need to type the sql server name it has to connect to the server and run a script that I have

let me know if u have any ideas of doing it

View 2 Replies View Related

Batch File

Sep 13, 2001

Do u know how to write a batch file
for example i will need to type the server name it has to connect to the server and run a script that I have

let me know if u have any ideas of doing it

View 3 Replies View Related

BCP From A Batch (*.bat) File....

Mar 29, 2000

Can someone show me an example of the syntax required to execute multiple BCP commands within the same batch (*.bat) file?

Sorry if this is a bit of a basic question, but not being a programmer by profession, I need to plead ignorance. I've tried a few things, but I just can't seem to figure it out.

Thanks!

Rich

View 4 Replies View Related

Batch File

Apr 3, 2007

Hi pals,

I need a small help from u all.
I need a Windows batch file script which does the ftp to remote machine and "puts" a file
say "data.xls" from a predefined dir say "c:uploads" and puts on the database server "d:dumps".


Regards,
Franky

View 2 Replies View Related

Bcp Within Batch File

Jul 20, 2005

I have a windows batch file that executes a SQL Server bcp command. Iwould like to obtain a return code if the bcp command fails. However,I cannot seem to find the return code (if any) for bcp. For example,if the bcp command is improperly formatted, or has a bad password, Iwant the batch file to return an error. Right now, my batch filesimply executes and returns success, even when the bcp command fails.Has anyone run into this before?Thanks!

View 3 Replies View Related

Batch Script To Create ODBC And Update Registry Datasource Key - Help!

Feb 21, 2008



I have create a batch file, that creates an ODBC then updates the application datasource key in the registry to the new system dsn name.

The problem is that the new DSN doesn't work when i try and connect the application...but if i had manually created the odbc source the app connects as expected... i have checked the registry and there is no difference between the two dsns created...but the application throws IM002[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified after i have also changed the applications registry key to point to the new database.

Now the interesting things to note are that when i re-create the odbc to the old server and database (sql 2000) by batch file it works fine. The new ODBC is linking to a sql 2005 database, but it is still using the 2000 drivers and when i manually created it, it worked also.

Another interesting thing is that if i go into the odbc dsn and click configure, go through and test the connection it works fine... after i close this i then retry the application and it opens correctly...

I need this to be automated with no manual intervention, as this will be added to a large group of users login scripts!

Any help greatly appreciated.

My batch file code is as below:

ODBCCONF.exe CONFIGSYSDSN "SQL Server" "DSN=RMS Live 2005 | SERVER=d-db99sql2005| Trusted_Connection=Yes | Database=RMS-Livedb"

View 4 Replies View Related

Batch File To Restart SQL

Mar 14, 2006

Hey all..   I am wanting my SQL Server installation to restart its services at a time I define in the Scheduled Tasks feature of the server its on
I need help with command line commands to:- Stop SQL Server Agent service- Stop and Start SQL Server service- Restart SQL Server Agent service
Thanks in advance

View 1 Replies View Related

Batch File Not Executing.. Please Help

Nov 6, 2000

Hi all,
I am executing a backup batch job scheduled daily. It runs
successfully but havent backed up any of the databases. The message
is
"The name specified is not recognized as an
internal or external command, operable program or batch file."

I am trying this for a full day and i gave up..please can anyone help
me or suggest me what to do?..The same batch file is executed in all
servers and is working fine..

Thank you in advance

Rani.

View 2 Replies View Related

Execute Batch File

Mar 31, 2000

Hi,
I would like to ask someone who could help me with one small problem:

I would like to run SQL server task on one of my servers, that will connect
to all other servers (including ones that are not SQL servers, ie: Exchange,
Test Server etc) one at the time, and that will execute one batch file (update.bat) that is residing on each server under C: drive.

Batch file will copy some things from all of the servers to one server.

Thanks, in advance.

Regards,
Vilko

View 1 Replies View Related

Using Win NT 4.0 Schedualer To Run A Batch File

Oct 21, 1998

Hi,I want to Utilize the schedule feature in window NT to run a batch file which will migrate data from a text file into an Sql server 6.5 table.
here is the senario,
I want to program window NT using AT,For, Start etc. I do not know how and have not yet succeeded. Please help?

the case:
I already wrote a code using bcp in a batch file as follow

if exist c:authors.out bcp pubs..authors in c:authors.out /Sservername /Usa /Ppassword /fp:autors.fmt

so the command line is basically if the file named authors.out exists in drive c: then run the bcp command. here is the problem, how can I run this code in the first place? A I going to use the AT command in window NT to run this code on a specific day and time to check if the author.out file exists.
Please help , I am in urgent need for a solution

You can write back to me at a.alhussein@mci.com

Thanks again for your time and effort to help me

regards
Ali

View 3 Replies View Related

Batch File To Run A Query

Jan 1, 2005

Dear All,

i need to put a query in a batch file to be easy to use by the user.
jusy only double click on it and it will work.

can any one help?

View 10 Replies View Related

Execute Batch File As Sql Job

Apr 5, 2006

I'm trying schedule a batch file to run as a job from sql server agent. The batch file copies files from one server directory to a directory on another server. The batch file works properly when executed directly. The job is being executed under the sql service account login. I've given the service account access to both the source and destination directories.

When I try to run the job it fails with an "Access is denied" error on both the source and destination directories (as read from job history).

Any ideas?

View 4 Replies View Related

Creating A Batch File

Jun 13, 2008

Hi All, I need to create a batch file to execute some 5-6 sql scripts. I have sql scripts for creating a table and related storedprocs and I need to generate a batch file to run all this scripts.

View 3 Replies View Related

Run Batch File In A Job Step.

Sep 27, 2006

MS SQL Server 2005

i get the following error when trying to run this job as user1:
'Unable to start execution of step 1 (reason: Error authenticating proxy serv1user1, system error: Logon failure: unknown user name or bad password.). The step failed.'

and the following error when trying to run the same job as 'sql agent service account':
'Executed as user: serv1user1. The process could not be created for step 1 of job 0x3653ACCFFA46DD47B3703C87DDFD0717 (reason: 2). The step failed.'

>job:
job name: job1
server: (local)
connection: net1user1
owner: serv1user1
step type: operating system (cmdexec)
run as: user1
command:@echo off
copy C: est.txt C:folder
ECHO Job completed
PAUSE

>the sql server agent service is running under 'serv1user1' and works fine for other jobs running ssis packages.

>i have created the following credentials under security/credentials:
credential name: serv1user1
identity: serv1user1
password: same as sql server agent service


>i have created a proxy under the sql server agent/operating system (cmdexec):
proxy name: user1
credential name: serv1user1
active subsystem: operating system (cmdexec)
principals (sql login): serv1user1

thank you

View 2 Replies View Related

Execute A Batch File

Jul 25, 2007

Hi All,
I would like to embed some stored procedures in a batch file and execute it from the command prompt on windows.
I have no idea of how to embed a stored proc in a .bat file.
Can you please redirect me to the solution to this?

Thanks in advance
vishu

View 1 Replies View Related

Running A Batch File

Mar 10, 2008

Hi

Is it possible using T-SQL to run a batch file located on different server, ie. PC1 has SQL Server on it, PC2 has the batchfile, I need to run the batchfile stored on PC2 on PC1.

Thanks

View 3 Replies View Related

Using Sql To Execute A Batch File

Aug 9, 2007

Is it possible to use sql to execute a batch file? I would like toexecute the following "C:BTWartend.exe /f=C:BTWToolboxFormatscarnum.btw /p", 6Thanks,Matt

View 6 Replies View Related

Does Anyone Know How To Run A Batch File Using Vb Script?

Sep 28, 2006



This is not working.

Set oShell = CreateObject("WScript.Shell")
oShell.Exec "test.bat"

View 4 Replies View Related

Running A Batch File

Mar 11, 2008

Hi

I am trying to run a batch file stored on different server from the one that SQL Server is on using T-SQL. I am using the following syntax:

EXEC master..XP_CMDShell '\hit1DEVArchivingArchivingDataFiles.zipdata.bat'

But it doesnt seem to be working, it states that it is not recognised as an internal or external command.

Any ideas?

Thanks

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved