Running A Host Command From Sql Server ".sql" File.

Jun 14, 2001

Hi All,

How can I run a host command (OS command ) from ".sql" script of sql server?


-- Rajesh

View 2 Replies


ADVERTISEMENT

Error While Running Script On Host Server

Aug 19, 2006

I am trying to deploy my database-driven ASP.NET application to my web server.  I have hosting through godaddy.com and they require that you run a script through their SQL admin Query Analyzer to create the database.  After I attach the database in the Management Studio, I generate the script, copy and paste it into the QA and get the following error.  Any help?Error -2147217900

Line 18: Incorrect syntax near '('.SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Students]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[Students]( [StudentID] [int] IDENTITY(1,1) NOT NULL, [FirstName] [nvarchar](20) NULL, [LastName] [nvarchar](20) NULL, [PhoneNumber1] [nvarchar](15) NULL, [PhoneNumber2] [nvarchar](15) NULL, [Instrument] [nchar](20) NULL, [Interests] [nvarchar](50) NULL, [Active] [bit] NULL, [TimeID] [int] NULL, [UserID] [nchar](20) NULL, CONSTRAINT [PK_Students] PRIMARY KEY CLUSTERED ( [StudentID] ASC)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]ENDGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Lessons]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[Lessons]( [LessonID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, [CurrentNotes] [nvarchar](250) NULL, [FutureNotes] [nvarchar](250) NULL, [DateTime] [datetime] NULL, [StudentID] [int] NOT NULL, CONSTRAINT [PK_Lessons] PRIMARY KEY CLUSTERED ( [LessonID] ASC)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]ENDGOIF
NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id =
OBJECT_ID(N'[dbo].[FK_Lessons_Students]') AND parent_object_id =
OBJECT_ID(N'[dbo].[Lessons]'))ALTER TABLE [dbo].[Lessons]  WITH CHECK ADD  CONSTRAINT [FK_Lessons_Students] FOREIGN KEY([StudentID])REFERENCES [dbo].[Students] ([StudentID])ON DELETE CASCADEGOALTER TABLE [dbo].[Lessons] CHECK CONSTRAINT [FK_Lessons_Students]

View 1 Replies View Related

Running A SQL File From OSQL Command Line Utility

Jul 20, 2005

Hi,I have dumped a very large database from mysql (using mysqldump program)as a raw sql file. The reason was, convert this database to a MSSQLdatabase. Since mysqldump creates the file as raw sql file with thedatabase-table structures and the data in it, I thought using OSQL commandline utilities should work to out this whole database in MSSQL server.I have run this command from command line:osql -u sa -i mysqldump.sqlIt is going since yesterday. It has been almost 36 hours that it'sstarted. And in the mssql server, I see no database created yet. On thescreen of the command line, I see bunch of numbers are going in order. Iassume they are row numbers of the tables processed. But, if it is doing it,then where is it saving all this data ? I have checked the tempdb, pub db,other dbs, and I see no tables related to the database I am inserting. Willit populate it at the and of the job ? Or, am I doing something wrong here?Regards.Murtix.

View 2 Replies View Related

Local Host Not Running Database Connections

May 6, 2008

hi my local host cannot open the connection to my database, whilst testing with vwd seems to be able to do this? other server side functions work (response.write("hello world"))
in my iis the version of .net it says its running reads: 2.0.50727, though when i go to add / remove programmes i have 3.5 there? maybe its nothing to do with .net versions?
thanks in advance for your help
 pete

View 5 Replies View Related

Running Sp From The Command Prompt (of Another Server)

Jan 23, 2001

I have created linked servers and successfully run the following stored procedure.

exec [db-2001server].sales..sp_test

Can anyone give me the exact syntax for running the same from command promt(without using the query analyzer).I am new to isql/osql.So,please help me with the syntax.
Thanks!!

View 1 Replies View Related

What Command Do I Use To Check How Many Processes Are Currently Running On The Server ?

Feb 29, 2008



Hello friends I want to ask that by which command I can know about how many process are currently running on the server ?

Waiting for reply.......

View 7 Replies View Related

Transact SQL :: Script To Find List Of Queries Currently Running In Database With User Login And Host Name?

Dec 30, 2014

How to find the list of queries currently running in the Database with User Login Information.

Since my database application is running slow, to find the slow queries.

View 8 Replies View Related

Unable To Open BCP Host Data-file

Feb 13, 2007

I am having trouble with BCP. I get the same error with xp_cmdshell as I do with entering bcp as a DOS command. I have checked and rechecked the file names and permissions and even restart the PC.

Does BCP even work when SQL Server 2005 Express on a PC?

declare @sql varchar(8000)
select @sql = 'bcp SYMITAR..ACCOUNT in C: estEXTRACT.ACCOUNT -T -f C: estACCOUNT.FMT -S'+@@servername
exec SYMITAR..xp_cmdshell @sql
GO

Volume in drive C has no label.
Volume Serial Number is 08E5-2414

Directory of C: est

02/13/2007 08:44 AM <DIR> .
02/13/2007 08:44 AM <DIR> ..
08/31/2006 09:11 AM 27,503,161 EXTRACT.ACCOUNT
08/31/2006 09:12 AM 6,879 FMT.ACCOUNT
02/07/2007 08:46 AM 220 ACCTTYPE.FMT
02/13/2007 08:44 AM 0 filelisting.txt
02/07/2007 08:33 AM 220 ACCTTYPE.xml
5 File(s) 27,510,480 bytes
2 Dir(s) 54,344,847,360 bytes free

Could the fact that it's actually pulling BCP from c:Program FilesMicrosoft SQL Server80Toolsinn be a problem? I know this because it doesn't recognize the -x extensionof the bcp command.

PATH:
%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;C:Program FilesCommon FilesGTK2.0in;C:Program FilesMicrosoft SQL Server80ToolsBINN;c:Program FilesMicrosoft SQL Server90Toolsinn;c:Program FilesMicrosoft Visual Studio 8Common7IDEPrivateAssemblies;c:Program FilesMicrosoft SQL Server90DTSBinn;c:Program FilesMicrosoft SQL Server90ToolsBinnVSShellCommon7IDE;C:Program FilesQuickTimeQTSystem

...

I added the c: est to the path and removed c:Program FilesMicrosoft
SQL Server80Toolsinn from the path. While it recognizes the -x
extension now it still gets the same error message:

SQLState = HY000, NativeError = 0
Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file
NULL

View 11 Replies View Related

Unable To Open BCP Host Data-file

May 10, 2007

Hello,



I have checked file names, and I have checked permissions on the files. I do not see any reason why the BCP should fail. Any ideas how I can debug this further?



Thanks

Tom

View 1 Replies View Related

Incorrect Host-column Number Found In BCP Format-file

Jul 20, 2005

Hi guys, would appreciate if you can shed some light on this.Sorry to be a pain, can you tell me what is wrong with the following:for /F %%i in ('dir /b /on c:cppc*.txt') do bcp Inventory..pc in%%i -fc:cpcp.fmt -T -S CHICKYywhere CHICKYy is the serverbcp.fmt8.00.19461 SQLCHAR 0 20 ", " 0 filler_1 ""2 SQLCHAR 0 8 "
" 1 computer_name ""3 SQLCHAR 0 20 ", " 0 filler_2 ""4 SQLCHAR 0 16 "
" 2 ip_address ""5 SQLCHAR 0 20 ", " 0 filler_3 ""6 SQLCHAR 0 60 "
" 3 operating_system ""pc1.txt and other *.txt format is:JW_193801,192.168.1.1,Windows XP,when I run it I get:C:cp>for /F %i in ('dir /b /on c:cppc*.txt') do bcp Inventory..pc in%i -fc:cpcp.fmt -T -S CHICKYyC:cp>bcp Inventory..pc in pc1.txt -fc:cpcp.fmt -T -S CHICKYySQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]Incorrect host-column numberfound in BCP format-fileC:cp>bcp Inventory..pc in pc2.txt -fc:cpcp.fmt -T -S CHICKYySQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]Incorrect host-column numberfound in BCP format-fileC:cp>bcp Inventory..pc in pc3.txt -fc:cpcp.fmt -T -S CHICKYySQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]Incorrect host-column numberfound in BCP format-fileC:cp>bcp Inventory..pc in pc4.txt -fc:cpcp.fmt -T -S CHICKYySQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]Incorrect host-column numberfound in BCP format-fileC:cp>bcp Inventory..pc in pc5.txt -fc:cpcp.fmt -T -S CHICKYySQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]Incorrect host-column numberfound in BCP format-fileThe sql table has 3 columns:Sorry to be a pain.-----------------------------------------------------------------------"Are you still wasting your time with spam?...There is a solution!"Protected by GIANT Company's Spam InspectorThe most powerful anti-spam software available.http://mail.spaminspector.com

View 1 Replies View Related

TempDB Log File Running Out Of Free Space While Running DBCC CheckDB On Large Database

May 28, 2015

In my environment, there is maintenance plan configured on one of the server and while running DBCC checkdb on a database of size around 200GB, log file usage of tempdb is increasing and causing the maintenance job to fail.

What can I do to make the maintenance job run successfully, size of the tempdb database is only 50GB and recovery model is set to simple. It cannot be increased as the mount point on which it is residing is 50GB.

View 3 Replies View Related

Storing Variable In Command File From SQL Server

Sep 13, 2004

Hi,
i am using command files(.cmd) and osql utility to conneft to a database.
following is the requirement.
I have a query "SELECT top 1 au_fname FROM pubs..authors".

Can i store the value of au_fname in the command file?

Is there any work around for this.

Any help is appreciated.

Thanks.... :)

View 1 Replies View Related

SQL 2012 :: Run A Command To Send File To TSM Server

Oct 3, 2014

write a backup to local disk and then run a command to send the file to the TSM Server.This is the command I use at a Command Prompt to do an TSM incremental backup.

Command for an incremental backup of drive letter h:
C:Program FilesTivoliTSMaclientdsmc incremental h:

Command for an incremental backup of a mount point:
C:Program FilesTivoliTSMaclientdsmc incremental -domain="E:Backup"

I would like to be able to run this as the last step in my backup processes. This would allow me to send my local backup file to the TSM server to write to tape.

I am looking for either a CMDEXEC Expert that could show me the syntax to run these commands via a direct command or a batch job. The other option would be to run these commands via the Powershell type.

View 3 Replies View Related

How Read CSV File In Other Server Using Bulk Insert Command In Sql Server In Different Server...

Mar 24, 2008

Hi All,
 Please some one help me...
I have to insert a csv into one table in sql server. But the problem is the file is in one server and SQL SERVER 2005 is in other server..
 how do i insert the file....
please help me.....
 

View 1 Replies View Related

Running A DTS Job From Command Prompt

Oct 17, 2000

Sorry for the new thread.
How to run a DTS job from command prompt? Any help is appreciated!
Thanks.

View 1 Replies View Related

Running A Script File In SQL Server

Dec 11, 2001

Hi guys,
I am a new person to sql. I wanted to know how you execute a script file in Query analyzer.
and also I wanted to know how you get the output to a file.
Thanks for the help . Please I need this info asap.

View 1 Replies View Related

Running A Sql Server Mdf File From A Usb Drive

Apr 9, 2008

Hi All,
I've been trying to find the answer but been unable to. My question is it possible to create a SQL Server (2005) database in a usb2 drive? I have a large usb drive that i would like to store my database into instead of my local drive which is not that big.

Thanks

View 2 Replies View Related

Running SQL Scripts From Command Prompt

Jul 25, 2006

I have a requirment, when a user logs in to the pc, I want to run some SQL scripts which is been saved as a stored procedure on another pc. Could this be possible. I know in oracle you could do it using SQLLDR. Is there any way to do it in SQL?
Please advice. Any help is greatly appreciated.

View 3 Replies View Related

Running Transac SQL In Command Line

May 4, 2004

Hi all

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 MiloJ

View 2 Replies View Related

Error When Running The DTSRUN Command

Nov 7, 2007

HiWe're using SqlServer 2000.I want to run a DTS using the DTSRUN command.The commmand is inside a ".bat" file which my application is runningfrom an SQL client.No matter how I run it from the client it fails giving me the message:[ConnectionOpen (Connect()).]SQL Server does not exist or access deniedI've tried to run it from the client from the application, from thecommand prompt and it fails.I went into enterprise on the client and tried to run the DTS fromthere. The run failed already on the 1st step which is a call to astored procedure, also giving me the same message. This really stuck meas wierd because in enterprise I'm accessing the server successfully sowhy the above messgae. It identifies the server and I am accessing it.Because it failed on the 1st step which is a call to a stored procedureI tried running the sp from within query analyzer and it succeeded.Has anyone got any idea what the problem is and ghow to solve it.Thanks !David Greenberg

View 1 Replies View Related

Running Multiple DTS Packages By One Command

Oct 9, 2007



Hi Techs,

I have created several DTS Packages those are working fine, tested and verified.
I need to run them by a single click, either by batchfile or some sort of command.

Thanks
Iqbal Ansari



View 4 Replies View Related

How To Read A Remote CSV File Into SQL SERVER Using Bulk Insert Command..

Mar 24, 2008

Hi,
I have load a CSV file into one of the table in sql server 2005 using bulk insert command. But the csv file in remote system.
Please help me.....

View 1 Replies View Related

SQL Server 2008 :: File Formatting Export To Excel Using BCP Command

Aug 28, 2015

Declare@QRYvarchar(8000)
Select@QRY='bcp "Select COL1, COl2 From table(nolock)" queryout "D: est.xls" -c -T -S ' + convert(varchar(20), serverproperty('servername'))
Select@QRY
Execmaster..xp_cmdshell@qry

The file test.xls is getting generated but when opening getting the message

"File you are trying to open is in a different format than specified by the file extension"

Is there any property that can be set to avoid this message?

View 6 Replies View Related

Converting .dbf To Sql Server Table...batch File? Command Line?

Jul 20, 2005

My client will be receiving a .dbf file which needs to be uploadedinto a sql server database table (as an append) every week. They areNOT computer savvy and I would like to automate this process ratherthan go into enterprise manager and run data transformation.Is there any way to write a batch file or a set of command lines whichwill do this?Thanks.Monica

View 3 Replies View Related

Closed Transaction Keeps Running...awaiting Command

Jul 20, 2005

I am debugging an app which blocks many processes in a SQL7 server DB.The app log writes every transaction "open" and "close".The weird thing is : when the app logfile says the transaction isdropped (object closed) the db keeps showing the process "running", ina sleeping mode, with open_tran in 2 or even 3 and in an awaitingcommand status.We are working on NT4.0, SP6a (all fixes up to date, MDAC 2.7SP1) onIIS side, an equal box for MTS (same patches and updates) and a SQLServer 7 (on NT4, same fixes ans SPs) database on another box.Is this normal? Those sleeping processes are blocking other apps andeverything gets slow and messy....the only solution is to kill thoseblocking processes.Thanks!

View 1 Replies View Related

Running SSIS From Command Line W/ SQL Agent

Apr 17, 2007

Hi Everyone!



I'm trying to run have SQL Server Agent excute an SSIS package from the command line and I keep recieving an error message. I will assume that I have miss typed something. Can someone validate that the execute line looks workable?



"C:Program Files (x86)Microsoft SQL Server90DTSBinndtexec.exe" /F "F:ProjectsSSISCustomerMaster_1CustomerMaster_1Package.dtsx" /CONNECTION "APLUS70F70.AKIN";""uid=AKIN;Dsn=APLUS70F70;"" /CONNECTION "CRMPSQL.IBT_Aplus";""Data Source=CRMPSQL;Initial Catalog=IBT_Aplus;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;"" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING EW



Thanks in advance!



Anthony Akin



View 10 Replies View Related

SQL Server 2012 :: Spool Backup Command Result To A Text File

Jun 9, 2015

I am running backups on SQL Sever express and I take backups via the batch file executing the TSQL as below. This works perfectly fine, I just need to be able to spool out the backup completion log. What TSQL command can I use to do that?

My batch file looks like this:

@echo off
sqlcmd -S SERVER01 -E -i H:master_scriptsTOM_FAM_log.sql

Which will the call the TOM_FAM_log.sql :

DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
SET @path = 'H:BackupTOM_FAM'

[Code] ....

Usually if we schedule the backups using the maintenance plan, we can chose reporting options that can spool the result of the backup to a text file. What is the T-SQL for the spool report to a text file.

This option produces a file that writes logs with the details I posted below. I would like to do the same or similar using T-SQL in my code.

Microsoft(R) Server Maintenance Utility (Unicode) Version 11.0.3000
Report was generated on "SERVER01".
Maintenance Plan: Backup logs
Duration: 00:00:00
Status: Succeeded.

[Code] ....

View 1 Replies View Related

Output File (.txt) Running Package From SQL Server Agent

Mar 19, 2008



Hello,
I have created a package that runs without problem.
I run the package with the command dtexec /F "package_name.dtsx" > package_name.txt.

Then I run the same package from SQL Server Agent, everything is OK

Then, I tried to edit the command line to have the output file, but I got an error.

The command line is:
dtexec /F "package_name.dtsx" MAXCONCURRENT "-1" / CHECKPOINTING OFF /REPORTING E > package_name.txt.
(MAXCONCURRENT "-1" / CHECKPOINTING OFF /REPORTING E are created by default)

How can I do?

Thank

View 4 Replies View Related

How To Write Command For Insert Data With Running Number

Jan 11, 2008

My table has a running number primary key. I want to insert data to this table and automatically generate running number pk. I try to write SQL command like this.
SELECT MAX(ID) AS MaxId from test
INSERT INTO test (ID, data1, data2, data3) VALUES (MaxId+1, @data1, @data2, @data3)
but it fails. How should I do? Thank you in advance

View 1 Replies View Related

Start A Job Task From The Command Line & Check To See If It&#39;s Running

Apr 22, 2000

I need to start a job task from the command line. Does anyone know of the correct command(s) to do this?

I also need to check to see if a specific job task is currently executing from the command line. Does anyone know of the correct command(s) to do this?

Thanks for any assistance.

Jim

View 4 Replies View Related

Running DBCC CHECKIDENT Command Within Stored Proc?

Jun 17, 2015

For reasons beyond the scope of my question, is there a way to run this command within a Stored Procedure from a low privileged user login? I can grant the entity "db_ddladmin" privilege and the proc runs, but I'd rather not give out that level of permission to what is basically a glorified web access login.

View 5 Replies View Related

Errors While Running Ssis Packages From The Command Prompt.

Dec 23, 2005

I have created ssis package. It has been successfully running at UI level.

But when i am trying to execute it from the command prompt by using dtexec utility it is showing the following error messages.

Error: 2005-12-23 17:01:57.67
   Code: 0xC00470FE
   Source: Data Flow Task DTS.Pipeline
   Description: The product level is insufficient for component "Flat File Source" (1).
End Error
Error: 2005-12-23 17:01:57.67
   Code: 0xC00470FE
   Source: Data Flow Task DTS.Pipeline
   Description: The product level is insufficient for component "Script Component" (9).
End Error


i have entered the command as follows.

dtexec /f "c:somefolderpackage1.dtsx"

 

Any points regarding this issue would be helpful.

 

View 7 Replies View Related

SQL Server 2008 :: Running WinSCP In SSIS Task / Bat File

Apr 29, 2015

I'm trying to call WinSCP in a SSIS Execute Process Task using a .bat file to automate. SSIS is returning a generic failure error message ("Error: 0xC0029151 at Execute Process Task, Execute Process Task: In Executing "MyServerC$Program Files (x86)WinSCPWinSCP.exe" "-script=MyNASShareWinSCPFTP.bat " at "", The process exit code was "1" while the expected was "0"."). So now I'm trying to run the .bat file by itself. Unfortunately, the command prompt rushes by so fast that I can't see what the server is doing.

I can't find anything on the WinSCP site that indicates how to slow down the .bat file processing or log the remote server responses. I do see how to use the /log switch when using the interactive command line console, but that's not what I want to do.

View 9 Replies View Related







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