MSSQL Default Values Not Being Interpreted In Table View Correct

[expired user #8458]'s profile image [expired user #8458] posted 9 years ago in General Permalink
I'm assuming that this isn't implemented at the moment or doesn't escape special characters?

When a default value of ('N/A') is specified for fields
HeidiSQL interprets it as 'N', the /A is missing.
ansgar's profile image ansgar posted 9 years ago Permalink
Can I get some CREATE TABLE code here to reproduce that?
[expired user #8458]'s profile image [expired user #8458] posted 9 years ago Permalink
The SQL CREATE table code is correct with HeidiSQL. I've tried exporting with several other programs and all produce the same result.

However, tt's the Design Table View in HeidiSQL that shows this and clips the string for editing.

See screenshot http://www.imagesup.net/?di=12141494071216

DROP TABLE [Workshops]
GO
CREATE TABLE [Workshops] (
[ID] int NOT NULL IDENTITY(1,1) ,
[WORKSHOP] varchar(255) NOT NULL ,
[WORKSHOPINFO] varchar(2048) NULL DEFAULT ('N/A')
)

[expired user #8458]'s profile image [expired user #8458] posted 9 years ago Permalink
Here's a better screenshot including the HeidiSQL column names http://www.imagesup.net/?di=814149414042
Code modification/commit from ansgar.becker, 9 years ago, revision 8.3.0.4857
Fix detection of DEFAULT value in CREATE TABLE code of MS SQL tables, which is wrapped in parentheses. See http://www.heidisql.com/forum.php?t=16748
ansgar's profile image ansgar posted 9 years ago Permalink
Fixed in r4857.

Problem was that MS SQL wraps the value in COLUMN_DEFAULT in parentheses, and HeidiSQL expected a single quote as the first character:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='dbo' AND TABLE_NAME='Workshops';

TABLE_CATALOG|TABLE_SCHEMA|TABLE_NAME|COLUMN_NAME|ORDINAL_POSITION|COLUMN_DEFAULT|IS_NULLABLE|DATA_TYPE|CHARACTER_MAXIMUM_LENGTH|CHARACTER_OCTET_LENGTH|NUMERIC_PRECISION|NUMERIC_PRECISION_RADIX|NUMERIC_SCALE|DATETIME_PRECISION|CHARACTER_SET_CATALOG|CHARACTER_SET_SCHEMA|CHARACTER_SET_NAME|COLLATION_CATALOG|COLLATION_SCHEMA|COLLATION_NAME|DOMAIN_CATALOG|DOMAIN_SCHEMA|DOMAIN_NAME
anse|dbo|Workshops|ID|1||NO|int|||10|10|0||||||||||
anse|dbo|Workshops|WORKSHOP|2||NO|varchar|255|255|||||||iso_1|||Latin1_General_CI_AS|||
anse|dbo|Workshops|WORKSHOPINFO|3|('N/A')|YES|varchar|2048|2048|||||||iso_1|||Latin1_General_CI_AS|||
[expired user #8458]'s profile image [expired user #8458] posted 9 years ago Permalink
Excellent!

Please login to leave a reply, or register at first.