Firs, you are reposting your question. The solution to one of your problem is
Here[
^]. You should improve your question if there is additional doubt or clarification. Second, the flow of your stored procedure should go like this:
Alter procedure VisitorDetails1
@p_name nvarchar(50),
@p_City nvarchar(100),
@p_Dept nvarchar(max),
@p_TableName nvarchar(50)
as
BEGIN
IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=@p_TableName))
BEGIN
Declare @set nvarchar(500)
set @set='insert into '+@TableName+'(Name,City,Dept) values(''' + @name + ''',''' + @City + ''',''' + @Dept + ''')'
Print 'Success'
END
else
BEGIN
Print 'Table is Not there'
END
END