 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
UDT support? |
|
Does SQL Assistant support user-defined data types for SQL Server?
|
|
Mon May 10, 2010 9:48 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
If you mean keyword prompts, no it doesn't. Keyword prompts are based on SQL Reference.
AFAIK, data exporting and scripting function does support custom data types. Unit Tests framework supports them too. I'm not sure about test data generator.
|
|
Mon May 10, 2010 10:02 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Any hints on how to modify DB Queries to show UDT info (system type for the user defined type) when hovering mouse cursor over a table column?
|
|
Tue Sep 04, 2012 5:38 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
If I get that correctly, it comes from Colums + Keys query
|
|
Tue Sep 04, 2012 6:10 pm |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Yes, that was it, thank you very much! I modified it so the popup now shows some other info I find relevant. In case anyone's interested, here's the code for Columns (MSSQL) + Keys. UAYOR, of course ;)
 |
 |
if @@version like 'Microsoft SQL Server 2005%'
or @@version like 'Microsoft SQL Server 2008%'
or @@version like '%SQL Server 2012%'
or @@version like '%Denali%'
select
c.name,
case when t.system_type_id = t.user_type_id then type_name(c.system_type_id)
else SCHEMA_NAME(t.[schema_id]) + '.' + type_name(c.user_type_id) + ' - ' + type_name(c.system_type_id)
end
+ case
when type_name(c.system_type_id) in ('varchar', 'char', 'binary', 'varbinary')
then '(' + case c.max_length when -1 then 'max' else convert(varchar, c.max_length) end + ')'
when type_name(t.system_type_id) in ('nvarchar', 'nchar')
then '(' + case c.max_length when -1 then 'max' else convert(varchar, c.max_length / 2) end + ')'
when type_name(t.system_type_id) in ('decimal', 'numeric')
then '(' + convert(varchar, c.[precision]) + ',' + convert(varchar, c.scale) + ')'
else ''
end,
case /* Y,N,A,D,L */
when c.is_identity = 1 then 'A'
when t.name='timestamp' then 'D'
when c.is_computed = 1 then case when c.is_nullable = 1 then 'L' else 'D' end
when c.is_nullable = 1 then 'Y' else 'N'
end
+ CASE /* P,F,U */
WHEN EXISTS(
SELECT NULL
FROM [$DB_NAME$].sys.indexes i, [$DB_NAME$].sys.index_columns k
WHERE i.[object_id] = k.[object_id] AND i.index_id = k.index_id
AND k.[object_id] = c.[object_id] AND k.column_id = c.column_id AND i.is_primary_key <> 0
) THEN 'P'
WHEN EXISTS(
SELECT NULL FROM [$DB_NAME$].sys.foreign_key_columns f
WHERE f.parent_object_id = c.[object_id] AND f.parent_column_id = c.column_id
) THEN 'F'
WHEN EXISTS(
SELECT NULL
FROM [$DB_NAME$].sys.indexes i, [$DB_NAME$].sys.index_columns k
WHERE i.[object_id] = k.[object_id] AND i.index_id = k.index_id
AND k.[object_id] = c.[object_id] AND k.column_id = c.column_id AND i.is_unique_constraint <> 0
) THEN 'U'
ELSE ' '
END
+ CASE
WHEN EXISTS(
SELECT NULL
FROM [$DB_NAME$].sys.indexes i, [$DB_NAME$].sys.index_columns k
WHERE i.[object_id] = k.[object_id] AND i.index_id = k.index_id
AND k.[object_id] = c.[object_id] AND k.column_id = c.column_id
AND i.is_primary_key = 0 AND i.is_unique_constraint = 0
) THEN 'I'
ELSE ''
END
from
[$DB_NAME$].sys.all_columns c
join [$DB_NAME$].sys.types t
on c.user_type_id = t.user_type_id
where
c.object_id = :OBJECT_ID
order by
c.column_id
else
select
c.name,
case when t.xtype = t.xusertype then type_name(c.xtype)
else type_name(c.xusertype) + ' - ' + type_name(c.xtype)
end
+ case
when type_name(c.xtype) in ('varchar', 'char', 'binary', 'varbinary')
then '(' + case c.length when -1 then 'max' else convert(varchar, c.length) end + ')'
when type_name(t.xtype) in ('nvarchar', 'nchar')
then '(' + case c.length when -1 then 'max' else convert(varchar, c.length / 2) end + ')'
when type_name(t.xtype) in ('decimal', 'numeric')
then '(' + convert(varchar, c.prec) + ',' + convert(varchar, c.scale) + ')'
else ''
end,
case /* Y,N,A */
when c.autoval is not null then 'A'
when t.name = 'timestamp' then 'D'
when c.isnullable = 1 then 'Y' else 'N'
end
+ CASE /* P,F,U */
WHEN EXISTS(
SELECT NULL
FROM [$DB_NAME$].dbo.sysindexes i, [$DB_NAME$].dbo.sysindexkeys k
WHERE i.id = k.id AND i.indid = k.indid
AND k.id = c.id AND k.colid = c.colid AND i.status & 0x800 <> 0
AND i.indid BETWEEN 1 AND 254
) THEN 'P'
WHEN EXISTS(
SELECT NULL FROM [$DB_NAME$].dbo.sysforeignkeys f WHERE f.fkeyid = c.id AND f.fkey = c.colid
) THEN 'F'
WHEN EXISTS(
SELECT NULL
FROM [$DB_NAME$].dbo.sysindexes i, [$DB_NAME$].dbo.sysindexkeys k
WHERE i.id = k.id AND i.indid = k.indid
AND k.id = c.id AND k.colid = c.colid AND i.status & 0x1000 <> 0
AND i.indid BETWEEN 1 AND 254
) THEN 'U'
ELSE ' '
END
+ CASE
WHEN EXISTS(
SELECT NULL
FROM [$DB_NAME$].dbo.sysindexes i, [$DB_NAME$].dbo.sysindexkeys k
WHERE i.id = k.id AND i.indid = k.indid
AND k.id = c.id AND k.colid = c.colid AND i.status & 0x1860 = 0
AND i.indid BETWEEN 1 AND 254
) THEN 'I'
ELSE ''
END
from
[$DB_NAME$].dbo.syscolumns c
join [$DB_NAME$].dbo.systypes t
on c.xtype = t.xtype
and c.xusertype = t.xusertype
where
c.id = :OBJECT_ID
and c.number = 0
order by
c.colid
|
|
|
Wed Sep 05, 2012 5:19 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Thank you. Outstanding.
I think that bit of new functionality should be good for everybody. I hope it's ok with you if I submit your changes as a new enhancement request.
|
|
Wed Sep 05, 2012 9:12 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Sure, I'd be honored. But I suggest you do some thorough syntax/semantic check on that thing, I didn't have time to do that myself :( I threw it together in haste and had to edit my post several times as different problems started to emerge. Besides looking very ugly with those mixed case keywords and bad formatting there might be some other imps hiding there.
|
|
Wed Sep 05, 2012 9:33 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Thank you. We will sure do that.
|
|
Wed Sep 05, 2012 11:08 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|