Posted by jennifer1970 on 02/27/06 22:56
One way would be this:
Declare @sQry nvarchar(500)
Declare @sWhere nvarchar(500)
Set @sWhere = ' '
set @AcctCode = 'ABC'
Set @sQry =
'Select AcctCode, SubAcct ' +
'From GLDetails ' +
'Where SubAcct <> '' '''
If @AcctCode <> '*'
Set @sWhere = @sWhere + 'and AcctCode = ''' + @Acctcode + ''''
If @SubAcct <> '*'
Set @sWhere = @sWhere + 'and SubAcct = ''' + @SubAcct + ''''
Set @sQry = @sQry + @sWhere
EXEC sp_executesql @sQry
Navigation:
[Reply to this message]
|