.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Wish to preserve carriage returns in Bulk Inserted text data. SQL 2008

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :Sql Server

Greetings.  I am using BULK INSERT to import data to a table from a text file.  One table column is varchar(max) and I wish to import text that has carriage returns and preserve the carriage returns in the database.  Basically, I am importing newspaper articles stripped of all special characters except quotes, double quotes, and CR's.  The Bulk Insert works just fine, except it strips out the carriage returns.

I am using an XML Format File and the field terminators are tabs.

Any help on this would be greatly appreciatede.  Thanks.

View Complete Post

More Related Resource Links

Using Conditional Split data Transfer in SSIS 2008

This article uses the Integration Services Conditional Split Data Transformation element to filter and transfer data from a set of flat text files to SQL Server database table. The concept can be easily extended to apply to any other source or destination such as Microsoft Excel. This scenario is useful in creating denormalized database tables in a reporting and analysis situation.

Under The Table: Spatial Data Support In SQL Server 2008


New spatial data support in SQL Server 2008 opens the door to mapping and querying geometric and geographic data, allowing you to build exciting new applications.

Bob Beauchemin

MSDN Magazine February 2009

Hierarchy ID: Model Your Data Hierarchies With SQL Server 2008


Here we explain how the new hierarchyID data type in SQL Server 2008 helps solve some of the problems in modeling and querying hierarchical information.

Kent Tegels

MSDN Magazine September 2008

Adding carriage returns between 2 dynamically created controls in an HtmlTableCell


The title pretty much explains it. Here is what i'm trying to do...

 Private Sub LoadGrid_CommentsField(ByVal Row As HtmlTableRow, ByVal BookingNumber As String, ByVal CommentsText As String)
  Dim Txt As TextBox
  Dim Cmd As ClickOnceButton.ClickOnceButton

  Txt = New TextBox
  Txt.ID = "txtComment_" & BookingNumber
  Txt.CssClass = "TFAppControls"
  Txt.TextMode = TextBoxMode.MultiLine
  Txt.MaxLength = 500
  Txt.Width = New Unit(95, UnitType.Percentage)
  Txt.Text = CommentsText

  Row.Cells(cComments).InnerHtml &= "<br/>"

  Cmd = New ClickOnceButton.ClickOnceButton
  Cmd.DisableAfterClick = True
  Cmd.Text = "Save Comments"
  Cmd.ID = "cmdSaveComments_" & BookingNumber
  Cmd.CssClass = "TFAppButtons"
  Cmd.EnableViewState = False
 End Sub

On the line where i try and update the InnerHtml, i get the following error; "Cannot get inner content of  because the contents are not literal."

evaluate data in row and change text on asp:ButtonField accordingly.


I am building a website for my hockey league.


I have a gridview that displays the current weeks scheduled games. Ideally I have added a column to the end of the gridview that I would like display 1 of 3 values. If the game has already been played I would like to display the score of the game; if the game has yet to be played I would like the column blank and if someone on either team has indicated that they can't make the game I would like to display a button that says "subs needed" and take you to another page to sign up to be a sub. Can this be done? I have been able to change the background color of the line based on the two boolean flags from the database using the RowDataBound event handler but I can't seem to find a way to set the value of a specific field in my row. (The background is set for the whole row.)

Thanks in advance -eric

SQL 2008 R2 (final): SSMS freezes: "Failed to retrieve data for this request.

The original thread is locked for some reason--but the cause of the bug had something to do with the "ssms tools pack" add-in, which, according to the comments in the connect item, will be fixed in an update of ssms tools: http://social.msdn.microsoft.com/Forums/en-US/sqlkjdatabaseengine/thread/f65737b7-fe4d-487b-aa41-ef437d100bc7 https://connect.microsoft.com/SQLServer/feedback/details/556169/ssms-completely-locked-up-after-right-clicking-a-table  

System.Data.SqlClient.SqlException: Bulk load data was expected but not sent

Hi everyone We've had this error twice now from our C# code. Nothing is changing the columns, but I've noticed though that it appears to happen when two threads are attempting to bulk insert into the same table, generally millions of rows. The docs say that SqlBulkCopy.WriteToServer is not guaranteed to be thread-safe, but is this the problem here? It feels like it. I've seen some posts where people appeared to have experienced problems in similar circumstances (http://social.msdn.microsoft.com/forums/en-US/sqldatabaseengine/thread/85d51484-6381-46bc-bcce-63b58b362d2d). There is no identity column just a non-unique clustered index that is (spid) process keyed to each thread. Do I need to synchronise access to the table for WriteToServer - is this a known problem? Many thanks Reg --- System.Data.SqlClient. SqlException: Insert bulk failed due to a schema change of the target table.   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)   at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal()   at System.Data.SqlClient.SqlBulkCo

Transferring data (on update) from SQL to SLQL (2008

Hi there,   we are having 2 MS SQL 2008 servers, where the first one is our main machine where our ERP (Navision) is running on. Now, due to a customer request, I need to send data from our main sql server into our second sql server. But not everything, only some specific datasets (only if the specific customer is affected)... not only on inserts, but also on updates and on multiple tables.   I am not quite sure which technology to use for that, I tried to read something about Integration Services and Trigger, but as I am not really into both of them and not sure what technique would be the most suitable, I'd like to ask the experts here for some advice.   The affected rows might be around 2-10% of our total inserts / updates a day.   Any help would be appreciated!

Bulk amount of data in List

Hi All, I got a requirement that to display bulk amount data in a List (Around 50000 items). Can any one of you suggest me best performance way?(Displaying this amount data would definitely leads to performance issue). Let me know if you have any Queries.   Regards, Kumar.

AdomdDataAdapter.Fill returns memory error when querying an SSAS Cube(2008)

For certain SQL's I will get the following error when calling the Fill method on an AdomdDataAdapter object. "Memory error: While attempting to store a string, a string was found that was larger than the page size selected. The operation cannot be completed."   Snippet of Code: DataSet ds1 = new DataSet(); AdomdCommand acmd1 = cn1.CreateCommand(); acmd1.CommandText = "SELECT ..."; AdomdDataAdapter ad1 = new AdomdDataAdapter(acmd1); ad1.Fill(ds1);   Now when we run this query in Ms Sql Studio we don't get any errors but the query returns 1 row with over 40,000 columns. I'm guessing the # of columns might be an issue but not sure.   When doing a Google search it appears that this problem was found in the 2005 and fixed in that version. Have any of you come across this problem?  

SslStream.Read() - Returns invalid data

Hey,I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express.I have successfully made the client application establish a connection, and send data, which appears in plain, de-crypted text on the server - this works.However, I am 'polling' the socket to see if data is available to read.Here is some code which is appropriate:----        public void Process(int threadId)        {            int BytesRead = 0;            try            {                Master.Log("BEGIN READ");                sslStream.ReadTimeout = 5000;                BytesRead = sslStream.Read(bytes, 0, bytes.Length);                Master.Log("READ " + BytesRead + " bytes");                if ( BytesRead > 0 )                {                   // process                }             } catch (IOException e) {                Log("Caught IOException: " + e.Message);                if (e.InnerException != null)                    Log("=========> INNER IOException: " + e.InnerException.Message);         }---- Here is some console output when running the application:---------LOG: Authentication successfulLOG: BEGIN READLOG: READ 140 bytesLOG: [Thread 0] [Client 1] [Address] Client.ProcessDataReceived()Text received from client: Testing

Data loading from text file

Hi, I am loading the data from a flat file into a sql table. The values in one of the column have spaces at the end of the value. I want to remove those spaces and load into the table. I am thinking of using derived column and use rtrim on that column, how can I use that as an expression. Thanks.sqldev

SSRS 2008 Export to PDF fails for large data with System.Exception: Parameter is not valid

Hi, We are working on Range Bar Chart using SSRS 2008. The report has huge data. It is properly displaying the data, but when we tried to export to pdf it is failing with the following exception. Exporting to excel works fine. Also if the report has small/medium data it is property exporting to PDF. It is failing only in case of huge data (we have custom page size of 28" X 14"). Of course the report has lot of expressions we used to customize the colors/text as per our requirements.   Server Error in '/Reports_SQLDEV2008' Application. Parameter is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: Parameter is not valid. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:   [Exception: Parameter is not valid.]   [Exception: An error occurred during rendering of the report.]   [Exception: An error occurred during rendering of the report.]    Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream ou

Data Collection in SQL 2008 not working

I am trying to use “Data Collection” feature in SQL 2008. I created it but I am not able to see any report. I am getting blank report. I saw all the jobs related to Data collection are failing and throwing following error:-     The step did not generate any output.  Process Exit Code 4.  The step failed. Any idea what needs to be done? This is SQL Server 2008 64 bits.   Thanks Saumen 

SQL server 2008 r2 Data sync question???

Sql 2008 r2 data sync, does it involve a db hosted by microsoft or does that involve us hosting the sync functionality locally?  I know we have db's local that need to be sync'd across a wan but does that happen in a db hosted in the ms cloud or does that have to do with a sync functionality that runs locally to keep my db's sync'd?   Thanks, SL

ssis sql 2000 image to 2008 varbinary Failed to retrieve long data for column

Hi, I have a task that to migrate the image type column from sql 2000 to varbinary type in sql 2008. The source column having 3812353 max datalength size for the column. The package always failed with following error message. [OLE DB Source [13177]] Error: Failed to retrieve long data for column "attch_file_content_t". [OLE DB Source [13177]] Error: There was an error with output column "attch_file_content_t" (13209) on output "OLE DB Source Output" (13187). The column status returned was: "DBSTATUS_UNAVAILABLE". [OLE DB Source [13177]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "attch_file_content_t" (13209)" failed because error code 0xC0209071 occurred, and the error row disposition on "output column "attch_file_content_t" (13209)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure. Meng Chew

SSRS 2008 Sum Calculation in text box

Hi,  Any one pls tell me how to calculate sum of text box values in SSRS 2008. (sum(Fields!Total_Days.Value, "DS_Monthday") - sum(Fields!Weekends.Value,  "DS_Weekends")) - (datediff("d",DATEADD("d",-(DAY(Today())-1),Today()),Today()))   * (Count(Fields!ClientID.Value, "DS_AVGRate")/Count(Fields!DimGPClientID.Value)) +  count(Fields!ClientID.Value, "DS_AVGRate"),Count(Fields!DimGPClientID.Value))   i want to calculate sum of the above expression in text box. I have tried it is showingerror  Aggregate function will not support in text box Pls help me to show the whole sum of above expression in text box only. Thanks in advance. Regards, Abdul2010
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend