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: sp_helpme: nvarchar columns are listed twice in the column-resultset #200

Closed
ChrMaa opened this issue Jun 10, 2021 · 3 comments · Fixed by #201
Closed

BUG: sp_helpme: nvarchar columns are listed twice in the column-resultset #200

ChrMaa opened this issue Jun 10, 2021 · 3 comments · Fixed by #201
Assignees
Labels
bug Something isn't working

Comments

@ChrMaa
Copy link

ChrMaa commented Jun 10, 2021

/*
BUG: sp_helpme: nvarchar columns are listed twice in the column-resultset

Execute the code. you will see 3 rows in the column-resultset where only 2 rows should be

Microsoft SQL Server 2019 (RTM-CU10) (KB5001090) - 15.0.4123.1 (X64) Mar 22 2021 18:10:24
Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 (Build 19043: ) (Hypervisor)
*/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestTable]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TestTable](
[nv] nvarchar NULL,
[v] varchar NULL
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'Description' , N'SCHEMA',N'dbo', N'TABLE',N'TestTable', N'COLUMN',N'nv'))
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Desc1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'TestTable', @level2type=N'COLUMN',@level2name=N'nv'
GO

IF NOT EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'Description' , N'SCHEMA',N'dbo', N'TABLE',N'TestTable', N'COLUMN',N'v'))
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Desc2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'TestTable', @level2type=N'COLUMN',@level2name=N'v'
GO

EXEC sp_helpme 'dbo.TestTable'

@lowlydba lowlydba self-assigned this Jun 10, 2021
@lowlydba
Copy link
Owner

Thanks for the bug submission! Looks like an easy fix, will have a development branch ready for you to validate soon.

@lowlydba lowlydba added the bug Something isn't working label Jun 10, 2021
@lowlydba lowlydba linked a pull request Jun 10, 2021 that will close this issue
7 tasks
@ChrMaa
Copy link
Author

ChrMaa commented Jun 10, 2021

the duplicated row ist eliminated. But the value of the Length-Column ist twice the real size of the column.
in my opinion the values in TrimTrailingBlanks and FixedLenNullInSource must be the same.
use sp_helpme 'dbo.TestTable' to get the new problems visible.
Thanks for your help

@lowlydba
Copy link
Owner

Glad its working!

But the value of the Length-Column ist twice the real size of the column.

If you are referring to it showing 2 as the Length for the NVARCHAR column in your example, that is because it is returning the length in bytes. For NVARCHAR, each character is 2 bytes. This is consistent with how the original sp_help works. The intention behind sp_helpme is to augment the data output, but not modify the original functionality.

in my opinion the values in TrimTrailingBlanks and FixedLenNullInSource must be the same.

Same as above, these two columns are exact copies of sp_help's logic. The documentation specifies FixedLenNullInSource is for backwards compatibility only, so I would not recommend using it.

If you encounter any more 🐛 , feel free to open new issues for them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants