How to give table name dynamically in stored procedure in SQL Server 2012
<p>I am creating two tables that have some rows and columns. And I created a stored procedure which dynamically takes table name and produce the result.</p>

<p>But when I pas the table name dynamically, then it not work.</p>

<pre><code>CREATE PROC spGetAll (@tableName varchar(50))
AS
BEGIN
    SELECT
        *
    FROM @tableName
END
</code></pre>

<p><a href="https://i.stack.imgur.com/fGWID.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fGWID.png" alt="enter image description here"></a></p>