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

  • SEARCH
  • Home
  • 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 6177947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:21:56+00:00 2026-05-24T00:21:56+00:00

I have a table called dbo.Tbl_ActivityInformations and the data look like Activityid activitymaxcount Activityusedcount

  • 0

I have a table called dbo.Tbl_ActivityInformations and the data look like

Activityid  activitymaxcount   Activityusedcount
   1               10                 9
   2               10                 7
   3               15                15

And another table called Tbl_AttendeeInformations and the data look like

AttendedID    AssID     ActivityID
    13        123456      1,2
    14        123457      1,3

In the Tbl_AttendeeInformations table data will be inserted as new row from page and in the ActivityInformations table Activityusedcount column incremented by one for appropriate activityID.

Now I want to check before inserting a row into AttendeeInformations that Activityusedcount < activitymaxcount using ActivityID. If the condition is satisfied then only it will allow to insert otherwise it should rollback. I have function named SplitString to split ActivityID in Tbl_AttendeeInformations.

This is the code for SplitString

create  FUNCTION dbo.SplitString(@FormattedString varchar(8000),@Delimitter char(1))      
returns @retResults TABLE(Value varchar(8000),Rownumber int)      
as      
BEGIN      
        DECLARE        @SearchString as varchar(8000)      
        DECLARE        @AssignString as varchar(8000)      
        DECLARE @Index int                      
        DECLARE @Count int      

        set @SearchString = @FormattedString      
        set @AssignString= ''      
        set @Count = 0      

        while(len(@SearchString) > 0 )      
        begin                      
                SET @Index =   CHARINDEX(@Delimitter,@SearchString, 0)                      
                set @Count = @Count + 1      
                if  @Index = 0      
                begin      
                        INSERT INTO @retResults      
                                values( @SearchString,@Count)      
                        set @SearchString = ''      
                        continue      
                end                      
                set @AssignString = SUBSTRING(@SearchString,1, @Index - 1 )      
                INSERT INTO @retResults values      
                        (@AssignString,@Count)      

                SET @SearchString = (select SUBSTRING(@SearchString, @Index + 1, LEN(@SearchString) -  @Index ))      


        end      
        return      
END     

Please do help.

  • 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-24T00:21:57+00:00Added an answer on May 24, 2026 at 12:21 am

    Pseudocode to show an idea:

    INSERT INTO AttendeeInformations
    SELECT act.*
    FROM ActivityInformations act 
    INNER JOIN AttendeeInformations at ON act.ActivityID = at.ActivityID
    WHERE act.Activityusedcount < act.activitymaxcount
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table called Data_Details and the data looks like: DateTimeClosed Datesub TimeSub 6/20/2011
I have a table in SQL Server 2000 Standard Edition called dbo.T668 (don't blame
I have a table called Stock and another called Listed, within the Stock Table
I have a table called Periods that looks like this PeriodID | PeriodYear |
I have a table called with thousands of records and would like to implement
SQL 2005, 600,000,000 rows. I have a table called Location currently using the data
I have a table that looks like this: CREATE TABLE [dbo].[SomeTable]( [Guid] [uniqueidentifier] NOT
I have a table called Node with 4 columns in which the data are
I have a table like this: CREATE TABLE [dbo].[Scores]( [Id] [int] IDENTITY(1,1) NOT NULL,
Have a find call on a table called Attachment which is assiciated with another

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.