Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


save varible in procedure


save varible in procedure

Author
Message
andy.aloys
andy.aloys
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 17
hi,

i have problem with my storeprocedure :

ALTER PROCEDURE [dbo].[sp_createdate2]
@username AS VARCHAR(20)
AS
BEGIN

DECLARE @FirstTable TABLE (id INT IDENTITY NOT NULL PRIMARY KEY,userid INT,tgl DATE,masuk time,pulang time,shift INT,timein TIME,timeout TIME,telat int,psw int,status varchar(20))

DECLARE @aa as VARCHAR(6)
set @aa = 'select absen_id from DB_TU.dbo.pokok where USER_NAME = '+ @username +''
exec @aa

INSERT INTO @FirstTable
SELECT (select absen_id from DB_TU.dbo.pokok where USER_NAME = @username ),tdate,'','','','','','','','' from temp_date where tdate <=GETDATE() and DATEPART(weekday, tdate) not in (1,7)

update a
set shift = b.num_of_run_id
from @FirstTable a
inner JOIN
(
select top 100000 userid,num_of_run_id,startdate,enddate from USER_OF_RUN where userid = @aa order by order_run desc
) as b
on a.userid = b.userid and a.tgl >= convert(date,b.startdate ,103) and a.tgl <= convert(date,b.enddate ,103)

select * from @FirstTable

END



when execute there is error :
[Err] 42000 - [SQL Server]Could not find stored procedure 'select'.


thanks,
ChrisM@Work
ChrisM@Work
SSCrazy Eights
SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)

Group: General Forum Members
Points: 8997 Visits: 19028
EXEC(@aa)



There are a number of errors in this stored procedure - would you be interested in knowing what they are?

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search