473,513 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql query for store procedure

2 New Member
i have four table
table user info = there are 6 columns one is primary key
tables user roles = two columns one is primary key
table user dep = two fields one is primary key
table user profile = there are four fields one is primary key
others fields are foreign keys(table info,table roles,table dep)

questions is of which table we have to make a store procedure and what is query for that
i wrote for table info m right or not
Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [USERINFORMATION]
  2. @Id int
  3. ,@LogInName varchar(50)
  4. ,@FirstName varchar(50)
  5. ,@LastName varchar(50)
  6. ,@EmailAddress varchar(50)
  7. ,@Password varchar(50)
  8.  
  9. AS
  10. BEGIN
  11. INSERT 
  12. INTO [tUserInfom]
  13. (
  14. Id
  15. ,LogInName
  16. ,FirstName
  17. ,LastName
  18. ,EmailAddress
  19. ,Password
  20. )
  21. VALUES
  22. (
  23. @Id
  24. ,@LogInName
  25. ,@FirstName
  26. ,@LastName
  27. ,@EmailAddress
  28. ,@Password
  29. )
  30. END
Sep 15 '14 #1
2 1233
Rabbit
12,516 Recognized Expert Moderator MVP
I have no idea what your question is. Please try to explain in more detail.
Sep 15 '14 #2
Frinavale
9,735 Recognized Expert Moderator Expert
Stored procedures are not associated with any database tables. They are just procedures that exist in the database that do "Things". The things that they do might involve one table, several tables or no tables at all.

The stored procedure you posted simply inserts a record into the tUserInfom table; however it should probably be expanded upon to also insert rows into the other 3 tables that depend on the record inserted....

For example:
Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE PROCEDURE [USERINFORMATION]
  3. @Id int
  4. ,@LogInName varchar(50)
  5. ,@FirstName varchar(50)
  6. ,@LastName varchar(50)
  7. ,@EmailAddress varchar(50)
  8. ,@Password varchar(50)
  9.  
  10. AS
  11. BEGIN
  12.  
  13. INSERT INTO [tUserInfom] (Id,LogInName,FirstName,LastName,EmailAddress,Password)
  14. VALUES (@Id,@LogInName,@FirstName,@LastName,@EmailAddress,@Password);
  15.  
  16. Insert Into tUserRoles (RoleID, UserID) Values("ViewContent",@ID);
  17.  
  18. --....etc....--
  19.  
  20. END
Sep 16 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
541
by: Alessandro | last post by:
Hi, here is the problem... I must create a store procedure that do the following... 1. select id_name,...'some other field' from table 'data' where 'criteria' = @parameter 2. use the result...
1
2346
by: TARUN | last post by:
Hello All I get stuck in one problem , Please help me and excuse me on the poor Knowledge in SQL Server Store procedure Q1...I want to return a string type value from store procedure , Is it...
6
2711
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like...
0
1667
by: zhenyuandeng | last post by:
Hi, When i call the procedure sp_jysczld_new from the Query Analyzer, it runs slowly. But when i extract the sql scripts from the procedure sp_jysczld_new, it runs quickly. Why? I don't...
11
4346
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
4
2576
by: ipez75 | last post by:
Hello everyone, I have a web application written in asp 6.0, my problem is that I execute a sql server store procedure and I get an empty recordset, while executing the same sp on query anlyzer I...
0
1911
by: ramuygl | last post by:
want to create store procedure that. want to send the table name as argument and retrive the data of that argument. and want to store data in temperary table using the insert query. HERE I AM...
0
1148
by: asifNewbie | last post by:
I have created table like this... CREATE TABLE INVOICEMASTER(INVOICEID INT IDENTITY(1,1),EXPORTER_REF INT,CONSIGNEE_REF INT,BUYER_REF INT,AGENT_REF INT,INVOICENO VARCHAR(20),INVOICEDATE...
1
1346
by: poonamt | last post by:
Hello Friends, I created web application in .net using C# where i created parameterized store procedure for join query but its showing me same result for different parameter in .net but when i...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.