AUTOID --- BRANCHID ---- QUTNO
1 10 "10#1"
2 11 "11#2"
AUTOID is a primary, autogenerated column. I need to fill the QUTNO column with combination of values from columns branchid and autoid. How can i do these in sql server insert statement stored procedure?
How about using a computed column?
Something like
DECLARE @TABLE TABLE(
AUTOID INT IDENTITY(1,1),
BRANCHID INT,
QUTNO AS CAST(BRANCHID AS VARCHAR(25)) + '#' + CAST(AUTOID AS VARCHAR(25))
)
INSERT INTO @TABLE (BRANCHID) VALUES (10),(11)
SELECT * FROM @TABLE
Make the column a computed column and set the computational expression so the two columns are concatenated accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With