Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automation of a query and output the query to a file

Status
Not open for further replies.

pavithra123

IS-IT--Management
Jun 17, 2001
54
0
0
CZ
Hi

to the GURUS of SQL server:

I want to achieve the following objective:

the SQL server ver is 7.0
Query the result of a SQL statement into a file and the filename should be unique ( i tried to use xp_cmdshell as suggested by terry.L.Broadbent)

Automate this option so that it happens at pre-defined time.

to accomplish this I am doing the following.

declare @t varchar(255)
declare @d varchar(30)
d=datetime()
select @t ='isql -Q &quot;select count(*) from <tablename>&quot; -E -o <path>'
exec <dbname>..xp_cmdshell @t

I get the following errors:
server msg2812 , level 16, state 62
could not find stored procedure 'xp_cmdshell'

I checked the stored procedures for the DB there was no extended stored procedure with the name 'xp_cmdshell'.

It does not allow me to create any extended stored procedure as it is greyed out in the DB i have created.

what needs to be done, any help would be greatly appreciated.

Best Regards
Prem.
 
You need to execute master.dbo.xp_cmdshell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top