473,654 Members | 3,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

osql import inserting carriage returns?

I'm trying to run an import of some data that has unix style carriage
returns throughout (ie, 0x0A, or \n). When i use osql to import the
data, it shows up in the SQL Server 2005 database as 0x0D 0x0A or \r
\n.

I do not want this behaviour - the import file is very large and has
ddl at the beginning. Can anyone suggest a more suitable utility or
method for importing this data that will preserve the original
format? Or perhaps my database is not configured correctly?

Thanks,
Bob
Oct 15 '08 #1
7 3448
On Wed, 15 Oct 2008 09:03:57 -0700 (PDT), "bo******@gmail .com"
<bo******@gmail .comwrote:
>I'm trying to run an import of some data that has unix style carriage
returns throughout (ie, 0x0A, or \n). When i use osql to import the
data, it shows up in the SQL Server 2005 database as 0x0D 0x0A or \r
\n.

I do not want this behaviour - the import file is very large and has
ddl at the beginning. Can anyone suggest a more suitable utility or
method for importing this data that will preserve the original
format? Or perhaps my database is not configured correctly?
I haven't had to work with that type of data that I can recall, but I
do wonder how you use OSQL to import data. BCP, DTS, SSIS, BULK
INSERT sure, but not OSQL, which is for executing SQL commands.

Roy Harvey
Beacon Falls, CT
Oct 15 '08 #2
The BCP utility is a good choice to import data and provides flexibility
to use format files:
http://msdn.microsoft.com/en-us/libr...2(SQL.90).aspx
http://msdn.microsoft.com/en-us/libr...5(SQL.90).aspx

--
Plamen Ratchev
http://www.SQLStudio.com
Oct 15 '08 #3
On Oct 15, 12:10*pm, "Roy Harvey (SQL Server MVP)"
<roy_har...@sne t.netwrote:
On Wed, 15 Oct 2008 09:03:57 -0700 (PDT), "bobdu...@gmail .com"

<bobdu...@gmail .comwrote:
I'm trying to run an import of some data that has unix style carriage
returns throughout (ie, 0x0A, or \n). *When i use osql to import the
data, it shows up in the SQL Server 2005 database as 0x0D 0x0A or \r
\n.
I do not want this behaviour - the import file is very large and has
ddl at the beginning. *Can anyone suggest a more suitable utility or
method for importing this data that will preserve the original
format? *Or perhaps my database is not configured correctly?

I haven't had to work with that type of data that I can recall, but I
do wonder how you use OSQL to import data. *BCP, DTS, SSIS, BULK
INSERT sure, but not OSQL, which is for executing SQL commands.

Roy Harvey
Beacon Falls, CT

Hi Roy,

The .sql file has all the "create table" and "insert into" commands.
I just run the command like this:

c:\osql -U sa -P blahblah -d mydb -i C:\myimportfile .sql

All the data imports fine, except the simply 0x0A's in the data - they
appear in the db as 0D0A's.

If i look at the .sql file before import in a hexeditor there is
clearly no 0D's in the data itself.

Bob
Oct 15 '08 #4
On Oct 15, 12:14*pm, Plamen Ratchev <Pla...@SQLStud io.comwrote:
The BCP utility is a good choice to import data and provides flexibility
to use format files:http://msdn.microsoft.com/en-us/libr...5(SQL.90).aspx

--
Plamen Ratchevhttp://www.SQLStudio.c om
Hi Plamen,

BCP does look like a great tool, but my output format of ".sql" with
complete INSERT and CREATE TABLE statements doesn't seem like its
compatible with bcp. Please correct me if i'm wrong.

Thanks,
Bob
Oct 15 '08 #5
On Wed, 15 Oct 2008 11:11:29 -0700 (PDT), "bo******@gmail .com"
<bo******@gmail .comwrote:
>BCP does look like a great tool, but my output format of ".sql" with
complete INSERT and CREATE TABLE statements doesn't seem like its
compatible with bcp. Please correct me if i'm wrong.
No, BCP won't do that. Of course Plamen responded before it was clear
what you were doing.

Roy Harvey
Beacon Falls, CT
Oct 15 '08 #6
BCP will not work to execute scripts, it is for raw data import. Since
you are on SQL Server 2005 you can try the SQLCMD utility:
http://msdn.microsoft.com/en-us/library/ms170572.aspx
http://www.dbazine.com/sql/sql-articles/cook15

--
Plamen Ratchev
http://www.SQLStudio.com
Oct 15 '08 #7
bo******@gmail. com (bo******@gmail .com) writes:
I'm trying to run an import of some data that has unix style carriage
returns throughout (ie, 0x0A, or \n). When i use osql to import the
data, it shows up in the SQL Server 2005 database as 0x0D 0x0A or \r
\n.

I do not want this behaviour - the import file is very large and has
ddl at the beginning. Can anyone suggest a more suitable utility or
method for importing this data that will preserve the original
format? Or perhaps my database is not configured correctly?
Try using SQLCMD instead. It does not seem to add the CR.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Oct 15 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14053
by: Ajay Garg | last post by:
I am running the following OSQL command and capturing the return code for the error .Whenver i have an error like server not exists or uable to login I get a return code of 1 for the %ERRORLEVEL%.However whenever I have an errorof a wrong dbcompatibility error the retun code id 1 even though sql returns an iformation message from OSQL that the right copatibilty levels are 60,70 and 80.How can i get OSQL to return the right return code...
2
18976
by: Murtix Van Basten | last post by:
Hi, I have dumped a very large database from mysql (using mysqldump program) as a raw sql file. The reason was, convert this database to a MSSQL database. Since mysqldump creates the file as raw sql file with the database-table structures and the data in it, I thought using OSQL command line utilities should work to out this whole database in MSSQL server. I have run this command from command line:
4
2522
by: Brian Cryer | last post by:
I have some long running scripts which I fire at my database using osql. (These are big files and mostly doing inserts but some also do a few other things.) It would be nice to have some activity indication (other than the disk activity light) that these are running. When I used to use Oracle, their equivalent to osql had an option to print a dot (without a carriage return) for every "n" statements. This gave a nice "I'm alive" indicator. I...
4
7315
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to use: 'replace carriage returns with BRs comment=Replace(comment, chr(13), "<br>") but obviously net.! The <pre> tag doesn't sem to help either as the embedded return is
2
2332
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost when pulling data from an SQL database. The thing that frustrates me the most, is that when I use Enterprise Manager, the carriage returns ARE THERE. It looks fine until I pull it out.
7
11180
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the comment through a pop-up that contains a textarea. When the user hits OK on the pop-up, the text in the textarea is sent to a function on the main page. The function inserts the text into the div's text node. Please don't ask why I'm making this...
3
2315
by: Someone | last post by:
Hello Using the c file io functions if reading a csv file there is a problem if a field contains an embedded carriage return. So I can check for apostrophe pairs but processing does seem a bit of a struggle. Has anyone got a robust algorithm or functions to use to reliably get a whole row of text from a csv file even if some fields contain embedded carriage returns? Angus
11
2810
by: Someone | last post by:
Hello Using the c file io functions if reading a csv file there is a problem if a field contains an embedded carriage return. So I can check for apostrophe pairs but processing does seem a bit of a struggle. Has anyone got a robust algorithm or functions to use to reliably get a whole row of text from a csv file even if some fields contain embedded carriage returns? Angus
5
3930
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I am writing an application that automates running sql scripts against my database. Currently, I am using Process.Start("sqlcmd") with a number of parameters to accomplish this, but I would like to have more control than running an outside process. I am hoping that there is a .Net class that I can call directly to run sql scripts, but so far, I have not had any luck finding one. Can anyone give me any advice to accomplish this task?
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.