.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

Correct BCP syntax

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :Sql Server
I am a first time BCP user.  I have an XML file that I need to import into a new table in SQL Server.  This is using SQL Server 2008 and BCP version 10.50.16.  I read through the documentation but I get 370,000 errors!  (This is a very large file).  When I open the error log, I just see a bunch of question marks.  About this XML file: it does use a new line to delineate rows, however, it uses the space character to separate fields.  So I'm not sure if that is what causes it to fail.  The failure message is: BCP copy in failed I wish it were more descriptive.  Is there a way to get a more detailed error message? Otherwise, here is my command: d:\SQL Tables\data>bcp Development.dbo.wbl_zSkywardEnrollment2 in zSkywardEnroll ment.xml -fSE_format.fmt -m50 -eseErrorLog -b100 -t0x20 -T -F107 All of these files are in this same directory.  I know it says to specify full file path, but since they're all in this same directory and also I saw another example where they didn't specify directories I thought this would suffice. I have tried this without the format file also, doing it interactively but get same errors. And I have tried this starting with row 1.  I am curious which line should BCP start on?  Line 1 of this XML starts with Schema and ElementType info.  But on line 107 is where rs:data section

View Complete Post

More Related Resource Links

Correct Syntax to do a LIKE in VB.net


I want to do a LIKE clause in an SQL statement. What is the proper syntax if this if my informaiton.

I want to select personID, personName, personBuilding

From Table: main27

WHERE personName has the Name 'Smith' in it. Note that person Name is set up as: Last Name, First Name = Smith, John.

The query works fine in my access database, but I am trying to put it in a VB.net application and I can't get it to pull any records when there are 18. Any help would be grateful.

SQL Query within a form fails with "parser error" - syntax not correct?


Hello, I've created an Expression Web form with a SQL datasource which is doing a query/select statement.

Somehow it appears that I'm making a syntax error. When I divide the query in two and execute them separate, it works fine.

I need to filter for an EventType, Region and Today's date + a custom interval (like 7 day's for a week)

The parameters come from a search form where the user can select these values via a dropdown list.

The two separate (and working) queries within my form are:


Query nr.1 :

"Select * from Events WHERE  (([EventType] LIKE '%' + @EventType + '%') AND ([Region] LIKE '%' + @Region + '%'))">


<asp:formparameter DefaultValue="%" FormField="EventType" />

<asp:formparameter DefaultValue="%" FormField="Region" />


Query nr.2 :






Listview and checkbox syntax not correct - please help




I have a listview (userid, users) and a checkbox. I would like to select the checkbox and store the userid in a textbox then into a  session page. Please see below. I am having issues with the code as it seems incorrect, due to the listview1.row. Anyone can help correct the below, much appreciated.







Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim chk As CheckBox

        TextBox1.Text = String.Empty

        For Each rowItem As ListView In Listview1.Rows
            chk = CType(rowItem.Cells(0).FindControl("chk1"), CheckBox)
            If chk.Checked Then
                TextBox1.Text &= GridView1.DataKeys(rowItem.RowIndex)("Categoryid").ToString() & ","
            End If
        Session("mykey") = TextBox1.Text

    End Sub


Correct Syntax for a Select statement with a date in VB.net 2008 web developer


What is the correct syntax in VB.net 2008 web developer in SQL to do a WHERE clause where the data is >= to the current date? I can't figure out how you pass now into the SQL statement.

searching for correct syntax repeater + itemindex


Best All


How can I write this correctly?

                    <%# if (Eval("ItemIndex") > 0)
                       <div class="btn_medium btn_medium_orange_left">
                        { %>  
                       <div class="btn_medium btn_medium_grey_left">
                       <%} %>

this syntax is working:

 <li><%# Eval("Country.Name")%></li>


Does this look correct for saving a file/ new record to a database


So thank you for all your help so far, So I think i got this right,
but would like for you all to look it over to see if there is any
areas I might run into trouble with:

//using asp.net mvc 2
the table (sql server 2005, using entities framework)
table fields
"Pattern_Media_GUID  uniqueid 
"Pattern_GUID  uniqueid
"Media varbinary(max)  
"height int
"Width int
"Media_Type String (50)

the form:
<h2> Add Media to this pattern</h2>
<% Html.EnableClientValidation(); %>
<% Html.BeginForm("AddMedia", "Pattern", new { id= Model.Pattern_Guid} , FormMethod.Post, new {enctype = "multipart/form-data"}); %>
    <%: Html.Label("height") %>
    <%: Html.TextBox("height") %>

    <%: Html.Label("width") %>
    <%: Html.TextBox("width") %>

    <%: Html.Label("Media") %>
    <input type="file" id="Media" name="Media" />
    <input type="submit" name=

Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

Correct me with report.setDatabaseLogon and .setDataSource


Hi All,

I was getting a load report failed error on the server before (locally it was working fine). I tried everything one of the solutions that helped me partially was adding below lines to the code.

 ext.SetDatabaseLogon("UserId", "Password","DataBaseTest","ServerName");

When I add the above Line to Local Mechine it is working fine and returning data.(Records)

But When I publish this code to server I am getting a screen that has

Server Name : Filled

DataBaseName : EMPTY

UserName :Filled


screen and I am unable to enter the databaseName.

Scenario 2:


ext.SetDatabaseLogon("UserId", "Password","DataBaseTest","ServerName");

 When I add these 2 lines to local mechine all the crystal report with heading and date is coming up but the data from the sql server is not appearing. Actually this is loading the report correctly but unable to get the data from the data base. (Not displaying any records although it is supposed to display 100 Recs)

When I deploy it to the server it is acting the same way.Displaying the record with heading , date, page number etc, but no data

Do you know what should I do to

T-SQL in Yukon: Powerful New T-SQL Syntax Gives SQL Server a Programmability Boost


The T-SQL language in the upcoming version of SQL Server will provide more power and flexibility than previous versions. Additions and enhancements include error handling with the TRY/CATCH construct, SNAPSHOT isolation, and WAITFOR enhancements. Also important are the BULK rowset provider, common table expressions, recursive queries, PIVOT and UNPIVOT operators, and much more. This article introduces these features so readers will be ready for the next version of SQL Server.

Itzik Ben-Gan

MSDN Magazine February 2004

Input string was not in a correct format.


Hi, I just started learning asp.net

i set simple application but i get this error that  "Input string was not in a correct format"

Input string was not in a correct format.

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.FormatException: Input string was not in a correct format.

Source Error:

Line 10:     protected void Page_Load(object sender, EventArgs e)
Line 11:     {
Line 12:         decimal num1 = Decimal.Parse(txtNumber1.Text);
Line 13:         decimal num2 = Decimal.Parse(txtNumber2.Text);
Line 14:         decimal ans = num1 + num2;

How can I correct this error




Default values in SQL syntax / MVC


Hi guys, I have a little problem for which I need a little advice about.

I have a repository function called getList which retrieves certain information that gets posted to it from a form. My form has 6 fields, and a user can enter searvh criteria in any or all the fields. According to what he has entered, I must execute a SQL string to retrieve matching information.

I have the following:

public List<Client> getList(string clientSurname, string clientInitials, string clientName, string clientNumber, string clientReference, int divisionID, int clientStatus, int usrID)


var clientlist = from c in DB.Clients
                             where c.Surname.Contains(clientSurname)
                             && c.FullName.Contains(clientName)
                             && c.Initials.Contains(clientInitials)
                             && c.OldClientNo.Contains(clientNumber)
                             && c.Reference.Contains(clientReference)
                             && c.DivisionID == divisionID
                             && c.Status == clientStatus
                             && division.Contains(c.DivisionID)
                             orderby c.Surname,c.Initials

Syntax error (missing operator) in query expression

Good Day Gurus!

I have a Excel user application which has a user form (named 'Registo') that displays criteria and an image that has been entered in it's corresponding spreadsheet. This works the way it should.  There's also the ability to search the spreadsheet via a form (by clicking 'Pesquisar' button) this opens a search form. However, I having a bit of a problem with it. When I try to search for something it basically doesn't do anything at all. It just sits there. So I tried to debug it and I think I'm having a problem with either the JET db engine or somethign with teh query or maybe I don't have the correct reference.

I 'borrowed' this Excel application from another forum because it's exactly what I'm looking for! However, I suck at vb.

So I was hoping somebody could take a look at the code and see if I'm missing something?  I'm kinda' desparate to get this working because I'm been trying to figure it out for days and I'm running out of time.  Cry
Option Explicit

'constantes para auxiliar na verificação do código
Private Const Ascendente As Byte = 0

Items count in scope "not available" in on WFE while it is correct in another WFE

Recently, we added a new WFE in the farm to do load balance. After installation, the search is not working occassionally(almost 50%). It apparently hits the new server. The error message:
Your search cannot be completed because of a service error. Try your search again or contact your administrator for more information.

I checked the Items count on view scopes. It is correct on old WFE, while it is "not available" on new WFE.
 In the Office Sharepoint Server Search Seveice seeting, I checked "Use this server for indexing content" and "use this server for serving search queries". I had ever tried to uncheck ""use this server for serving search queries". It is not working, either.

Any suggestion?

ReadOnly DateTime attribute stores correct date but only retrieves DateTime.MinValue on Delete


Hey everyone,

I have a dynamic data site that stores Event data using LINQ-to-SQL. When someone requests an event, it is first stored as a PendingEvent (which is a child of Event) with a column/attribute called receivedAt, which is [ReadOnly(true)] and which is assigned in InsertEvent as shown.

        partial void InsertEvent(Event instance)
            instance.requestedAt = DateTime.Now;




This works fine. The event displays with the correct receivedAt date, and it's correct in my database. It shows up just fine on my Display, Edit, and List pages. However, if I try to delete, the receivedAt in the instance (retrieved with my debugger) in my delete function is 01/01/0001 12:00am, also known as DateTime.MinValue. My other dates appear correct.

If I remove "ReadOnly(true)" from the received at, everything works fine. Why won't "ReadOnly" allow me to have a time?
Thanks in advance,



I forgot to mention why I care. I can't submit the instance to be deleted because DateTime.MinValue is outside SQL's available datetime, so I get a SQL error. The delete also takes place in a custom dele

Incorrect syntax near 'GO' error while running a sql script ?


I am using Visual Studio 2008

I have one Database A

now i want to create Database B just like Database A

I generated a script of Database A

and created fresh Database B

Now, when i try to run the generated script against Database B, i get this error, why ? how to fix it ?

sql error

For your information:

I have checked in my script it is:


and i have also tried to save the sql script in notepad as: ANSI, UTF-8 and UNICODE

and then i copied from txt file to query but still doesn't work and getting the same error

and these are the option that i selected/used while creating my script:


LinQ Syntax of looping a collection


Hi, I would be glad is there is anyone can point/teach me the correct way of iterate a collection in LINQ. I attached part of my coding for reference. I wish to find out the location(s) of an Employee who can also happen to be a Supervisor. My model contains a Many-to-Many relationship between Location and Employee. Thanks in advance


Dim someDataSource = From _e As Employee In _context.Employees
                                  Where _e.Locations = location <---- _e.Locations return a collection 
                                  Select _e.FullName, _e.ID


Incorrect syntax near "("


Hi, below is a sub I wrote to run an SQLDataSource UpdateCommand. This is customized layer of a createUserWizard. I know I should probably have another table for the addt'l data and just FK the UserId...but I'd rather update the existing record and add the data to the existing row in the user (membership) table.

Can someone tell me what I'm doing wrong on this sub. The error is at the last line, "DataSource.Update()"


 Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs)
        FormsAuthentication.SetAuthCookie(CreateUserWizard1.UserName, False)

        Dim UserNameTextBox As TextBox = DirectCast(CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName"), TextBox)
        Dim DataSource As SqlDataSource = DirectCast(CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo"), SqlDataSource)

        Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
        Dim UserGUID As Object = User.ProviderUserKey

        DataSource.UpdateParameters.Add("UserId", UserGUID.ToString())

End Sub



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