Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAND() function using GO N produces the same result #1066

Closed
macdo5 opened this issue Mar 7, 2018 · 2 comments
Closed

RAND() function using GO N produces the same result #1066

macdo5 opened this issue Mar 7, 2018 · 2 comments
Assignees
Labels

Comments

@macdo5
Copy link

macdo5 commented Mar 7, 2018

Issue Type
Bug

Description
Executing batch script to produce random values using GO N doesn't change the seed.

  • MSSQL Extension Version: 1.3.0
  • VSCode Version: 1.20.1
  • OS Version: 10.0.16299 Build 16299

Steps to Reproduce:

  1. Open Visual Studio Code
  2. Connect to local SQL Server
  3. Execute T-SQL:
SELECT RAND() AS Randomvals;
GO 5
  1. Export results as JSON:
[
  {
    "Randomvals": "0.409168548858607"
  },
  {
    "Randomvals": "0.409168548858607"
  },
  {
    "Randomvals": "0.409168548858607"
  },
  {
    "Randomvals": "0.409168548858607"
  },
  {
    "Randomvals": "0.409168548858607"
  }
]
  1. Execute same T-SQL in SQL Server Management Studio 17.5 and export results as JSON:
[
  {
    "Randomvals": "0.914936876182325"
  },
  {
    "Randomvals": "0.0864878534629798"
  },
  {
    "Randomvals": "0.400794151918763"
  },
  {
    "Randomvals": "0.325317352563939"
  },
  {
    "Randomvals": "0.370678372074297"
  }
]

SSMS generates random values when using GO N, but mssql in VS Code produces the same value.

@kevcunnane kevcunnane self-assigned this Mar 7, 2018
@kevcunnane kevcunnane added the Bug label Mar 7, 2018
@kevcunnane
Copy link
Contributor

I can repro this. It looks like the handling of result sets when the batch is executed multiple times is wrong - it always returns the same resultset instead of handling a case where there are many of them. I will look to fix this given I added support for this feature.

@nishihere19
Copy link

Is the issue solved?
I am still getting same results from rand() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants