Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

save varible in procedure Expand / Collapse
Author
Message
Posted Tuesday, August 14, 2012 10:35 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 13, 2013 9:04 PM
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,
Post #1345128
Posted Wednesday, August 15, 2012 2:01 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:59 AM
Points: 7,180, Visits: 13,632
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
Post #1345150
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse