﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Programming / Powershell  / Query to variable - not wanting table style result / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 05:26:11 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query to variable - not wanting table style result</title><link>http://www.sqlservercentral.com/Forums/Topic1392510-1351-1.aspx</link><description>No problem.Still getting to grips with Powershell and very little of it is common sense so far :-)The hardest bit has been linking all the individual steps together - once you start seeing how you can pass info from one step to the next it really does become an amazing tool!CheersGaz</description><pubDate>Wed, 05 Dec 2012 03:11:02 GMT</pubDate><dc:creator>Gazareth</dc:creator></item><item><title>RE: Query to variable - not wanting table style result</title><link>http://www.sqlservercentral.com/Forums/Topic1392510-1351-1.aspx</link><description>Many thanks for that.  It must seem like common sense to you but I didn't realize that queries would actually return results with members that can be seperated.  This opens up a world of possibility and extra knowledge for me.Query resolved.</description><pubDate>Wed, 05 Dec 2012 02:15:04 GMT</pubDate><dc:creator>Drenlin</dc:creator></item><item><title>RE: Query to variable - not wanting table style result</title><link>http://www.sqlservercentral.com/Forums/Topic1392510-1351-1.aspx</link><description>If it's one result, you can get it like this:$lastBackupFile.physical_device_nameThis can be used in other methods, e.g.:($lastBackupFile.physical_device_name).SubString(0, 30)If it's multiple rows you can do something similar but include the row number:$lastBackupFile[0].physical_device_name</description><pubDate>Tue, 04 Dec 2012 10:21:47 GMT</pubDate><dc:creator>Gazareth</dc:creator></item><item><title>Query to variable - not wanting table style result</title><link>http://www.sqlservercentral.com/Forums/Topic1392510-1351-1.aspx</link><description>HiI am trying to run a script that queries the last full backup file for a specific database.  Invoke line formated for ease of reading.[code="plain"]# Script is ran on the SQL server (not remotely)# Instance is called sql-instance# database is called sql-dataimport-module SQLPS -disableNameChecking$instanceName = "$($env:computername)\sql-instance"$server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName$lastBackupFile = Invoke-Sqlcmd -Query "	SELECT TOP 1 msdb.dbo.backupmediafamily.physical_device_name 	FROM   msdb.dbo.backupmediafamily 		INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id 	WHERE  msdb..backupset.type = 'D' and msdb.dbo.backupset.database_name = 'sql-data'	ORDER BY  msdb.dbo.backupset.backup_finish_date desc"[/code]The result I get with this is in a table format:[code="plain"]physical_device_name--------------------C:\Program Files\Microsoft SQL Server\MSSQL11.SIMS2012\MSQL\Backup\full_sql-data_20121101.bak[/code]Is there any way to just get the result and not the heading stuff?I need just the path and filename for using elsewhere in the script.I tried searching around but only found articles that give the table format and I don't know enouth to trim this down with confidence.Thanks in advance</description><pubDate>Tue, 04 Dec 2012 08:00:53 GMT</pubDate><dc:creator>Drenlin</dc:creator></item></channel></rss>