question

ravireddy avatar image
ravireddy asked

PLEASE CHANGE SQL SERVER STOREDPROCEDURE FOR .NET VISUAL STUDIO

CREATE TABLE MyTable (COMPLAINTID int identity(1,1) NOT NULL -- See above note) ,ResponsiRble varchar(100) NOT NULL --I'm making an assumption as to length here, change to value /*Other columns here */ ,COMPLAINTID_Display AS (CASE WHEN ResponsiRble = 'MANAGEMENT' THEN 'M' WHEN ResponsiRble = 'NETWORK' THEN 'N' ELSE 'O' END + CONVERT(VARCHAR(15),COMPLAINTID)) ) this gives the output as COMPLAINTID_Display M1 N2 O1 but we want the output as M1 N1 O1
sql-server-2008sql
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Usman Butt avatar image Usman Butt commented ·
Strange..you did not accept this as my answer to your another question. But trying to implement the same kind of logic :)
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
I don't understand what you're asking for here. You mean you don't want to see the column name?
0 Likes 0 ·
Usman Butt avatar image Usman Butt commented ·
@Grant Fritchey Since I know the background I know what the OP is aiming for. That is case of a manual auto increment field. I suggested him a computed column instead. For more details please see this [question][1] [1]: http://ask.sqlservercentral.com/questions/83676/stored-procedure-creation?page=1#83687
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
Oh, wow, I sure didn't get that from the question.
0 Likes 0 ·

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
It's probably no help to you in the short term, but you should take a look at the sequency operator in SQL Server 2012. That will do exactly what you need.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.