When performing database maintenance you will occasionally find the need to export data out of your database tables to an operating system for storage, or conversely import data to a table from a file. You may find yourself needing to do these tasks for data backup or for inserting data that comes from a 3rd party export. Sybase makes this process simple by the Bulk Copy Utility (BCP).
Basic BCP Usage
BCP as it’s name suggest is used for 1 purpose the bulk copy of data to and from Sybase Tables. To utilize the utility the basic command format is:
bcp DATABASE..TABLE out C:\DB\temp.txt
If you wanted to perform an import you simply switch the out keyword for in.
BCP Option Flags
In addition to the command there are a few options you may also find yourself using.
- Server Flag -S You can specify the Database Server you are accessing by use of the -S flag followed by the Server. (e.g. -S SYBABC )
- User Flag -U If you are not using credentials outlined in your .ini file then you can specify the User you would like to use for authentication using the -U flag followed by the user name. (e.g. -U guest)
- Password Flag -P If no password is supplied then a prompt will occur to input it. You can use the -P flag to specify the password to use to bypass the prompt. (e.g. -P test123)
- Native Format -n To export data in native format which is not readable by looking directly at the file you can use the -n flag. This mode will make it so you don’t have to specify the column format during export.
- Char Format -c To export all data in basic char format then you can use the -c flag. This mode will also make it so you don’t have to specify the column format during export.
- Tab Format -t The default format for delimiting data columns per row is the tab character to specify a different delimiter -t can be used followed by the new delimiter.
- Row Format -r If you want to have a different delimiter then the new line character in your export you can modify it by using the -r flag followed by the new delimiter.
Basic BCP Output Example
bcp DATABASE..TABLE out C:\DB\temp.txt -c -S server -U userName -P password
Basic BCP Input Example
bcp DATABASE..TABLE inC:\DB\temp.txt -c -S server -U userName -P password
The Bulk Copy Utility (BCP) is a very simple and versatile tool. If you find yourself doing a lot of database management you may want to familiarize yourself with it as it can save you a lot of time, effort, and headaches.
Resources
BCP, Bulk Copy Utility, Command Line, SYBASE, T-SQL, Transact-SQL
Often we forget that although we want our URLs to be SEO friendly and contain information about the current page. Because of this URLs can become very long and cumbersome to the user and to other applications which allow a limited amount of text like Twitter. For example the URL to this article is http://resources.mdbitz.com/2010/03/creating-user-friendly-and-twitter-friendly-links-with-tinyurl, however using a tool like TinyURL we can create a short user friendly redirect that would look something like http://tinyurl.com/y9bs9k5
This shorter URL is easier to post on both web applications and through emails without worrying about the application truncating the link or breaking it up on multiple lines. To create a TinyURL you simply need to access their website at tinyurl.com/. Once there simply paste in your long URL into the input box and generate your shorter redirect link. Also if desired you could create a vanity link that can contain information on what is being linked to.
Links, Redirects, TinyURL, Twitter
AddThis is a free easy to utilize web service that enables you to increase your site traffic by enabling visitors to easily bookmark and share your web pages and content with social networks such as Facebook, Twitter, and so many more. The service works by letting you add a customizable button to your site that contains all the popular sharing tools in one place, allowing the visitor to quickly link your content out into the web for others to enjoy.
In addition the AddThis team even has analytics enabled for registered users(free registration) that allows you to see what pages are getting bookmarked or shared and to what services. In the detailed articles found on my site you will see one of the possible formats for the AddThis button. If you have a website or blog that you want to increase traffic to, then this is a free tool/service that you would be well worth integrating.
AddThis, Increase Traffic, Social Bookmarking, Social Networking
For those of us that have applications that require the uploading of files, our work has just gotten easier. Earlier this month the folks of moxiecode (tinymce) released the first version of their File Uploading tool Plupload.
This handy tool enables users to utilize Flash, Silverlight, HTML5, and other web assets for handling and displaying the progress of the files being uploaded. In addition it also contains handlers for resizing images on the client side before the file is transmitted over to your server. An interesting tool that you definitely want to review before creating your own file upload tool. Check out the Plupload official site to learn more.
File Uploader, Plug n Play, Plupload