x

sql questions

table name : purchase

or_name ord_yr ord_numer

sal 2011 0004

after insert the table the value is

table name: purchase_order

order

sal-2011-0004

and again increment the ord_number replace 0004 to 005 and update the purchase table ,
more ▼

asked Apr 22 at 07:50 AM in Default

sekar gravatar image

sekar
1 1 1

What's your question?
Apr 22 at 09:13 AM ThomasRushton ♦

From your other question, is this what you meant to ask?

hi how to use 3 column(table name:purhcase) concatenate another one table(order) and when i will insert last two column or last column autoincrement only the last column (order) and updated the same table (pruchase)

tell the answer
Apr 22 at 09:14 AM ThomasRushton ♦

this is my table

table name:order column1 column 2 column3 seeee 2011 00004

i need another table

tablename: order_1

column1

seeee/2011/0004

this values is inserted and increment values ie: 0004 is update in 0005 in my order table

Apr 22 at 10:11 AM sekar
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

something like below. You will need to put in the WHERE clause accodingly

INSERT INTO order_1 ( column1 )
SELECT column1 + '/' + convert(varchar(10), column2) + '/' + column3
FROM   [order]
WHERE  . . .

UPDATE [order]
SET    column3 = column3 + 1
WHERE  . . .
more ▼

answered Apr 23 at 12:07 PM

Squirrel gravatar image

Squirrel
2.5k 1 2 4

...and wrap it all up in a single transaction...
Apr 23 at 01:25 PM ThomasRushton ♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x3

asked: Apr 22 at 07:50 AM

Seen: 334 times

Last Updated: Apr 23 at 01:25 PM