I have to truncate the table but getting error
Must declare the scalar variable "@Table".
Code:
DECLARE @Table VARCHAR(20) = 'ABC'
AS
BEGIN
EXEC ('TRUNCATE TABLE abcDB.dbo.'+@Table) AT [Server]
END
Declare the varaible After AS keyword.
BEGIN
DECLARE @Table VARCHAR(20) = 'ABC'
EXEC ('TRUNCATE TABLE abcDB.dbo.'+@Table) AT [Server]
END
Check if u have any constraints(Foreign key). If exists drop it
DECLARE @Table VARCHAR(20) = 'ABC'
BEGIN
EXEC ('TRUNCATE TABLE abcDB.dbo.'+@Table)
END
ASdoing there?