Click here to Skip to main content
15,900,446 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
SQL
USE [customcontrolsetting]
GO
/****** Object:  StoredProcedure [dbo].[sp_all_task]    Script Date: 10/10/2013 12:50:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_all_task] 

	@table_name nvarchar(max),
    @taction nvarchar(max),
    @tcolumn nvarchar(max),
    @tvalues nvarchar(max),
    @tconditions nvarchar(max)

	
AS
BEGIN
SET NOCOUNT ON;

DECLARE @cmd AS NVARCHAR(max)
 
if(@taction = 'insert')

SET @cmd='insert into '+@table_name+' ('+@tcolumn+') values('+@tvalues+') '
EXEC sp_all_task @cmd 

END



this is my query in store procedure ...


EXEC [sp_all_task] @table_name='AA',@taction='insert', @tcolumn='CC',@tvalues='DD',@tconditions='EE'

when i execute this folowing error is occured

error

ASM
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 201, Level 16, State 4, Procedure sp_all_task, Line 0
Procedure or function 'sp_all_task' expects parameter '@taction', which was not supplied.
Msg 217, Level 16, State 1, Procedure sp_all_task, Line 20
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).
Posted
Updated 9-Oct-13 23:39pm
v2

EXEC sp_all_task 'c','d','e','f','b'
 
Share this answer
 
Try
SQL
EXEC [sp_all_task] 'AA','insert','CC','DD','EE'
Also, just write
SQL
EXECUTE (@cmd)
instead of
SQL
EXEC sp_all_task @cmd
in your SP.
 
Share this answer
 
v2
Comments
MAYANK GEETE 10-Oct-13 7:51am    
THANKS ZAFAR ..IT'S WORKING THANK YOU THANK YOU SO MUCH
Zafar Sultan 10-Oct-13 8:11am    
Welcome.
Changed your string to
SQL
SET @cmd='insert into '+@table_name+' ('+@tcolumn+') values('+Char(39)+@tvalues+Char(39)+')'
And
Just write
SQL
EXEC @cmd
for executing string.
Here Char(39) is ASCII value for single quote.
 
Share this answer
 
v2
Use the
EXECUTE (@cmd)


instead of
EXEC sp_all_task @cmd
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900