PyCharm's database console does not “remember” previously declared variables
已回答
Suppose I want to execute the following SQL statements in PyCharm's database console:
DECLARE @today DATETIME = GETDATE()
SELECT @today
When I execute the two statements in one go (selecting both of them, then hitting ctrl+Enter), it works as expected.
But if I execute the first statement, and then the second one separately, I get the error Must declare the scalar variable "@today".
Is there a way to make the console keep variables in scope for more than one statement?
请先登录再写评论。
It's expected behavior. AFAIK, SSMS works in the same way. You need to execute all statements at once.