Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Dhanu
Starting Member
3 Posts |
Posted - 2008-03-25 : 01:50:34
|
| I am new in sqlserver UDF,I am written a UDF but it showing errorCREATE FUNCTION udf_DayOfWeek(@dtDate DATETIME)RETURNS VARCHAR(10)ASBEGINDECLARE @rtDayofWeek VARCHAR(10)SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate)WHEN 1 THEN ‘Sunday’WHEN 2 THEN ‘Monday’WHEN 3 THEN ‘Tuesday’WHEN 4 THEN ‘Wednesday’WHEN 5 THEN ‘Thursday’WHEN 6 THEN ‘Friday’WHEN 7 THEN ‘Saturday’ENDRETURN (@rtDayofWeek)ENDGOErrorIncorrect syntax near '‘'.Msg 102, Level 15, State 1, Procedure udf_DayOfWeek, Line 16Incorrect syntax near 'END'. |
|
|
Koji Matsumura
Posting Yak Master
141 Posts |
Posted - 2008-03-25 : 01:59:39
|
| Use Single Quote,‘Sunday’ should be 'Sunday' |
 |
|
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-03-25 : 02:02:07
|
| Try this,CREATE FUNCTION udf_DayOfWeek(@dtDate DATETIME)RETURNS VARCHAR(10)ASBEGINDECLARE @rtDayofWeek VARCHAR(10)SET @rtDayofWeek = CASE DATEPART(weekday,@dtDate)WHEN 1 THEN 'Sunday'WHEN 2 THEN 'Monday'WHEN 3 THEN 'Tuesday'WHEN 4 THEN 'Wednesday'WHEN 5 THEN 'Thursday'WHEN 6 THEN 'Friday'else 'Saturday'ENDRETURN (@rtDayofWeek)ENDGOit didnt work initially as it could not recognize your quotes used (i.e)'‘'. |
 |
|
|
Dhanu
Starting Member
3 Posts |
Posted - 2008-03-25 : 02:02:16
|
quote: Originally posted by Koji Matsumura Use Single Quote,‘Sunday’ should be 'Sunday'
Thnks For your report |
 |
|
|
|
|
|