question

hemasingamsetty avatar image
hemasingamsetty asked

what is the error in the following storedprocedure

alter procedure sp_pubhol @currentdate DateTime as begin set @currentdate = select CONVERT(date,GETDATE()) select Holiday_Name from Holiday where Holiday_On = @currentdate end
sql-server-2008-r2
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
mjharper avatar image
mjharper answered
Hi The first thing I can see is that this : set @currentdate = select CONVERT(date,GETDATE()) should be set @currentdate = CONVERT(date,GETDATE()) or set @currentdate = (select CONVERT(date,GETDATE())) does that sort out the issue?
6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hemasingamsetty avatar image hemasingamsetty commented ·
Procedure or function 'sp_pubhol' expects parameter '@currentdate', which was not supplied. this is d error i am getting
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
That means the procedure is compiling correctly, but you're not passing it a value when you execute it. You should be something like: exec dbo.sp_pubhol @currentdate = '1/1/2013' or exec dbo.sp_pubhol '1/1/2013'
0 Likes 0 ·
hemasingamsetty avatar image hemasingamsetty commented ·
set @currentdate = select CONVERT(date,GETDATE())here i am assigning today's date & i am passing that variable..otherwise can i use directly select Holiday_Name from Holiday where Holiday_On = CONVERT(date,GETDATE())
0 Likes 0 ·
hemasingamsetty avatar image hemasingamsetty commented ·
alter procedure sp_pubhol as begin select Holiday_Name from Holiday where Holiday_On = CONVERT(date,GETDATE()) end when i execute sp_pubhol , i am facing the following issue... Invalid object name 'Holiday' pls suggest me what should i do
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
What schema owns the table Holiday? You're not defining it and if it's a different schema than your default, you may not be seeing it.
0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.