Announcements
Hi,
i have example like bellow :
insert_recordset TmpTable (ID,Name,CurrentUserId)
select ID,Name, curUserId()
from SourceTable;
how i can use curUserId() in this statement just i need to take current user id in all records which is inserted into the temp table ,
*This post is locked for comments
You are using it all wrong.
If you want to extract user id from any table then acquire that field in "userId" EDT.
In your case, it looks like that you want to store the current user id in your table named TmpTable. In order to use curUserId(), you need to store it into some variable and then insert it.
"insert_recordset" is a good way for bulk insertion but has a limitation that you cannot manipulate your data while insertion which in your case is necessary.
You could get answers for majority of your questions using the MSDN documentation and various blogs, please rely on search engines more in the future.
See example 3 for insert_recordset operation in the documentation:
msdn.microsoft.com/.../aa635694.aspx
You could assign it to a variable first.
André Arnaud de Cal...
293,296
Super User 2025 Season 1
Martin Dráb
232,093
Most Valuable Professional
nmaenpaa
101,156
Moderator