Does the database exist?

  • Comments posted to this topic are about the item Does the database exist?

  • 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

  • This was removed by the editor as SPAM

  • DIR is an alias. The command behind it is Get-ChildItem.

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Stewart "Arturius" Campbell (11/4/2014)


    Interesting question, thanks Steve

    Haven't played with powershell much lately, so learned something new today.

    +1 same here 🙂

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • 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.

  • 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!).

  • In case anyone wants a link to official documentation in BOL.

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

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • 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.

  • 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.

  • I'm not a powershell user so thanks for the education.

  • 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.

  • Andy sql (11/4/2014)


    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!).

    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