473,385 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

sql query for store procedure

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 1231
Rabbit
12,516 Expert Mod 8TB
I have no idea what your question is. Please try to explain in more detail.
Sep 15 '14 #2
Frinavale
9,735 Expert Mod 8TB
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
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
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
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
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
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
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
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
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
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.