Many Sql scripts to execute

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqar100
    New Member
    • Jun 2010
    • 27

    Many Sql scripts to execute

    I have 90 scripts in C:\SQL Scripts\*sql

    how could i execute by command ,i saw many things on net but could execute it successfully,,,
    I am using sql 2008 R2 , not a default instance
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You can run this from the command line:
    Code:
    for %f in (*.sql) do sqlcmd /S <servername> /d <dbname> /E /i "%f"

    Comment

    • waqar100
      New Member
      • Jun 2010
      • 27

      #3
      I installed SQL multiScripts software ,, trial version

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        @Rabbit
        Does your SQLCMD command cover the fact that the SQL Server is not running as the default instance?

        @Waqar100
        If you ask for assistance you should respond to when someone posts that help. If you have chosen to use special software to handle this in spite of standard software being available, and help for that given to you, surely you can explain why. Otherwise it seems like you have just ignored the expert whom you asked to help you.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          @NeoPa, oh, I'm not sure. If it doesn't there's probably a switch for it.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Originally posted by Rabbit
            Rabbit:
            If it doesn't there's probably a switch for it.
            That's cheating! :-D

            OK. I looked it up myself (Connect to the Database Engine With sqlcmd). The syntax would be :
            Code:
            for %f in (*.sql) do sqlcmd /S <servername>\<instancename> /d <dbname> /E /i "%f"

            Comment

            • waqar100
              New Member
              • Jun 2010
              • 27

              #7
              I am using this command,this will halt at.

              Code:
              for %f in (*.sql) do sqlcmd /S <WAQAR-PC>\<KARACHI20882>/d <SF_CORE_DEV_CMD> /E /i "%f"
              See the image

              Now what should i do?
              Last edited by NeoPa; Jun 4 '13, 11:57 PM. Reason: Added mandatory [CODE] tags.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                <servername>\<i nstancename> = WAQAR-PC\KARACHI20882 and there is a space before the /d.

                Try that and let us know how you get on.

                Comment

                • waqar100
                  New Member
                  • Jun 2010
                  • 27

                  #9
                  Thanks Neo Pa
                  Now i am stucking at this stage , what should i do the next.


                  FYI: i have temporary i am testing on only 3 files a t this location
                  say 3 scripts in c folder

                  Path=C:\FOlder and they are respectively 1.sql, 2.sql and 3.sql.

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    Please attach the image to the thread itself.

                    Comment

                    • waqar100
                      New Member
                      • Jun 2010
                      • 27

                      #11
                      which image @Rabbit? I didnt understand.

                      Comment

                      • Rabbit
                        Recognized Expert MVP
                        • Jan 2007
                        • 12517

                        #12
                        You attached an link to an image. Our firewalls block external file storage sites.

                        Comment

                        • waqar100
                          New Member
                          • Jun 2010
                          • 27

                          #13
                          Thanks Neo Pa
                          Now i am stucking at this stage , what should i do the next.
                          http://postimg.org/image/l4k0bv6hl/

                          FYI: i have temporary i am testing on only 3 files a t this location
                          say 3 scripts in c folder

                          Path=C:\FOlder and they are respectively 1.sql, 2.sql and 3.sql.



                          Now the link of above image is



                          Now it is ok?
                          Attached Files

                          Comment

                          • Rabbit
                            Recognized Expert MVP
                            • Jan 2007
                            • 12517

                            #14
                            That's too small to read. But it looks like a command prompt. So just type in the thread itself what the command prompt is showing.

                            Comment

                            • waqar100
                              New Member
                              • Jun 2010
                              • 27

                              #15
                              Images

                              There are 2 snaps I attached of the different extension.if you are able to see then tell me the next steps.3 sql files are in C,, see the previous detail of this path.
                              Attached Files

                              Comment

                              Working...