如何使用Powershell列出所有SQL Server表,列和列数据类型?

时间:2023-01-28 17:03:09

I'm trying to do documentation on an SQL server 2008 database. This includes listing all tables, their columns, and the column types. I've been so far as to use "get-childitem | get-member" while browsing the table, the column, and the column's extended properties, and none of them return the data type of the columns. Is there a way to list the data types of columns in powershell?

我正在尝试在SQL Server 2008数据库上做文档。这包括列出所有表,列和列类型。我一直在浏览表,列和列的扩展属性时使用“get-childitem | get-member”,并且它们都没有返回列的数据类型。有没有办法在PowerShell中列出列的数据类型?

2 个解决方案

#1


Sure, take a look at the SQL Server 2008 PowerShell provider over at:

当然,在以下位置查看SQL Server 2008 PowerShell提供程序:

http://msdn.microsoft.com/en-us/library/cc281954.aspx

-Oisin

#2


From a table's Columns "directory", you can get the column types like this:

从表的列“目录”,您可以获得如下列类型:

PS> gci | select Name, DataType

#1


Sure, take a look at the SQL Server 2008 PowerShell provider over at:

当然,在以下位置查看SQL Server 2008 PowerShell提供程序:

http://msdn.microsoft.com/en-us/library/cc281954.aspx

-Oisin

#2


From a table's Columns "directory", you can get the column types like this:

从表的列“目录”,您可以获得如下列类型:

PS> gci | select Name, DataType