ExamNotes.net  -  IT certification portal

ForumsCertResearchTop sitesNewslettersFree email
HomeRegister
Exams Notes
Practice exams
Exam games
Questions by email
Online training
Training videos
College degrees
Boot camps
Book store
Links directory
Tell a friend
For webmasters

CompTIA Exam Vouchers
Save money on CompTIA exams
Question of the day
Sign up to receive
interactive practice questions
for MCSE, CompTIA
Cisco and other exams
TestKing
Get MCSE, MCSD, CCNA, CCNP,A+, N+ and many more

* ExamSheets *
Guide for Success!
Actual Questions & Answers
MCSE, MCSD, A+ ,CCNA, CCNP
Oracle 8i, Oracle 9i

Online practice tests

Certification sites

Online university

Online college

Online education

Distance learning

Software forum

Server administration forum

Programming resources






This is interesting: Free IT Magazines | Databases help forum



Microsoft (MCSE, MCSD, MOUS, MCAD) > SQL server exams > Error Handling

Show a Printable Version
Email This Page to Someone!
Receive updates to this thread




Click here for list of SQL 2000 study guides



Author Error Handling
cocolocopolo
Senior Member




Registered: Apr 2001
Location: Los Angeles
Country: USA
State:
Certifications: A+, Network+, CCNA
Working on: MCDBA

Total Posts: 287
Error Handling

From "Microsoft SQL Server 2000 Database Design & Implementaton Training Kit", there is a training question to create a database
(by the name of BookShopDB) and several tables, one of the table is Customers (but I created tblCustomers at that time).

Now, when it comes to Chapter 8 "Implementing Stored Procedures"
to practise Error Handling, I followed the instruction, entered the following code:

Declare @r_Code int
Execute @r_Code=dbo.AddCustomer
@FirstName= 'Jamie', @LastName= 'Marra',
@Phone = '425-555-1212', @Address1 = '20 Oak St., SE',
@City = 'Remy', @State = 'WA', @Zip = '98888'

If @r_Code = 4
Begin
Print 'A database error has occured.
Please contact teh help desk for assistance.'
End

If @r_Code = 1
Print 'You must specify a value for the firstname or lastname.'

Else If @r_Code = 2
Print 'You must specify a value of the phone number.'

Else If @r_Code = 3
Print 'You must provide all address information, Street address, City, State and Zipcode.'

Else If @r_Code = @@Identity
Select [Customer ID] = 'The new customer is: ' +
Convert(Char(2), @r_Code)


But I got error:
Server: Msg 208, Level 16, State 1, Procedure AddCustomer, Line 16
Invalid object name 'BookShopDB.dbo.Customers'.

I understand there is no such table by the name of Customers (only tblCustomers).

So I modified the codes and enter following code instead:


Select [BookShopDB].[dbo].[tblCustomers].[Customer ID]= 'The new Customer ...'


But got another error again that:

Line 23: Incorrect syntax near '='.

Besides drop the tblCustomers, then re-create Customers table, I wonder if there is another way to fix this error???

Please help.

__________________
cocolocopolo

Report this post to a moderator

Old Post 07-01-02 05:54 AM
cocolocopolo is offline Click Here to See the Profile for cocolocopolo Click here to Send cocolocopolo a Private Message Add cocolocopolo to your buddy list Find more posts by cocolocopolo Reply w/Quote Edit/Delete Message IP: Logged
2lazybutsmart
The Game Never Ends




Registered: Jun 2002
Location: Toronto
Country: Canada
State:
Certifications: MCSD, MCP
Working on: MCSD.net, MCDBA, MCT

Total Posts: 684

looks like the error is comming from the dbo.AddCustomer stored proc. can u print that out for us here on the thread so we can analyze it a bit.

i hope ur not facing role problem, i hate them.

__________________
Crime is Common, Logic is Rare.
TechExams.net moderator

Report this post to a moderator

Old Post 07-01-02 05:58 AM
2lazybutsmart is offline Click Here to See the Profile for 2lazybutsmart Click here to Send 2lazybutsmart a Private Message Add 2lazybutsmart to your buddy list Find more posts by 2lazybutsmart Reply w/Quote Edit/Delete Message IP: Logged
kingsunl
Junior Member
M




Registered: Nov 2001
Location: Richmond
Country: Canada
State:
Certifications: MCSD
Working on: MCSD .NET

Total Posts: 8
Specifying Aliases

quote:

Select [BookShopDB].[dbo].[tblCustomers].[Customer ID]= 'The new Customer ...'



When specifying aliases, the correct syntax is:

Select 'The new Customer'=[BookShopDB].[dbo].[tblCustomers].[Customer ID],...

Place the alias first followed by an equality operator and then the column name.

Personally, I like to do it this way:

Select [BookShopDB].[dbo].[tblCustomers].[Customer ID] AS 'The new Customer', ...

The third way is:

Select [BookShopDB].[dbo].[tblCustomers].[Customer ID] 'The new Customer', ...

The word 'AS' is removed.

Report this post to a moderator

Old Post 07-02-02 04:18 PM
kingsunl is offline Click Here to See the Profile for kingsunl Click here to Send kingsunl a Private Message Add kingsunl to your buddy list Find more posts by kingsunl Reply w/Quote Edit/Delete Message IP: Logged
cocolocopolo
Senior Member




Registered: Apr 2001
Location: Los Angeles
Country: USA
State:
Certifications: A+, Network+, CCNA
Working on: MCDBA

Total Posts: 287

Dear kingsunl, thanks for your advice.

The MCSE Training Kit likes us to come up a result in this way:

"The new customer is 11 (or 12 so on so on)'

So I follow your suggesttion and changed the last "Select" clause like this way:

Select [BookShopDB].[dbo].[tblCustomers].[Customer ID] AS 'The new Customer'

but after this clause, how can I combine the @r_Code so the result can come up a customer ID number???

Thanks in advance.

__________________
cocolocopolo

Report this post to a moderator

Old Post 07-03-02 05:12 AM
cocolocopolo is offline Click Here to See the Profile for cocolocopolo Click here to Send cocolocopolo a Private Message Add cocolocopolo to your buddy list Find more posts by cocolocopolo Reply w/Quote Edit/Delete Message IP: Logged
kingsunl
Junior Member
M




Registered: Nov 2001
Location: Richmond
Country: Canada
State:
Certifications: MCSD
Working on: MCSD .NET

Total Posts: 8

quote:

But I got error:
Server: Msg 208, Level 16, State 1, Procedure AddCustomer, Line 16
Invalid object name 'BookShopDB.dbo.Customers'.


You must look at line 16 of AddCustomer procedure. There is no point modifying the current codes that call this procedure.

quote:

Else If @r_Code = @@Identity
Select [Customer ID] = 'The new customer is: ' +
Convert(Char(2), @r_Code)


will work if AddCustomer procedure is straightened out.

Report this post to a moderator

Old Post 07-03-02 02:58 PM
kingsunl is offline Click Here to See the Profile for kingsunl Click here to Send kingsunl a Private Message Add kingsunl to your buddy list Find more posts by kingsunl Reply w/Quote Edit/Delete Message IP: Logged
All times are GMT.
Post new thread   Post reply

MCSE exam notes



Forum Jump:
Rate This Thread:
Forum Rules:
Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author.
Posts: HTML code is OFF. Smilies are ON. vB code is ON. [IMG] code is ON.
 

ExamNotes forum archive


Powered by: vBulletin 2.2.8
Copyright ©2000, Jelsoft Enterprises Limited.

  Free Braindumps | mcse braindumps