Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2003
    Posts
    4

    Unanswered: Adding data in SQL server

    This is probably a very basic question, so thanks in advance for not flaming the newbie.

    I created a sample database in Access, then converted it into SQL Server format using the import/export wizard. I'm doing the "Creating a Distributed Application" walkthrough in Visual Studio and everything has compiled and runs fine. My problem is that I just created an empty database in access. It only has one table with two fields (a names table with lastName and firstName fields.) When I run the project I created in Visual Studio, I don't get any errors, but the data grid that I added doesn't have any data. This isn't surprising, because it is an empty data base. I'm very new to SQL Server and can not for the life of me figure out how to add data to a database. I feel dumb even asking such a question, but how do I create some dummy first and last names?

    Thanks for the help.

  2. #2
    Join Date
    Sep 2002
    Location
    Mancos, CO
    Posts
    73

    Re: Adding data in SQL server

    Use an insert statement In Query Analyser.

    If your table is called names it would be something like:

    INSERT Names VALUES('John', 'Smith')
    INSERT Names VALUES('Jane', 'Doe')

    Or you can open the table in query analyser and type the data directly into the table.


    Hope this helps

    Brent

    Originally posted by orangewater
    This is probably a very basic question, so thanks in advance for not flaming the newbie.

    I created a sample database in Access, then converted it into SQL Server format using the import/export wizard. I'm doing the "Creating a Distributed Application" walkthrough in Visual Studio and everything has compiled and runs fine. My problem is that I just created an empty database in access. It only has one table with two fields (a names table with lastName and firstName fields.) When I run the project I created in Visual Studio, I don't get any errors, but the data grid that I added doesn't have any data. This isn't surprising, because it is an empty data base. I'm very new to SQL Server and can not for the life of me figure out how to add data to a database. I feel dumb even asking such a question, but how do I create some dummy first and last names?

    Thanks for the help.

  3. #3
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    Since you are familiar with MS Access you could create a link table in Access pointing to the SQL Server table and then enter data that way as well.
    MCDBA

  4. #4
    Join Date
    Jul 2003
    Posts
    4
    OK, I'm confused. When I type in this query into the Query Analyzer:

    INSERT names VALUES('John', 'Smith')
    INSERT names VALUES('Jane', 'Doe')

    I get the following error message:

    Server: Msg 208, Level 16, State 1, Line 1
    Invalid object name 'names'.

    The name of the database is names, the table is called name and it has firstName and lastName entities. when i click on the dbo.name table in sql server, Edit is grayed out. why is this?

    why is something so common completely obfuscated in SQL server?

  5. #5
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    Here is an example:

    Code:
    create table myTbl (myKey varchar(20), myValue int)
    go
    insert myTbl (myKey , myValue) values ('a.1.red',99)
    insert myTbl (myKey , myValue) values ('a.1.blue',7)
    insert myTbl (myKey , myValue) values ('a.2.red',88)
    insert myTbl (myKey , myValue) values ('a.2.blue',5)
    insert myTbl (myKey , myValue) values ('b.1.red',9)
    insert myTbl (myKey , myValue) values ('b.1.blue',1)
    insert myTbl (myKey , myValue) values ('b.2.red',8)
    insert myTbl (myKey , myValue) values ('b.2.blue',6)
    go
    MCDBA

  6. #6
    Join Date
    Sep 2002
    Location
    Mancos, CO
    Posts
    73
    If the table is called name then modify:

    INSERT name VALUES('John', 'Smith')
    INSERT name VALUES('Jane', 'Doe')

    name is whatever the table is called. If your table was called contacts then it would be:

    INSERT contacts VALUES('John', 'Smith')
    INSERT contacts VALUES('Jane', 'Doe')

    Brent




    Originally posted by orangewater
    OK, I'm confused. When I type in this query into the Query Analyzer:

    INSERT names VALUES('John', 'Smith')
    INSERT names VALUES('Jane', 'Doe')

    I get the following error message:

    Server: Msg 208, Level 16, State 1, Line 1
    Invalid object name 'names'.

    The name of the database is names, the table is called name and it has firstName and lastName entities. when i click on the dbo.name table in sql server, Edit is grayed out. why is this?

    why is something so common completely obfuscated in SQL server?

  7. #7
    Join Date
    Jul 2003
    Posts
    4

    i knew it shouldn't be so difficult

    OK...I figured it out. It's really easy to add data in SQL server, without adding links to an Access database or INSERT statements. All I did was navigate to the table in Enterprise Manager, right click on Open and then click "Return all rows." This pulls up an Access style representation of the data and allows you to easily enter or edit the data.

    Thanks to all for your help though! Now if only I could get the update button in the web service to work.....

  8. #8
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    If you are having problems with UPDATE you should try SQL Profiler to verify the SQL statement is making it to SQL Server. If it is, then COPY/PASTE the statement from SQL Profiler into SQL Analyzer and run the SQL statement. When executing the SQL statement in Analyzer make sure you are logged in with the same UserID used for the Web to verify permissins as well.
    MCDBA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •