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

Bug: SQL Server - Declaring Table variable results in weird behavior in scripts #121

Closed
akarnavasco opened this issue May 14, 2024 · 1 comment

Comments

@akarnavasco
Copy link

I get a weird behavior when declaring a Table variable in SqlServer Version 2022.

  1. Please check DbSchema Help / Output logs for errors.
    No errors reported in log.
    16:00:42 > runScript

  2. Please include the DbSchema version, operating system and used database

    DB Schema version:
    DbSchema 9.5.4 build 240504
    DbSchema Community Edition

    OS version:
    Ubuntu 22.04.4 LTS

    Database version:
    SqlServer Version 2022 Build version 16.0.4095.4

  3. The steps to reproduce this issue

    Run the following script (with auto-commit enabled)

    DECLARE @Columns100 TABLE (Name NVARCHAR(MAX));
    CREATE TABLE dummy33 (Name NVARCHAR(MAX));
    INSERT INTO dummy33 VALUES ('Value1'), ('Value2');
    SELECT * FROM dummy33;
    

    Expected Output:

    DECLARE @Columns100 TABLE (Name NVARCHAR(MAX));
    
    CREATE TABLE dummy33 (Name NVARCHAR(MAX));
    
    
    Modified -1 rows
    
    
    INSERT INTO dummy33 VALUES ('Value1'), ('Value2');
    
    
    Modified 2 rows
    
    
    SELECT * FROM dummy33;
    
    Name   
    ====== 
    Value1 
    Value2 
    
    
    Read 2 rows
    

    Actual Output:

    DECLARE @Columns100 TABLE (Name NVARCHAR(MAX));
    CREATE TABLE dummy33 (Name NVARCHAR(MAX));
    INSERT INTO dummy33 VALUES...
    
    
    Modified 2 rows
    

Notes

  1. Schema is not auto-refreshing after running above script.

  2. The table dummy33 table is created and populated as expected but it appears that the Select statement does not run.

  3. Same behavior happens when declaring a table variable, populating the table and then querying the table:

DECLARE @Columns100 TABLE (Name NVARCHAR(MAX));
INSERT INTO @Columns100 VALUES ('Value1'), ('Value2');
SELECT * FROM @Columns100;
  1. All above scripts run perfectly fine by the same user using SQL Server Management Studio as well as other db clients.
@wise-coders
Copy link
Owner

Please install the current beta:
https://dbschema.com/beta.php
The select statement seems to run. We have still to fix the schema auto-refresh, but we don't consider this as a priority issue.

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

No branches or pull requests

2 participants