Variable

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?
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.
0
Soumi ChakrabortyAuthor Commented:
i am learning sql
0
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??

E.g.
USE tempdb;
GO

DECLARE @Test INT = 1;
SELECT @Test;
GO

SELECT @Test;
GO

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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?
0
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
0

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.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Why did you accept my comment?
I didn't even answered your questions.
0
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.

Question has a verified solution.

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.