i want to insert values into a table select one field value from other table
(want to write select statement into insert statement but not knows how to
do it)
how can i implement it
the stored procedure is as given below
ALTER PROCEDURE dbo.usp_Insert
(
@.AccountName [NVARCHAR] (50)
, @.AccountSite [NVARCHAR] (50)
, @.LeadName [NVARCHAR] (50)
)
AS
BEGIN
SELECT Lead_ID into @.Lead_ID from Lead where Leadname=@.Leadname
INSERT INTO [Account]
(
[AccountName]
, [AccountSite]
, [Lead_ID]
)
VALUES
(
@.AccountName
, @.AccountSite
, @.Lead_ID
)
RETURN (@.@.IDENTITY)
END
ALTER PROCEDURE dbo.usp_Insert
(
@.AccountName [NVARCHAR] (50)
, @.AccountSite [NVARCHAR] (50)
, @.LeadName [NVARCHAR] (50)
)
AS
BEGIN
INSERT INTO [Account] ([AccountName], [AccountSite], [Lead_ID])
SELECT @.AccountName, @.AccountSite, b.Lead_ID
FROM [Lead]
WHERE [LeadNane] = @.Leadname
RETURN SCOPE_IDENTITY()
END
Andrew J. Kelly SQL MVP
"news.microsoftnews" <sapk81@.yahoo.com> wrote in message
news:erADAHSrEHA.332@.TK2MSFTNGP14.phx.gbl...
> i want to insert values into a table select one field value from other
table
> (want to write select statement into insert statement but not knows how to
> do it)
> how can i implement it
> the stored procedure is as given below
> ALTER PROCEDURE dbo.usp_Insert
> (
> @.AccountName [NVARCHAR] (50)
> , @.AccountSite [NVARCHAR] (50)
> , @.LeadName [NVARCHAR] (50)
>
> )
>
> AS
> BEGIN
> SELECT Lead_ID into @.Lead_ID from Lead where Leadname=@.Leadname
> INSERT INTO [Account]
> (
> [AccountName]
> , [AccountSite]
> , [Lead_ID]
> )
> VALUES
> (
> @.AccountName
> , @.AccountSite
> , @.Lead_ID
> )
> RETURN (@.@.IDENTITY)
> END
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment