Regarding Count through

Posted by Gopal_nivas under Sql Server on 9/13/2010 | Points: 10 | Views : 1112 | Status : [Member] | Replies : 1

i was created a table named "contacts"..

in tat contact table i have a column called "createdby"

then if a admin can create a new contact info. those details will be inserted and the created by column have the value user name or id..

in that the login user can create new user i.e) user regsitration to login..

the registerd user details are inserted into another table..

and also i have maintaining another table called "user_reg"

in tat table i have 3 columns namely "id","adminid","userid"

here i want to "count" the contact info. according to "createdby" column value..

that is..

contact table:

id name Addre createdby
1 raj ss admin
2 ram ww a
3 john rr b

user_reg table
id adminid userid
1 0 1
2 0 2

id name pw
0 admin admin
1 a a
2 b d

the admin and its users can able to insert contact info upto 100 only..

so i am taking the count of admin and those users are created by admin tat count also i am going to take..

so if tot1l=100 then nobody (admin and its users cant able to insert contacts) and simultaneously for other users..

so how to achieve this..

need ur suggestions..



Posted by: T.saravanan on: 9/13/2010 [Member] [MVP] Silver | Points: 25

Hi Gopal,

Using Procedure you can achieve your output easily.

In Your Procedure,
Here Pass @sAdminId --> your Login User Id

Declare @nCount int
Set @nCount =(select count(id) from user_reg where createdby =@sAdminId)
If(@nCount <100)
Insert Statement // Its for your insert statement
return false // Its for your message

If any doubt ask to me.

Cheers :)


Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response