Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
programer
Posting Yak Master
221 Posts |
Posted - 2010-08-02 : 12:56:55
|
Hi,My code:ALTER PROCEDURE dbo.Select_Customer ( @UserId varchar(100), @PaymentType varchar(100), @PaymentId varchar(100), @AttributeName varchar(100), @Value varchar(100) ) AS BEGIN INSERT INTO dbo.tbl_Payment (UserId, PaymentType ) VALUES (@UserId, @PaymentType);SET IDENTITY_INSERT tbl_Payment ON; INSERT INTO dbo.tbl_PaymentDetails (PaymentId, AttributeName, Value ) VALUES (@PaymentId(), @AttributeName, @Value);END;How the information in Table tbl_Payment - COLUMN: UserId (primary key) save to data another table tbl_PaymentDetails - PaymentId column (varchar).Thanks. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-02 : 13:03:00
|
look for SCOPE_IDENTITY() No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
programer
Posting Yak Master
221 Posts |
Posted - 2010-08-02 : 13:06:19
|
quote: Originally posted by webfred look for SCOPE_IDENTITY() No, you're never too old to Yak'n'Roll if you're too young to die.
Yes, but this is not work:ALTER PROCEDURE dbo.Select_Customer ( @UserId varchar(100), @PaymentType varchar(100), @PaymentId varchar(100), @AttributeName varchar(100), @Value varchar(100) ) AS BEGIN INSERT INTO dbo.tbl_Payment (UserId, PaymentType ) VALUES (@UserId, @PaymentType);SET IDENTITY_INSERT tbl_PaymentDetails ON; INSERT INTO dbo.tbl_PaymentDetails (PaymentId, AttributeName, Value ) VALUES (SCOPE_IDENTITY(), @AttributeName, @Value);END;Please help! |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-02 : 13:12:19
|
Any error message? No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2010-08-02 : 14:31:50
|
Could you post the DDL of dbo.tbl_Payment and dbo.tbl_PaymentDetails. ? I need to know whether you have a column on dbo.tbl_PaymentDetails that has an identity property, Jack Vamvas--------------------http://www.sqlserver-dba.com |
|
|
programer
Posting Yak Master
221 Posts |
Posted - 2010-08-02 : 15:50:06
|
quote: Originally posted by jackv Could you post the DDL of dbo.tbl_Payment and dbo.tbl_PaymentDetails. ? I need to know whether you have a column on dbo.tbl_PaymentDetails that has an identity property, Jack Vamvas--------------------http://www.sqlserver-dba.com
Now it works!My code: INSERT INTO dbo.tbl_Payment (UserId, PaymentType ) VALUES (@UserId, @PaymentType);SET IDENTITY_INSERT tbl_Payment ON; INSERT INTO dbo.tbl_PaymentDetails (PaymentId, AttributeName, Value ) VALUES (SCOPE_IDENTITY(), @AttributeName, @Value); |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|