Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2014-01-03 : 18:24:31
|
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.Smo”) | out-null## Connect to the SQL Server and get the Stored-procedures$server = new-object(‘Microsoft.SqlServer.Management.Smo.Server’) “MYSERVERNAME”$db = $server.Databases["MYDATABASE"]$dbcmd = @" SELECT [MYCOLUMN] FROM [dbo].[MYTABLE]"@$ds = $db.ExecuteWithResults($dbcmd)$dt = $ds.Tables[0]#IF I just do $dt i see the value of MYCOLUMN#IF I do below i only get$dt | Format-Table -Property DatabaseName, TableName, RowCount -Autosize#Database Name TableName ---these column names and nothing else.Any ideas what I am misisng |
|
|
|
|