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

New-DbaDbTable creates wrong datatype if no MaxLength specified #9198

Closed
btripz opened this issue Jan 5, 2024 · 0 comments · Fixed by #9314
Closed

New-DbaDbTable creates wrong datatype if no MaxLength specified #9198

btripz opened this issue Jan 5, 2024 · 0 comments · Fixed by #9314
Assignees

Comments

@btripz
Copy link

btripz commented Jan 5, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

N/A

Steps to Reproduce

Import-Module DbaTools

$instance = 'MyInstance'
$database = 'MyDatabase'
$server = Connect-DbaInstance -SqlInstance $instance -Database $database -TrustServerCertificate

$tableName = 'BobTest'

$tabColumns = @()
$tabColumns += @{Name = 'Cola'; Type = 'nvarchar'; Nullable = $true; Default = 'Hello'; DefaultName = 'DF_Name_test5'}

Remove-DbaDbTable -SqlInstance $server -Database $database -Table $tableName -Confirm:$false
New-DbaDbTable -SqlInstance $server -Database $database -Name $tableName -ColumnMap $tabColumns

Please confirm that you are running the most recent version of dbatools

2.1.5

Other details or mentions

If I sepecify a MaxLength then a NVarchar column is created with the specified MaxLength.

if no MaxLength is specified then a varchar(max) column is created.

What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.14393.6343
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.6343
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2016 (SP3-GDR) (KB5029186) - 13.0.6435.1 (X64)
Jul 30 2023 19:53:42
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)

.NET Framework Version

PSChildName Version


v2.0.50727 2.0.50727.4927
v3.0 3.0.30729.4926
Windows Communication Foundation 3.0.4506.4926
Windows Presentation Foundation 3.0.6920.4902
v3.5 3.5.30729.4926
Client 4.8.03761
Full 4.8.03761
Client 4.0.0.0

@btripz btripz added bugs life triage required New issue that has not been reviewed by maintainers labels Jan 5, 2024
@andreasjordan andreasjordan self-assigned this Mar 31, 2024
@andreasjordan andreasjordan removed the triage required New issue that has not been reviewed by maintainers label Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants