Showing posts with label newbie. Show all posts
Showing posts with label newbie. Show all posts

Friday, March 9, 2012

how to add data to my tables (was "SQL Server Newbie")

Hi. I just set up my first sql server database and I've managed to connect to it via ASP as a test.
I'm not sure how to add data to my tables. In MS Access, you can edit the table and add records. How do I do that in SQL Server?
I'm using the Enterprise manager tool to create tables... does it have something i can use?

ThanksThe sky's the limit on how you can add and edit data in SQL tables, but comparable to what you said about editing tables in access... In EM, you can right click a table then select to open table and return all rows, top or specifiy a query. (I usually use top 1 if I plan on adding rows)

I would advise using query analyzer to do any editing though. Much easier and more efficient IMHO.|||When I try to return rows by right clicking on the table, i get an error that says:
An unexpected error happened during this operation.
Query Designer encountered a Query Error: Unspecified error.

??|||If all else fails, and you have primary keys on your tables, you can always just link the tables in MS Access. As Dr_Clong advised, though, you probably want to pick up a book on Transact-SQL. I liked Sams Publishing's "Teach Yourself in 21 Days" book.|||ok... so it sounds like i have to write sql INSERT statements to add data...??
Sorry if that's a dumb question.
I'll look up some books on transact sql.|||I don't know your setup or for that matter what could be causing your error, but I agree the best way to start out is by educating yourself on SQL Server tools and TSQL.|||1. Stop using Enterprise Manager

2. Start Using Query Analyzer

3. Open Books Online and Leave it Open

4. INSERT INTO myTable99(Col1, Col2, Col3) SELECT 'x','y','z'

5. Or bcp data in from flat files

6. Have a Margarita!

7. Post here often

8. Have Another Margarita

9. Go to 8.

how to add autonumber (increment) unique ID to sqlserver

Hi,

I am a newbie learning sql server. I used to use Access table where I set the primary ID (int) as autonumber. Every insert will generate a new ID, which is incremented by 1.

How do I add an INSERT statement to add the incrementing primary ID in sql server. I noticed that you can't set the ID to autonumber as you do in Access. I read that you can set the ID as identity, which can auto increment.

How do I handle this in the INSERT cmd. The only thought is to call a sql cmd with a max on the current id and increment by 1 in vbscript. Afterwards, add the increment ID into the INSERT call.

Is there an easier way to do this?

Thanks,

JohnHi John,

Correct. You can't write to an identity field (and I didn't know you could in Access). You don't write to it, so don't include that field in your insert statement.

If you need the new ID number, return the value from the SQL Server SCOPE_IDENTITY function after you insert the row, either by returning it from your stored procedure or immediately after doing the insert. And you can batch them together so that you have only one round trip to the SQL Server server.

And there are lots of ways to do this, depending on the needs of your application.

Is that enough information? If not, just ask. It's pretty straightforward once you get to know SQL Server a bit.

Don

Friday, February 24, 2012

How to activate the MSDTC service?

Hello,

As newbie in server country I try a course example to test a distributed transaction accessing both SQL Server 2005 and Sql Server 2005 Express.

But I get an error message saying:
>MSDTC on server is not available

I Internetted somewhere that MSDTC stands for TransactionManager service.
If I look in the 'Services' list I do not see something like MSDTC, so I think it is not installed or started.

How do I install or activate the MSDTC service?

Thanks in advange,
Henk

Hi,

What OS are you using? I have Win2K3 and I do see "Distributed Transaction Coordinator" as a service.

Thanks

Waseem

|||

In the services list it should be named "Distributed Transaction Coordinator".

You should check ControlPanel->AdministrativeTools->Component Services->Computers->My Computer->Properties.

Have a look at http://msdn2.microsoft.com/en-us/library/ms684146.aspx for a general documentation.

|||

Thanks both of you!

I'm using WinXP Prof and I see a 'Distributed Transaction Coordinator' service thats waiting to be started....
After starting it, my program runs fine!

regards,

Henk