create proc NewTable @TabName nvarchar(20),@Flag bit,@SID int,@Name varchar(20)
as
begin
if @Flag=1
begin
IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = @TabName))
BEGIN
print 'hi'
END
else
begin
declare @str varchar(max)
set @str='create table @TabName (Sid int,Name varchar(20))'
select @str=replace(@str,'@TabName',@TabName)
exec(@str)
print 'Table not found'
END
end
end
I hope it's working well and helping to you........:-)