Call & Exec Batch File From Query Analyzer

Apr 16, 2001

How can I call a batch file from within Query Analyzer, which is the same batch I'm using with isqlw command.

Thanks

View 3 Replies


ADVERTISEMENT

Sql Query Analyzer Against Cisco Call Manager DB

Nov 24, 2006

Greetings all. New user here. I'm just getting started with using sql query's with our cisco voIP call manager database. Although cisco has a utility "CDR" which runs pre-defined reports; it's not enough. So far there have been several request for specific data which "CDR" cannot compile, in which we have to use analyzer. Unfortunately I'm not versed and need a little help. It's been asked I pull a report from call manager which shows all "forced authorization Codes" cisco calls these client matter codes. Here is the query I tried using. It pulls all user data but the client matter code column is empty. I tried with * and *.* inside brackets as well.

select * from CallDetailRecord where clientmattercode=''

Can anybody help so I can get the records of who has what particular in use client matter code?

thanks to all in advance, I hope to learn as much as possible from the experts.

View 13 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

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

Getting A File Name From Query Analyzer

Sep 24, 2006

Hi all,

im trying to write a stored procedure that will basically browse a folder and get me the first file that it sees. Is there any way that I can do this in TSQL or using CLR in C#? I was thinking something along the lines of using the dos dir command and triyng to pipe it into a variable, not sure how to go about doing this. Any suggestions?

dir /b ...gives me the bare file names, but it lists all the files in the folder, any way that i can just get the first file ( i dont really care what file).

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

Export A Query To CSV From Batch File

Sep 19, 2014

I'm trying to export a query to a csv file from a batch file.

batch file:
sqlcmd -S loni-sbs -d lonikahn0207 -E -Q "select * from ael" -o "AELORI.csv" -h-1 -s"," -w 700

BUT, I'm getting a user name and password issue inside the csv file:

Cannot open database "lonikahn0207" requested by the login. The login failed.
Msg 18456
Login failed for user 'LONIBOOKSAdministrator'.

View 1 Replies View Related

SQL Query In Batch File Problem

Aug 11, 2006

Hi,

I am trying to run this query in a batch file but am getting an "Incorrect syntax near keyword 'and'" error. Any help would be much appreciated. Thanks, Jeff

ECHO OFF
set GatewayDB="SybaseHDR_Prod"
set DBUser="user"
set DBPswd="pswd"
set SQLServer="nnn.nn.nnn.nn"
set HdrctlNbr1 ="20060714000000000000"
set HdrctlNbr2 ="20060727999999999999"

ECHO ========================================================================
ECHO Start of Bulk Copy Process from Production Tables to Output Text Files
ECHO Database is : %GatewayDB%
ECHO Server : %SQLServer%
ECHO File AuthNbr: %AuthNbr%
ECHO ========================================================================

set TableName="hdr_ctl_nbr_status"
set outfile="C:BCPhdr_ctl_nbr_status.txt"
If exist %outfile% del %outfile%
bcp "SELECT * FROM %GatewayDB%..%TableName% where hdr_ctl_nbr between %HdrctlNbr1% and %HdrctlNbr2%" queryout %outfile% -b1000 -c -t~ -U %DBUser% -P %DBPswd% -S%SQLServer%
REM pause


:END

ECHO ================================
ECHO Bulk Copy process is completed !
ECHO ================================

pause

View 5 Replies View Related

Running SQL Query From Batch File- MS SQl 2000

Mar 25, 2008

Hello,
I am looking for some way to run a sql query from a batch file on the SQL server. The query needs a user entered parameter, if that can be accomodated it would be great.
I read about some osql command & tried to run it but it kept saying "Server does not exist or access denied."
Please give me the steps to go about this.
Thanks,
-R

View 4 Replies View Related

How Do I List Contents Of File Directory In The SQL Query Analyzer

Apr 13, 2006

how do I list contents of file directory in the SQL Query Analyzer

View 1 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

Using An Exec Query To Insert Pdf, .doc File Into Table From A Dir Path Which Is A Field In Another Table

Aug 5, 2007

I have the following query in sql 2005:


PROCEDURE [dbo].[uspInsert_Blob] (

@fName varchar(60),

@fType char(5),

@fID numeric(18, 0),

@bID char(3),

@fPath nvarchar(60)

)



as

DECLARE @QUERY VARCHAR(2000)

SET @QUERY = "INSERT INTO tblDocTable(FileName, FileType, ImportExportID, BuildingID, Document)

SELECT '"+@fName+"' AS FileName, '"+@fType+"' AS FileType, " + cast(@fID as nvarchar(18)) + " as ImportExportID, '"+@bID+"' AS BuildingID, * FROM OPENROWSET( BULK '" +@fPath+"' ,SINGLE_BLOB)

AS Document"

EXEC (@QUERY)

This puts some values including a pdf or .doc file into a table, tblDocTable.

Is it possible to change this so that I can get the values from a table rather than as parameters. The Query would be in the form of: insert into tblDocTable (a, b, c, d) select a,b,c,d from tblimportExport.

tblImportExport has the path for the document (DocPath) so I would subsitute that field, ie. DocPath, for the @fPath variable.

Otherwise I can see only doing a Fetch next from tblIportExport where I would put every field into a variable and then run this exec query on these. Thus looping thru every row in tblImportExport.

Any ideas how to do this?

View 1 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

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

Easy SQL Question. How To Display Query Results In Query Analyzer

Feb 12, 2008

When I run the following query from Query Analyzer in SQL Serer 2005, I get a message back that says.
Command(s) completed successfully.
What I really need it to do is to display the results of the query. Does anyone know how to do this?
declare     @SniierId as   uniqueidentifierset @SniierId = '85555560-AD5D-430C-9B97-FB0AC3C7DA1F'declare    @SniierAlias  as nvarchar(50)declare    @AlwaysShowEditButton  as bitdeclare     @SniierName  as  nvarchar (128)/* Check access for Sniier */SELECT TOP 1       @SniierName      = Sniiers.SniierName,        @SniierAlias    = Sniiers.SniierAlias,        @AlwaysShowEditButton = Sniiers.AlwaysShowEditButtonFROM SniiersWHERE Sniiers.SniierId=@SniierId

View 3 Replies View Related

Query Analyzer Runs The Query Instantly But ADO Can Take Forever???

Aug 29, 2001

THis is so annoying. I have 3 ADO executes in my program. THe first one creates a view, the second one performs an outer join on that view and returns a result set, the third execute drops the aforementioned view. THe program that is using this is installed on about 200 computers scattered across Germany and Italy, all querying the same MSsql server 7.0. THe queries run quite quick when few users are actively using the program (after hours for example). however in the heat of the day performance goes up and down dramatically with identical queries taking from 1 to 20 seconds to return their result set. Now I initially thought 'bandwidth issue out of our server'. However I noticed that if I take those three queries and run them from the sql server enterprise manager( running on the same computer as the aforementioned program) then the queries run instantly and the data is in my result pane in less than 2 seconds ALWAYS....even when the program is dogging it with 20 second delays before the result set returns. I know it is hanging on the return of the result set as I put a stop after before each ADO execute in order to check which one was eating up my time. Why is there this dichotomy between running the queries from my enterprise manager versus running them from an ADO object. Both are using TCP/IP (no named pipes involved). I havent monkied with the attributes of the ADO result set so they are all set to default.
I have used the sql server profiler to trace these queries and they always run in less than 33 milliseconds. THe duration is also never more than 33 milliseconds. THis stinks of a network resource issue but what always leads me somewhere else is how consistent the performance of the enterprise manager is when it runs the exact same three queries.

Here is my slightly edited connection string
Public Const connection_string = "Provider=SQLOLEDB;Server=000.000.000.000;" & _
"User ID=johndoe;Password=janedoe;Network=dbmssocn;" & _
"database=fidojoe"

Here are the 3 ADO executes:
conn.Execute (sqlstr_create_view)
Set resultset1 = conn.Execute(sqlstr_get_providers_by_DMISID)
conn.Execute (sqlstr_drop_view)

View 3 Replies View Related

Same Query Gives Result With Different Column Sequence When Used In Query Analyzer

Feb 25, 2012

When I run query in excel it gives result with different column sequence. The same query gives result with different column sequence when used in query analyzer or VBA Macro. E.g., Select * from ABC.

result in Excel 2003 SQL OLE DB query

col-A col-B col-C
values...

Result with Query Analyzer and VBA Macro

col-c col-B col-A
values...

View 3 Replies View Related

Re-display Result Set Without Re-running Query In Query Analyzer?

Apr 9, 2006

I hope I am not asking about something that has been done before, but Ihave searched and cannot find an answer. What I am trying to do is torun a query, and then perform some logic on the rowcount and thenpossibly display the result of the query. I know it can be done withADO, but I need to do it in Query Analyzer. The query looks like this:select Varfrom DBwhere SomeCriteriaif @@Rowcount = 0select 'n/a'else if @@Rowcount = 1select -- this is the part where I need to redisplay the resultfrom the above queryelse if @@Rowcount > 1-- do something elseThe reason that I want to do it without re-running the query is that Iwant to minimize impact on the DB, and the reason that I can't useanother program is that I do not have a develpment environment where Ineed to run the queries. I would select the data into a temp table, butagain, I am concerned about impacting the DB. Any suggestions would begreatly appreciated. I am really hoping there is something as simple as@@resultset, or something to that effect.

View 6 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

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

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 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







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