Your technology certification is waiting. Enroll in Cloud Class ®
DECLARE @TblName VARCHAR(50)
SET @TblName = 'Test'
FROM dbo.Sysdepends AS A
INNER JOIN SysObjects AS B
ON A.depid = B.id
WHERE B.name = @TblName
Open in new window
Be seen. Boost your question’s priority for more expert views and faster solutions
DECLARE @Sp VARCHAR(50)
SET @Sp = 'Usp_Test'
SELECT DISTINCT OBJECT_NAME(depid) FROM Sysdepends WHERE id = OBJECT_ID(@Sp)
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%YourTableName%'
CREATE PROCEDURE [dbo].[spTest]
EXEC('SELECT * FROM ' + @TableName)
EXEC spTest 'TableA'
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.