-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Gogi7735
Message 1 in Discussion


hi,
In one of my 
SQL Server Trigger , I am doing is 
getting the primary key(s) of the  
table by calling sp_pkeys  by passing the table name and  insert the data  return by 
SP_PKEYS  in to a temp 
table  #TPKEYS ( i have create 
temporary table)   , i am getting the primary  key  cloumn name using  SELECT 
COLUMN_NAME FROM  #TPKEYS  and 
assign that value to @V_KEY1 .i need to use this   @V_KEY1 value to 
get the inserted value from inserted table and assign in to a variable 
@V_DATAKEY ,the statement is  SELECT @V_KEY1  FROM  
INSERTED  ,but i am not getting the inserted value for the column value 
contained in @V_KEY1 in the variable  
@V_DATAKEY 
 i tried with both the options to get the inserted value 

with out any success.What is the mistake i am doing?
the code as 
follows 
 --Getting the 
primary key column name from this 
stmt

SET @V_KEY1 = (SELECT 
COLUMN_NAME FROM  #TPKEYS ) 
--i need to get the value inserted for the primary key 
column ,for that i am using this stmt,i feel some thing wrong i am doing 
here..
SET @V_DATAKEY = (SELECT @V_KEY1  FROM  INSERTED 
) 
if i am 
printing   @V_DATAKEY  , i am getting 
only the column name but not the value
 
How to get the 
primary key value from inserted table as i know the primary  key column 
name. 
Regards
-Srini

 



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to