Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:12:41+00:00 2026-05-30T07:12:41+00:00

i had query for update the version of my value, here the code DECLARE

  • 0

i had query for update the version of my value, here the code

DECLARE @inParam AS VARCHAR(50) = '80003689_CST_20120118'
DECLARE @file_extension varchar(50)='.xlsx'
DECLARE @lastVer AS VARCHAR(50)
DECLARE @nextVer AS INT 
DECLARE @combine AS VARCHAR(50) 

SELECT @lastVer = MAX([File_Name]) 
  FROM dbo.Uploaded_File 
 WHERE [File_Name] LIKE @inParam+'%'

SELECT @nextVer = CAST(SUBSTRING(@lastVer,LEN(@inParam) + 6, 1) AS INT) + 1

SELECT @combine = @inParam + '(' + CONVERT(VARCHAR, @nextVer) + ')' + @file_extension

SELECT @lastVer, @nextVer, @combine

the problem is when the value 80003689_CST_20120118(1), its not updated the version, the result i had 80003689_CST_20120118(1)(1)…

but i wanted the result become 80003689_CST_20120118(2).

so if i had same value it will become :

80003689_CST_20120118
80003689_CST_20120118(1)
80003689_CST_20120118(2)

etc

Answered by @Dimitri..
but i can’t mark his answered.. its givin error page on me…
thanks dimitri

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:12:43+00:00Added an answer on May 30, 2026 at 7:12 am

    I think it works now:

    DECLARE @inParam AS VARCHAR(50) = '80003689_CST_20120118'
    declare @file_extension varchar(50)='.xlsx'
    DECLARE @lastVer AS VARCHAR(50)
    DECLARE @nextVer AS INT 
    DECLARE @combine AS VARCHAR(50) 
    
    SELECT @lastVer = MAX(CAST(SUBSTRING([File_Name], LEN(@inParam)+2, LEN([File_Name]) - LEN(@inParam) - 2) AS INT))
    FROM dbo.Uploaded_File 
    WHERE [File_Name] LIKE @inParam+'(%)'
    
    SELECT @nextVer = ISNULL(@lastVer, 0) + 1
    SELECT @combine =  @inParam + '(' + CONVERT(VARCHAR, @nextVer) + ')' + @file_extension
    SELECT @lastVer,@nextVer,@combine
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

yesterday you had taught me to query record history within a time range here
I had to write a query to update all records in a table based
A while ago I had a query that I ran quite a lot for
I'm trying to optimize query performance and have had to resort to using optimizer
As I had written in title, I have SQL query, run on Oracle DB,
Had a good search here but can't see anything that gets my mind in
UPDATE: I have determined that the SQLClient code times out on the first call,
I use an update query in mysql to change the published row in my
I need a query which will update a row in Games to have a
I want to update and select one row within one query in SqLite. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.