Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Wednesday, March 28, 2012

how to save result of sql query to .csv file "using command in sql query itself"

Hello there

I m new in sql..i want to know wether above said task is possible in sql?

if yes then what is exact format of sql query command..

Thanks

AVD

YOu can have a look in the BOL for OPENDATASOURCE, there should a sample for an output to a propetary format.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

Monday, March 26, 2012

How to run windows DOS command in SQL?

I want to check to see if any error files from SQL uploads are present in a
folder.
I want to run IF EXISTS *.err then run EXEC xp_sendmail stored procedure
How can I check a windows directory for *.err files in SQL syntax? osql?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums.aspx/sql-server/200611/1
There is an 'undocumented' function that will do that for you
[xp_fileexist]. See this article:
Functions -UnDocumented Check to Verify File Existence
http://www.sqlservercentral.com/columnists/bknight/xpfileexist.asp
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"jsheldon via droptable.com" <u2880@.uwe> wrote in message
news:6909a192e8dbf@.uwe...
>I want to check to see if any error files from SQL uploads are present in a
> folder.
> I want to run IF EXISTS *.err then run EXEC xp_sendmail stored procedure
>
> How can I check a windows directory for *.err files in SQL syntax? osql?
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forums.aspx/sql-server/200611/1
>
sql

How to run windows DOS command in SQL?

I want to check to see if any error files from SQL uploads are present in a
folder.
I want to run IF EXISTS *.err then run EXEC xp_sendmail stored procedure
How can I check a windows directory for *.err files in SQL syntax? osql?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200611/1There is an 'undocumented' function that will do that for you
[xp_fileexist]. See this article:
Functions -UnDocumented Check to Verify File Existence
http://www.sqlservercentral.com/col...xpfileexist.asp
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"jsheldon via droptable.com" <u2880@.uwe> wrote in message
news:6909a192e8dbf@.uwe...
>I want to check to see if any error files from SQL uploads are present in a
> folder.
> I want to run IF EXISTS *.err then run EXEC xp_sendmail stored procedure
>
> How can I check a windows directory for *.err files in SQL syntax? osql?
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200611/1
>

How to run windows DOS command in SQL?

I want to check to see if any error files from SQL uploads are present in a
folder.
I want to run IF EXISTS *.err then run EXEC xp_sendmail stored procedure
How can I check a windows directory for *.err files in SQL syntax? osql?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200611/1There is an 'undocumented' function that will do that for you
[xp_fileexist]. See this article:
Functions -UnDocumented Check to Verify File Existence
http://www.sqlservercentral.com/columnists/bknight/xpfileexist.asp
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"jsheldon via SQLMonster.com" <u2880@.uwe> wrote in message
news:6909a192e8dbf@.uwe...
>I want to check to see if any error files from SQL uploads are present in a
> folder.
> I want to run IF EXISTS *.err then run EXEC xp_sendmail stored procedure
>
> How can I check a windows directory for *.err files in SQL syntax? osql?
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200611/1
>

Friday, March 23, 2012

How to run SSIS package through the command line?

Dear member,

Does any body know how to run SSIS package through the command line?

Thanks

Shamen

You can use DTEXEC from the command line to run packages.|||

Thanks Jwelch...I will try....

Wednesday, March 21, 2012

How to run an agent job in low priority

Hi Sql server experts,
Is there a way that I can tell the agent to run a job in the lowest
priority(resource wise)? like Unix NICE command.
I need to solve this problem we are having ASAP. I appreciate any prompt
response.
Thanks in advance!
Pingx
Not really. There is a feature in the next version of SQL Server called the
Resource Governor that will do this but not currently.
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Pingx" <Pingx@.discussions.microsoft.com> wrote in message
news:309207E0-7B8A-4439-A2C1-4A244A9778D6@.microsoft.com...
> Hi Sql server experts,
> Is there a way that I can tell the agent to run a job in the lowest
> priority(resource wise)? like Unix NICE command.
> I need to solve this problem we are having ASAP. I appreciate any prompt
> response.
> Thanks in advance!
> Pingx
>
|||Andrew, thanks for your help.
Pingx
"Andrew J. Kelly" wrote:

> Not really. There is a feature in the next version of SQL Server called the
> Resource Governor that will do this but not currently.
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "Pingx" <Pingx@.discussions.microsoft.com> wrote in message
> news:309207E0-7B8A-4439-A2C1-4A244A9778D6@.microsoft.com...
>
|||"Pingx" <Pingx@.discussions.microsoft.com> wrote in message
news:14131D4A-9D05-4067-AEF8-3661133F8727@.microsoft.com...
> Andrew, thanks for your help.
>
What's your underlying problem and ultiamte problem?
There may be other solutions we can propose.
[vbcol=seagreen]
> Pingx
> "Andrew J. Kelly" wrote:
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
sql

How to run an Access file from a SQL job?

I have an Access file that I'm using to move some data around. I want to run it from a SQL job. How do I do that? The Access file runs a command using AutoExec, so it doesn't have any interaction or anything. It just runs and closes itself. Thanks.

pse don't duplicate.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1947186&SiteID=1

Madhu

How to run Access file from SQL job?

I have an Access file that I'm using to move some data around. I want to run it from a SQL job. How do I do that? The Access file runs a command using AutoExec, so it doesn't have any interaction or anything. It just runs and closes itself. Thanks.

use XP_cmdshell

Executes a given command string as an operating-system command shell and returns any output as rows of text. Grants nonadministrative users permissions to execute xp_cmdshell.

check in BOL. IF its sql server 2005 you have to enable it using SQL Server 2005 features.

Madhu

Friday, February 24, 2012

how to retrieve a row by specifying row number

Hi,
Is there any sql command to retrieve a particular row by specifying its
row number."supriya" <santu@.hotmail.com> wrote in message
news:OriSXyJTGHA.5156@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Is there any sql command to retrieve a particular row by specifying its
> row number.
Oh I can't wait for the replies to this one :-)

>|||hi
you can use this type of Query
This Query is from Pubs DB
SELECT emp_id, lname, fname, job_id, (SELECT COUNT(*) FROM employee e2
WHERE e2.lname <= e.lname AND e2.job_id = 10) AS rownumber
FROM employee e
WHERE job_id = 10
ORDER BY lname
Hope this helps you
Regards
Shrinivas|||Hi
What vesrion are you using?
SQL Server 2005
CREATE TABLE SpeakerStats
(
speaker VARCHAR(10) NOT NULL PRIMARY KEY,
track VARCHAR(10) NOT NULL,
score INT NOT NULL,
pctfilledevals INT NOT NULL,
numsessions INT NOT NULL
)
SET NOCOUNT ON
INSERT INTO SpeakerStats VALUES('Dan', 'Sys', 3, 22, 4)
INSERT INTO SpeakerStats VALUES('Ron', 'Dev', 9, 30, 3)
INSERT INTO SpeakerStats VALUES('Kathy', 'Sys', 8, 27, 2)
INSERT INTO SpeakerStats VALUES('Suzanne', 'DB', 9, 30, 3)
INSERT INTO SpeakerStats VALUES('Joe', 'Dev', 6, 20, 2)
INSERT INTO SpeakerStats VALUES('Robert', 'Dev', 6, 28, 2)
INSERT INTO SpeakerStats VALUES('Mike', 'DB', 8, 20, 3)
INSERT INTO SpeakerStats VALUES('Michele', 'Sys', 8, 31, 4)
INSERT INTO SpeakerStats VALUES('Jessica', 'Dev', 9, 19, 1)
INSERT INTO SpeakerStats VALUES('Brian', 'Sys', 7, 22, 3)
INSERT INTO SpeakerStats VALUES('Kevin', 'DB', 7, 25, 4)
--1 (ROW_NUMBER())
SELECT ROW_NUMBER() OVER(ORDER BY score DESC) AS rownum,
speaker, track, score
FROM SpeakerStats
ORDER BY score DESC
--2
SELECT *
FROM (SELECT ROW_NUMBER() OVER(ORDER BY score DESC, speaker) AS rownum,
speaker, track, score
FROM SpeakerStats) AS D
WHERE rownum BETWEEN 4 AND 6
ORDER BY score DESC, speaker
--3
DECLARE @.pagenum AS INT, @.pagesize AS INT
SET @.pagenum = 2
SET @.pagesize = 3
SELECT *
FROM (SELECT ROW_NUMBER() OVER(ORDER BY score DESC, speaker) AS rownum,
speaker, track, score
FROM SpeakerStats) AS D
WHERE rownum BETWEEN (@.pagenum-1)*@.pagesize+1 AND @.pagenum*@.pagesize
ORDER BY score DESC, speaker
"supriya" <santu@.hotmail.com> wrote in message
news:OriSXyJTGHA.5156@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Is there any sql command to retrieve a particular row by specifying its
> row number.
>