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



General discussions > Public newsgroups > microsoft.public.sqlserver.server > CAn I do this in SQL2000?

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






Author CAn I do this in SQL2000?
Jeff
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
CAn I do this in SQL2000?

Hi,

I am new to SQL. I have 2 fields in tableOrder, OrderID and OrderNum.
OrderID is
Identity:yes. Is there a way that I can set OrderNum to be "J"+OrderID and
always has 8 characters automatically in SQL2000?

OrderID OrderNum
---------- --------------
1 J0000001
2 J0000002
10 J0000010
11 J0000011
123 J0000123

I really appreciate your help and thanks in advance.

Jeff



Report this post to a moderator

Old Post 06-27-02 08:25 PM
Reply w/Quote Edit/Delete Message IP: Logged
Narayana Vyas Kondreddi
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
Re: CAn I do this in SQL2000?

You can have a computed column as shown in this example:

CREATE TABLE dbo.Orders
(
OrderID int IDENTITY(1, 1),
OrderNUM AS 'J' + RIGHT('0000000' + LTRIM(STR(OrderID)), 7)
)

INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES
INSERT INTO dbo.Orders DEFAULT VALUES

SELECT * FROM dbo.Orders

--
HTH,
Vyas, MVP (SQL Server)
SQL Server FAQ, articles, code samples, interview questions and more @
http://vyaskn.tripod.com/




"Jeff" <lpr815@hotmail.com> wrote in message
news:uSUJd3hHCHA.1740@tkmsftngp10...
Hi,

I am new to SQL. I have 2 fields in tableOrder, OrderID and OrderNum.
OrderID is
Identity:yes. Is there a way that I can set OrderNum to be "J"+OrderID and
always has 8 characters automatically in SQL2000?

OrderID OrderNum
---------- --------------
1 J0000001
2 J0000002
10 J0000010
11 J0000011
123 J0000123

I really appreciate your help and thanks in advance.

Jeff





Report this post to a moderator

Old Post 06-27-02 09:25 PM
Reply w/Quote Edit/Delete Message IP: Logged
All times are GMT.
Post new thread   Post reply

Featured site: MCSE, MCSD, CompTIA, CCNA training videos



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 OFF.
 

ExamNotes forum archive


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

  Free Braindumps | mcse braindumps