TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
suresh s
NA
37
175.7k
Insert Query with Sub Query
Sep 29 2008 3:22 PM
Hi: I am using
Login,Userdetails tables in which UserID is common for both tables.UserId is Primary key for Login .UserId is not a Foreign Key for Userdetails table due to it refers more than one table.
Now I have to take UserId from Login table then insert into Userdetails table along with some other parameters.I have writtern procedure but i got some error.Procedure and the Error has Mentioned below.
Procedure:
ALTER PROCEDURE [dbo].[DAMS_SP_InsertUserDetails]
AS
BEGIN
DECLARE @sqlinsert varchar(100),
@UserId as bigint,
@UserName as varchar(25),
@FirstName as varchar(100),
@LastName as varchar(100),
@DateOfBirth as datetime,
@StreetAddress1 as varchar(1000),
@StreetAddress2 as varchar(1000),
@City as varchar(250),
@State as varchar(250),
@CountryId as int,
@Email as varchar(250),
@PhoneNo as varchar(25),
@MobileNo as varchar(25),
@FaxNo as varchar(25),
@EmailDigestFrequency as char(25),
@AreaOfInterest as int,
@InvoiceDeliveryMethod as varchar(25)
SET NOCOUNT ON;
SET @sqlinsert=''
SET @sqlinsert=@sqlinsert+'SELECT UserId FROM DAMS_Tbl_UsersLogin WHERE UserName='''+@UserName+''''
EXEC @sqlinsert
INSERT INTO DAMS_Tbl_RegisteredUsers(UserId,FirstName,LastName,DateOfBirth ,StreetAddress1 ,StreetAddress2 ,
City,State ,CountryId ,Email ,PhoneNo,MobileNo,FaxNo ,EmailDigestFrequency,AreaOfInterest ,InvoiceDeliveryMethod )VALUES
(@sqlinsert ,@FirstName,@LastName,@DateOfBirth ,@StreetAddress1 ,@StreetAddress2 ,@City,@State ,@CountryId ,@Email,
@PhoneNo,@MobileNo,@FaxNo ,@EmailDigestFrequency,@AreaOfInterest ,@InvoiceDeliveryMethod )
END
Error:
Generally I got the Error
" Parameter is not supplied"
Can any one send me query to solve this issue plz. its very urgent.
suresh
Reply
Answers (
1
)
How to create server reports in sqlserver 2005
Creating a Drop down list in SQL Express