Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

I have a table variable in a script (not a stored procedure). Two questions:

How do I drop the table variable? Drop-Table @varName gives an "Incorrect syntax" error.

Should I always do this? I hear it's a good practice. Is it ever really necessary for small scripts like this?

Here's my code:

Declare @projectList table(

    name varchar(40) NOT NULL);

Insert Into @projectList

Values ('BCR-00021')

Select *

From @projectList

Drop Table @projectList -- does not work

1 Answer

0 votes
by (40.4k points)

Table variables are automatically local and automatically dropped 

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories