0
A
回答
0
DECLARE @OBJ_TBLNAME VARCHAR(100) = 'touchnet'
DECLARE @OUTTBL AS TABLE (NAME VARCHAR(200), DATATYPE VARCHAR(200), NULLABLE VARCHAR(10))
declare @mytbl as table(TABLE_NAME VARCHAR(500))
INSERT INTO @mytbl SELECT TABLE_NAME from INFORMATION_SCHEMA.COLUMNS where [email protected]_TBLNAME GROUP BY TABLE_NAME
WHILE((SELECT COUNT(*) FROM @mytbl)>0)
BEGIN
DECLARE @TBLNAME VARCHAR(200)
SELECT TOP 1 @TBLNAME = TABLE_NAME FROM @mytbl GROUP BY TABLE_NAME
INSERT INTO @OUTTBL(NAME, DATATYPE, NULLABLE) SELECT @TBLNAME, '', ''
INSERT INTO @OUTTBL(NAME, DATATYPE, NULLABLE) SELECT 'Colum Name', 'Data Type', 'Type'
INSERT INTO @OUTTBL
select COLUMN_NAME AS NAME, CONVERT(varchar, DATA_TYPE) + (case when ISNULL(CHARACTER_MAXIMUM_LENGTH,-1)=-1 then '' else '('+CONVERT(varchar, CHARACTER_MAXIMUM_LENGTH)+')' end) AS DATATYPE, (CASE when is_nullable = 'YES' then 'NOT NULL' else 'NULL' end) AS NULLABLE from INFORMATION_SCHEMA.COLUMNS
where [email protected]_TBLNAME and [email protected]
INSERT INTO @OUTTBL(NAME, DATATYPE, NULLABLE) SELECT '', '', ''
DELETE TOP(1) FROM @mytbl
END
SELECT * FROM @OUTTBL
0
我已經採取了一些代碼的SP_HELP
參考的定義和這裏的東西,可以幫助你,但你仍必須將數據在Excel中手動複製:
select
'Table_name' = ao.name,
'Column_name' = ac.name,
'Type' = type_name(user_type_id),
'Computed' = case when ColumnProperty(ac.object_id, ac.name, 'IsComputed') = 0 then 'no' else 'yes' end,
'Length' = convert(int, max_length),
-- for prec/scale, only show for those types that have valid precision/scale
-- Search for type name + ',', because 'datetime' is actually a substring of 'datetime2' and 'datetimeoffset'
'Prec' = case when charindex(type_name(system_type_id) + ',', N'tinyint,smallint,decimal,int,bigint,real,money,float,numeric,smallmoney,date,time,datetime2,datetimeoffset,') > 0
then convert(char(5),ColumnProperty(ac.object_id, ac.name, 'precision'))
else ' ' end,
'Scale' = case when charindex(type_name(system_type_id) + ',', N'tinyint,smallint,decimal,int,bigint,real,money,float,numeric,smallmoney,date,time,datetime2,datetimeoffset,') > 0
then convert(char(5),OdbcScale(system_type_id,scale))
else ' ' end,
'Nullable' = case when is_nullable = 0 then 'no' else 'yes' end,
'TrimTrailingBlanks' = case ColumnProperty(ac.object_id, ac.name, 'UsesAnsiTrim')
when 1 then 'no'
when 0 then 'yes'
else '(n/a)' end,
'FixedLenNullInSource' = case
when type_name(system_type_id) not in ('varbinary','varchar','binary','char')
then '(n/a)'
when is_nullable = 0 then 'no' else 'yes' end,
'Collation' = collation_name
from sys.all_columns ac
INNER JOIN sys.all_objects ao
ON ac.object_id = ao.object_id and ao.type = N'U'
ORDER BY ao.object_id, ac.column_id
相關問題
- 1. php表導出爲excel
- 2. 將XmlDocument導出爲excel
- 3. 如何將jqgrid導出爲excel?
- 4. R:如何將結構化列表導出爲excel
- 5. 將HTML表導出爲excel
- 6. 將html5表格導出爲excel jquery
- 7. 將gridview導出爲excel表格
- 8. 將表導出爲excel,包括宏
- 9. 將R對象表導出爲excel
- 10. 將gridview行導出爲excel表
- 11. 將MYSQL表導出爲excel
- 12. PHP導出爲excel
- 13. 訪問導出爲excel
- 14. Java servlet - 導出爲excel
- 15. 節點導出爲excel
- 16. php + jqgrid +導出爲excel
- 17. 從sql查詢導出爲excel
- 18. ExtJS Gridpanel導出爲excel
- 19. SSIS導出爲excel
- 20. Telerik:Radgridview導出爲excel
- 21. KendoUI導出爲excel
- 22. datagridview導出爲excel
- 23. 導出爲excel問題
- 24. 導出爲excel vb.net
- 25. Telerik MVC導出爲excel
- 26. Dojo DataGrid導出爲excel
- 27. Rave Reports導出爲excel
- 28. 如何使用c#導出爲excel?
- 29. 如何在JasperReports中導出爲excel?
- 30. 將Jfreechart圖像導出爲excel