473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem running stored procedure inside another store procedure

hi,

I want to use a stored procedure inside a stored procedure simulteanously changing the database.
this is my base store procedure

alter PROCEDURE create_file @dbname sysname
AS
declare @fname varchar(30)
declare @fsizes nvarchar
BEGIN
DECLARE @cmd varchar(1000)
set @cmd = 'osql -E -d ' + @dbname + ' -Q "exec ret_sizes @fname OUTPUT,@fsizes OUTPUT"'
exec master..xp_cmdshell @cmd
END


if i execute the his "exec create_file ertis"
i get error as

Msg 137, Level 15, State 2, Server HCC-BPVHD1, Line 1
Must declare the variable '@fname'.
NULL


the procedure called inside the mail procedure is

alter procedure ret_sizes
@fname varchar(30) OUTPUT,
@fsizes nvarchar OUTPUT
as
begin
select @fname=name, @fsizes=size from sysfiles
order by fileid
end


Please help me
Sep 16 '06 #1
1 7843
The @Cmd string doesn't seem to include the second exec.

set @cmd = 'osql -E -d ' + @dbname + ' + '-Q' + ' "exec ret_sizes @fname OUTPUT,@fsizes OUTPUT"' '

exec @CMD




__________________________________________________ ___________
hi,

I want to use a stored procedure inside a stored procedure simulteanously changing the database.
this is my base store procedure

alter PROCEDURE create_file @dbname sysname
AS
declare @fname varchar(30)
declare @fsizes nvarchar
BEGIN
DECLARE @cmd varchar(1000)
set @cmd = 'osql -E -d ' + @dbname + ' -Q "exec ret_sizes @fname OUTPUT,@fsizes OUTPUT"'
exec master..xp_cmdshell @cmd
END


if i execute the his "exec create_file ertis"
i get error as

Msg 137, Level 15, State 2, Server HCC-BPVHD1, Line 1
Must declare the variable '@fname'.
NULL


the procedure called inside the mail procedure is

alter procedure ret_sizes
@fname varchar(30) OUTPUT,
@fsizes nvarchar OUTPUT
as
begin
select @fname=name, @fsizes=size from sysfiles
order by fileid
end


Please help me
Sep 18 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection...
5
by: Timppa | last post by:
Hi, Could anyone help me with my problem ? Environment: Access 2000 and Sql Server 2000. I have a stored procedure as follows: DROP table1 SELECT alias1.field1,alias2.field2,table2.field6...
4
by: Mullin Yu | last post by:
i have a stored procedure at sql server 2k. which will update records and select result from temp table. if i use SqlConnection class, and i do both. but, if i use OleDbConnection class, i can...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
0
by: eRTIS SQL | last post by:
hi, I want to use a stored procedure inside a stored procedure simulteanously changing the database. this is my base store procedure alter PROCEDURE create_file @dbname sysname AS declare...
4
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine...
9
by: jyothi1105 | last post by:
Hi all, Here is some information which could help people who want to create stored procedures and execute them in their program. You can create stored procedures in two ways: Through front end...
2
by: acw | last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that accesses couple tables and runs the extended stored procedure xp..cmdshell. The goal is to grant users with limited privileges...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.