I have used joins to get data from two tables under common name, as
SELECT userValidity.UserName, userValidity.ValidFrom,userValidity.ValidUpTo,userValidity.TotalPoints,
persons.SenderID
FROM userValidity
INNER JOIN persons
ON userValidity.Username=tbl_persons.Username
But I need to execute this query with only the username which I pass as parameter in stored procedure..
How to pass the username in stored procedure in this joins.
alter procedure GetNameIDUserInformation
(
@user varchar(max)
)
as
begin
SELECT userValidity.UserName, userValidity.ValidFrom,userValidity.ValidUpTo,userValidity.TotalPoints,
persons.SenderID
FROM userValidity
INNER JOIN persons
ON userValidity.Username=tbl_persons.Username
end
In this SP, where I have to pass the user parameter to get the single row of my user record?
What happens if you just add
WHERE userValidity.Username=userto the query? :If you get a syntax error around
user, consider using a different name, asuseris a reserved keyword in some RDBMSes.