November 3, 2014 at 10:03 pm
Comments posted to this topic are about the item Does the database exist?
November 4, 2014 at 12:44 am
Thanks for the question - to play safe I left until after my first coffee
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
November 4, 2014 at 2:27 am
This was removed by the editor as SPAM
November 4, 2014 at 3:57 am
DIR is an alias. The command behind it is Get-ChildItem.
November 4, 2014 at 4:28 am
Nice question, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
November 4, 2014 at 5:29 am
Stewart "Arturius" Campbell (11/4/2014)
Interesting question, thanks SteveHaven't played with powershell much lately, so learned something new today.
+1 same here 🙂
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
November 4, 2014 at 6:25 am
I haven't played with PowerShell much at all.
November 4, 2014 at 6:44 am
Alex Gay (11/4/2014)
DIR is an alias. The command behind it is Get-ChildItem.
There's a whole slew of commands that are aliased as DIR is. I believe powershell aliased the same commands used in the command prompt so that users can use either.
November 4, 2014 at 6:53 am
Alex gets a +1
It is a very important concept in the Powershell world; in this example, the "dir" alias doesn't just return a list of databases - it returns an object for each database. Additional commands can be made on these objects, as well as piping the objects to another cmdlet. Steve's question is still valid and 100% accurate (of course!).
November 4, 2014 at 8:24 am
In case anyone wants a link to official documentation in BOL.
November 4, 2014 at 11:26 am
Alex Gay (11/4/2014)
DIR is an alias. The command behind it is Get-ChildItem.
(to my knowledge..) DIR is a DOS command which also can be used in PS without aliasing. Once you connect to the SQLPS use the CD command to change the path and use the DIR to list the directories or the LS( "ls") command at each stage.
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
November 4, 2014 at 12:13 pm
Great question. I don't use PowerShell at all currently but the more I read up on it, the more I can see uses for it. Knowing that some of the commands are aliased to use more familiar command line terms like "dir" is a big help. Thanks Steve.
November 5, 2014 at 6:34 am
I'm not a powershell user so thanks for the education.
November 5, 2014 at 6:40 am
As mentioned earlier by Alex, "dir" is an alias for "Get-ChildItem". It might, as a casual user, look like it produces the same results as the old DOS command of the same name, but it is very important to understand that this is the PowerShell world, not simply running DOS commands in PowerShell.
November 6, 2014 at 4:02 am
Andy sql (11/4/2014)
Alex gets a +1It is a very important concept in the Powershell world; in this example, the "dir" alias doesn't just return a list of databases - it returns an object for each database. Additional commands can be made on these objects, as well as piping the objects to another cmdlet. Steve's question is still valid and 100% accurate (of course!).
100% accurate? Well, maybe whether it works or not depends what CD (ie sl, Set-Location) commands you have executed before DIR DATABASES. If you aren't at DEFAULT will DIR DATABASES work? Of course it's maybe a reasonable assumption that your location is SQLSERVER:\SQL\MyComputer\DEFAULT, but reasonable assumptions sometimes lead to undesirable results. So let's say 99.995% accurate just to be pedantic and allow for the one time in 20000 when your curent location is not the default. :hehe:
Besides, I would probably type ls instead of DIR because I was using ls before ms dos existed.
Tom
Viewing 15 posts - 1 through 15 (of 17 total)
You must be logged in to reply to this topic. Login to reply