Import multiple files using sql server management studio

Using sql server management studio I want to do 2 things.
- Import all txt files from a directory as tables into my DB.
- Add an additional field to each new table which contains the table name.
Can anyone help me?

There are couple of ways to do it:
File naming conventions : YourFileName_SystemId.txt
You can create one extra column in table or may be name a table with system id. Then after loading the data you can update that column with the system id.
   components required:
 ForEachLoopContainer - To get file and store file name in a variable
 Expression Task (if SSIS 2012 or above) or variable expression or script task to seperate file name from systemId
 Data Flow Task - to load data
 Execute SQL Task - to update last column or specific table based on precedence constraints  
Note: You can also add extra column in data flow via
derived column transformation.
Ex.:
Load file via foreach loop
Split string via seprator
2: Loading different system file in different folder
you can have predefined folder structure ex: SystemId1, SyetemId2 etc and can download respective txt file in their system folder. Then you can easily identity which file belong to which system and then load it to the respective table.
3: Use first row of text file to hold the system value
Use first row to have the system id and then skip row while fetching data. 
Note: Then you have to read first row through script task to get the system id.
hope this will help

Similar Messages

  • Not able to access database from a remote machine using SQL Server Management Studio

    Hi,
    I have a DB_BOX with SQL Server 2008 R2 installed. I can access the databases on the local machine using SQL Server Management Studio but it is not accessible from other machines, though the machines are in same domain.
    I have remote enabled on SQL Server box, TCP enabled, firewall off. I checked with IP Address too, all SQL Server services are running.
    The SQL Server log shows the message
    The requested service has been stopped or disabled and is unavailable at this time. The connection has been closed.
    I get the below message in SSMS from remote machine.
    Details of error message are
    ===================================
    Cannot connect to DB_BOX.
    ===================================
    A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) (.Net SqlClient Data Provider)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=64&LinkId=20476
    Server Name: DB_BOX
    Error Number: 64
    Severity: 20
    State: 0
    Program Location:
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
       at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
       at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
       at System.Data.SqlClient.TdsParserStateObject.ReadByte()
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
       at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

    Sorry, missed the message from the errorlog in the original post. You shouldn't have included that big .Net dump that hid the important facts. :-)
    My first Google attempt on that message (which I have never seen before) suggests that the TCP Enpoint is stopped, so try this:
    ALTER ENDPOINT [TSQL Default TCP]
    STATE=STARTED;
    Erland Sommarskog, SQL Server MVP, [email protected]
    This solves the problem. Thanks...

  • How to recover deleted attached mdf file from sql server management studio

    Hi everyone
    I've faced very bad problem
    I had a mdf file that created in visual studio, and then I had attached this file to sql server management studio and after that, when I wanted to deattach
    this file I had a big mistake; and deleted the mdf file; then now this file was deleted from my computer
    I test several recovery tools but they can't find deleted mdf file; the volume of the mdf file was more than 2 GB.
    Please help me if you can

    Hello,
    If you don't have a backup of the database, then it's not really possible to get it back. There are some "Undelete" Tools available for Windows, but when even only one page was overwritten on disk, then it's not possible to recover it.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to find a record then edit using sql server management studio

    Hello,
    A very basic question:
    I want to find a record stored in MS SQL Server 2008 express database table then edit the record.
    I tried to do it using SQL Server 2008 management studio express because I have been using MS Access database all the time. I have right clicked the table in management studio, clicked the "Edit top 200 records" menu item then when records were
    displayed on the result pane, I pressed Ctrl + F key to find a student named Simon for example. Well, nothing happened. I couldn't see any dialog boxes for putting in the search criteria.
    I guess I cannot simply use Ctrl+F in SQL Server management studio to find / edit a record.
    Can someone please teach me how to find a record specifying a search criteria then edit the record in SQL server management studio?

    Hi ZKM128,
    I have not seen Ctrl+F to be used to look for desired rows in Sql server.
    On the result pane after you selected "Edit top 200 records", just right click , select
    PANE, SQL, you will get the T-Sql query t,here you need to mention the exact criteria which you are looking for, and then you will get the desired rows and then you can edit.
    Thanks
    Manish
    Please use Marked as Answer if my post solved your problem and use
    Vote As Helpful if a post was useful.

  • How to create a composite nonclustered index using sql server management studio

    Hi,
    How do I create a composite non clustered index using Manage Index and Keys dialogue box?
    sukai

    See image below:
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Can't Use SQL Server Management Studio

    Hello, all. I'm having trouble with SSMS in SQL Server 2014. I was using it just the other day for my database class, and today when I tried using it, SSMS opened, but the login window didn't appear. It isn't hidden behind any other windows that I can see,
    but apparently it is somewhere, because when I click on the SSMS window, anywhere, I get the telltale "ding" sound that tells me that there's a modal window opened that is blocking this window from taking the focus.
    I got frustrated with it enough that I uninstalled SQL Server 2014, and reinstalled it, and I still have the same problem. I'm on a Surface Pro 3, so I've got Win8.1 installed (have not installed 10 yet - don't think I will at this point yet). Does anyone
    have any suggestions as to how I can get the modal login window to show? I even tried opening a .sql file, and while it opens in the window, I still can't do anything because it still seems that the modal login window is blocking it from taking the focus.
    -- Rich

    Hello,
    Could you try to download and install the latest cumulative update for SQL Server 2014? Below you will find the link to download it:
    http://support.microsoft.com/kb/2984923/en-us
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Find Connection String used by SQL Server Management Studio

    I am having problems getting my VS C# .NET application to connect to a SQL Server Database, even though I can connect to it (on the same machine) using SQL Server Management Studio.
    Is there any way I can find the connection string that SQL Server Management Studio generates when it connects?

    Hi,
    As you have Visual Studio on your machine, I think we can also use the Visual Database Tools of Visual Studio to generate the connection string.
    Please:
    1. Create a new data connection to the SQL Server database in the
    Server Explorer of Visual Studio
    2. After the connection is established, right-click on the connection name and select
    Properties. There is an item called Connection String in the
    Properties window.
    Reference:
    How to: Add New Data Connections in Server Explorer/Database Explorer 
    http://msdn.microsoft.com/en-us/library/3d1wkhas.aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

  • Sql server management studio express - change tracking

    I'm using sql server management studio express 2005 , wanted to turn function "change tracking" for Northwind database, but when I clicked properties for northwind, there wasn't any tab for change tracking. what's the deal?

    I'm using sql server management studio express 2005 , wanted to turn function "change tracking" for Northwind database, but when I clicked properties for northwind, there wasn't any tab for change tracking. what's the deal?
    change tracking is available only from sql 2008 and above.. it is not available in sql 2005
    if you want too play with, try downloading sql 2008 or above express editions...
    Hope it Helps!!

  • Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database"

    Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
    When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
    somewhere that there should be a compact database option. but I do not see it.
    What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
    Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
    Thank you for your help..
    diana4

    Hello,
    With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
    You can use the free SQL CE Toolbax instead; see
    http://sqlcetoolbox.codeplex.com/
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • SQL Server Management Studio - File Encoding

    I have been searching the forums for this issue and I haven't found anything on it so I apologize in advance if this issue has already been covered. My eyes are droopy and the coffee supply is low.
    Is there a way to always save a file as UTF-8 or ANSI in SQL Server Management Studio? In analyzer you could save as ANSI, etc.
    - d

    That's very useful feedback.  Could you please file a suggestion on http://connect.microsoft.com/SqlServer? 
    The product teams use customer feedback to help prioritize future work.  Filing the suggestion on the Connect site does two things:  First, it ensures that your suggestion goes directly into our internal issue tracking system and we don't lose any information.  Second, suggestions from customers carry more weight than those proposed by employees, so filing suggestions on Connect can have a bigger impact on future improvements.
    Thanks,
    Steve

  • SQL server management studio importing

    Hi All
    I am trying to import data from excel into my database tables in SQL Server management studio and the import facility just doesn't appear to be available. Could this be a permissions or setup issue? Apologies if I am posting in wrong area as I am new to
    this 

    I am trying to import data from excel into my database tables in SQL Server management studio and the import facility just doesn't appear to be available. Could this be a permissions or setup issue? Apologies if I am posting in wrong area as I am new to
    this 
    Excel data can be imported to SQL easily by using SQL Server Import and Export Wizard which is available in SQL Server management Studio itself.
    Right click on Database then select Task then Import data. Wizard opens up and just follow the instructions.
    Please feel free to revert in case if you need additional details.
    Cheers,
    Vaibhav Chaudhari
    MCP, MCTS, MCSA (SQL Server 2012)

  • SQL Server Management Studio - Configuring the environment for first time use

    Hi
    I have recently switched my local 'My Documents' folder location to a network drive that I 'make available off line' to allow on-line/off-line work and synchronisation when I am working in and out of the office.
    When I load my SQL Server Management Studio 2005 I frequently get 'Microsoft SQL Server Management Studio is configuring the environment for first time use'.
    Management Studio  them loads and I can continue without problem.
    I am guessing it is trying to make reference to some settings file. Any ideas? I wonder if I can change/move these settings elsewhere to a local drive?
    Thanks

    Hi,
    There is bug report of this issue:
    http://connect.microsoft.com/SQLServer/feedback/details/126364/configuring-enviroment-for-the-first-time-every-time-in-ms-sql-server-management-express
    "SQL Server Management Studio Express saves the settings for the user in ...\Documents and Settings\<User Profile>\Local Settings\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM
    and in ...\Documents and Settings\<user profile>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM
    if any of these files are not available or unusable, SSMSE will generate new ones."
    Hope this helps.
    BR,
    JoukoK

  • Impossible to open .dtproje file after re-installing SQL Server Management Studio

    Hi all,
    today, after re-installing SQL Server Management Studio from a package downloaded from MS web site (SQLManagementStudio_x64_FRA.exe), I tried to open a SSIS package file via Visual Studio and I get a message stating that  this type of project (.dtproj)
    is not supported.
    Here are the events that lead to this problem:
    We have SQL Server 2005 installed on a server and are planning to migrate to SQL Server 2012.
    1 - Earlier this year, to solve a problem that we had with the SSMS client, we installed SSMS 2012 client on my station.
    At this point, it worked fine for SSMS and when I tried to access SSIS it converted the packages  to SSIS 2012 and it worked fine too.
    2 - Yesterday, I tried to access SSMS and I had the message that the test period had expired; at this point I could open a SSIS file.
    3 - To solve the problem with SSMS we decided to re-install it. It worked fine for SSMS but now I am not able to open a SSIS file.
    Do you have any idea of what the problem is and what should I do to solve it?
    It seems that there are some SSIS component missing, how could I get them back?

    You are welcome Sylviep,
    Based on what I see you want to create BI projects (e.g. a SSIS project), thus it will be enough to install SSDT
    which is part of the SQL Server installation media. I do not see why you would re-install SQL Server itself.
    Arthur My Blog

  • SQL Server Management Studio File Open dialog is very slow to change directories

    I am running Microsoft SQL Server Management Studio    10.0.2531.0 on Windows 7 Professional.
    I have an intermittent problem with the File Open dialog. Sometimes it works reasonably well, but often it takes a very long time (a few minutes) to change directory. While it is doing whatever it is doing, the dialog and all of SSMS becomes unresponsive
    - I can't even cancel the dialog. It sometimes changes the cursor to an hourglass and sometimes not.
    I do not have this problem with any other application.
    I can open File Open one time and have this delay for every single directory change or if I open the Look In dropdown then, after closing it I can open it again and it will work with normal delays.
    It is slow more often than it is normal.
    It makes accessing files very impractical.

    Hi,
    10.0.2531.0 is SQL Server 2008 Service Pack 1 (release April 2009)
    No guarantee this will fix your issue, but may be worth testing the latest Service Pack 3 (released October 2011) to see if that helps
    http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27594

  • The SQL Server Management Studio used for SQL 2012

    Hi,
    Wanted to confirm is SQL Server Management Studio 2008 compatible client for
    SQL server 2012, or does the client come packaged with the SQL 2012

    Related thread:
    http://stackoverflow.com/questions/12136005/sql-server-management-studio-2008-connects-to-sql-2012-localdb
    SQL Server 2012 client tools include SSMS 2012 version.
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Maybe you are looking for