-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_viewer.sql
More file actions
39 lines (37 loc) · 1.04 KB
/
object_viewer.sql
File metadata and controls
39 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- show all objects tracked in CodeWrangler for the current database
select * from master.dbo.[codeWrangler] where [dbName] = db_name() ;
-- pick a random object
declare @id int = (select top 1 [oid] from master.dbo.[codeWrangler] where [dbName] = db_name() and [oid] <> 0 order by newid()) ;
-- and view the details for it...
select
[o].[id],
[o].[name],
[o].[xtype],
[|] = '|',
[c].[id],
[c].[name],
[c].[xtype],
[c].[xusertype],
[objText] =
case
when [s].[name] in ('char', 'nchar', 'varchar', 'nvarchar')
then [s].[name] + ' (' + Convert(varchar, [c].[length]) + ')'
when [s].[name] in ('decimal', 'numeric')
then [s].[name] + ' (' + Convert(varchar, [c].[prec]) + ', ' + Convert(varchar, [c].[scale]) + ')'
when [s].[name] in ('float')
then [s].[name] + ' (' + Convert(varchar, [c].[prec]) + ')'
else
[s].[name]
end
from
sysobjects o
inner join syscolumns [c]
on [o].[id] = [c].[id]
inner join systypes [s]
on [c].[xusertype] = [s].[xusertype]
where
[o].[id] = @id
order by
[o].[name] asc,
[c].[colid] asc ;
go