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.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Dynamic SQL?

Author  Topic 

sqldba20
Posting Yak Master

183 Posts

Posted - 2008-01-30 : 14:34:53
Folks:

I would like to know from this function whether the SET command is used a Dynamic SQL? If so, will it have any IO impact on the server? The reason I ask is because I see IO wait for this function.


CREATE FUNCTION fnGenUseGetSDSVal(@asofdate DATETIME, @secid INT,
@propertyid INT)
RETURNS VARCHAR(255)
AS
BEGIN
DECLARE @return VARCHAR(255)
DECLARE @maxasofdate DATETIME
IF (SELECT PropertyType
FROM Analysis..tblPropertyMaster
WITH (NOLOCK)
WHERE PropertyID = @propertyid) = 'SecConstant'
BEGIN
SET @maxasofdate = (SELECT max(AsOfDate)
FROM tblSecDataStr
WITH (NOLOCK)
WHERE SecID = @secid AND PropertyID = @propertyid)
END
ELSE
BEGIN
SET @maxasofdate = (SELECT max(AsOfDate)
FROM tblSecDataStr
WITH (NOLOCK)
WHERE SecID = @secid AND PropertyID = @propertyid AND
AsOfDate <= @asofdate)
END

SET @return = (SELECT PropertyValue
FROM Analysis..tblSecDataStr SDS
WITH (nolock)
WHERE SDS.SecID = @secid AND SDS.PropertyID = @propertyid AND
SDS.AsOfDate = @maxasofdate)
RETURN @return
END




Thanks !
   

- Advertisement -