Import multiple.sql files into DB

  • I have more than 200 Sp's files on my folder. I would like to import onto my DB. I tried using BIDS. But it didn't worked out. Do we need to manually run the script for every file? or do we have any procedure to run all the .sql files. Please, let me know thank you.

  • Please look at this msdn example.

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

    Try adding some kind of looping to that..


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • You could also create a job with a powershell step to access the files. I used this the other day for importing a bunch of create object scripts

    $folder = "c:\scriptfolder\";$scripts = @(); get-childitem $folder | ?{$_.Extension -eq ".sql"} | %{ if($_) {$scripts += $_.name}}; foreach ($script in $scripts) {invoke-sqlcmd -inputfile "$folder$script" -serverinstance "YourServer" -database "MyDatabase"}

  • got it. Thank you

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply