I) What happens to a declared variable after the GO statement?
1)The Variable will be displayed
2)The Variable is removed from memory
3)The Variable is added to memory
4)The Variable is officially declared
5)It does nothing to the variable

II)What is the scope of the variable?
1)Current Session
2)As long as SQL Server is open
3)Network Packets
4)As long as you want
5)Executing Batch

Please need help
Soumi ChakrabortyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee SavidgeCommented:
This, and your other questions sound like exam/test questions.
Soumi ChakrabortyAuthor Commented:
i am learning sql
ste5anSenior DeveloperCommented:
There is some context missing:

GO is not part of T-SQL. It's the batch terminator used by SSMS .

So the answer is: After a GO you're in a new batch. Thus: different scope.

And as you said you're learning T-SQL. Why don't you test it??

USE tempdb;

DECLARE @Test INT = 1;


Open in new window

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Yes, testing is the best thing to do while learning.
We can give you the fish or teach you how to fish. What's your choice?
Mayank GairolaSr. Application Support Engg.Commented:
I) What happens to a declared variable after the GO statement
Answer - The Variable is removed from memory

II)What is the scope of the variable?
Answer - Executing Batch

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Soumi ChakrabortyAuthor Commented:
Please teach me how to fish.
Vitor MontalvãoMSSQL Senior EngineerCommented:
Why did you accept my comment?
I didn't even answered your questions.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.