[SP]up_Desc
Posted In:
MSSQL
,
Stored Procedure
.
By 卡西卡
類似Oracle的desc指令
CREATE PROCEDURE up_desc (
@TABLE_NAME NVARCHAR(128) -- 資料表名稱
)AS
SELECT COLUMN_NAME,
CASE DATA_TYPE
WHEN 'char' THEN DATA_TYPE+'('+CONVERT(VARCHAR(10),CHARACTER_MAXIMUM_LENGTH)+')'
WHEN 'varchar' THEN DATA_TYPE+'('+CONVERT(VARCHAR(10),CHARACTER_MAXIMUM_LENGTH)+')'
WHEN 'nvarchar' THEN DATA_TYPE+'('+CONVERT(VARCHAR(10),CHARACTER_MAXIMUM_LENGTH)+')'
WHEN 'numeric' THEN DATA_TYPE+'('+CONVERT(VARCHAR(10),NUMERIC_PRECISION)+','+CONVERT(VARCHAR(10),NUMERIC_SCALE)+')'
ELSE DATA_TYPE END AS OBJECT_DATA_TYPE,
B.value as [OBJECT_DESCRIPTION]
FROM [INFORMATION_SCHEMA].[COLUMNS] A
LEFT JOIN ::fn_listextendedproperty ('MS_Description', 'user', 'dbo', 'TABLE', @TABLE_NAME, 'COLUMN', default) B ON A.COLUMN_NAME=B.objname
WHERE TABLE_NAME=@TABLE_NAME
ORDER BY A.ORDINAL_POSITION
5 Responses to [SP]up_Desc
Hello! I simply want to give a huge thumbs up for the nice info you’ve got here on this post.
I shall be coming again to your blog for extra soon.
Take a look at my web page: lose weight coffee
Hiya! I simply want to give a huge thumbs up for the nice info you could have right here on this post.
I will likely be coming back to your weblog for extra soon.
Also visit my site ... semolina breads
Good day! I simply would like to give a huge thumbs up for the good info you might have here on this post.
I will probably be coming again to your weblog for extra soon.
My blog post ... graco travel lite crib with stages weight limit
Hi there! I just wish to give a huge thumbs up
for the good information you might have right here on this post.
I will likely be coming again to your weblog for more soon.
Here is my homepage - seoul bus routes and schedules
Howdy! I just would like to give a huge thumbs up
for the good info you’ve gotten here on
this post. I shall be coming back to your blog for extra
soon.
Here is my web site - kbrs shower base
Something to say?