SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 SQL Server Administration (2012)
 SMO commands using PS
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Aged Yak Warrior

594 Posts

Posted - 01/03/2014 :  18:24:31  Show Profile  Send TRACEYSQL an ICQ Message  Reply with Quote
[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 = @"

$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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.23 seconds. Powered By: Snitz Forums 2000