存储过程是:
CREATE PROC myproc2
@m1 char
as
select * from sal_plancomc
where ax003 like '2004%' and ax020 =@m1
GO2004是一个字符串,我想再加一个参数@m2来代替2004,
这个存储过程该怎么写呢?也就是在"where ax003 like '(@m2) %' "这里该怎么写呢?
CREATE PROC myproc2
@m1 char
as
select * from sal_plancomc
where ax003 like '2004%' and ax020 =@m1
GO2004是一个字符串,我想再加一个参数@m2来代替2004,
这个存储过程该怎么写呢?也就是在"where ax003 like '(@m2) %' "这里该怎么写呢?
CREATE PROCEDURE Pr_FunctionUpdateSort
@TopSort int ,@MidItem varchar(20), @TrailSort int OUTPUT
WITH ENCRYPTIONAS
declare @tempID varchar(20) ,@tempSort int DECLARE myCursor CURSOR FOR
select s.FunctionID ,s.Sort from [functions] as c ,[functions] as s where PATINDEX( c.Path+'%' ,s.Path)>0 and c.FunctionID=@MidItem and (s.Depth - c.Depth )>=0 order by s.Sort asc OPEN myCursor
FETCH NEXT FROM myCursor INTO @tempID, @tempsort
WHILE @@FETCH_STATUS = 0
BEGIN
update [functions] set Sort= @TopSort where FunctionID = @tempID set @TopSort=@TopSort+ 1
FETCH NEXT FROM myCursor INTO @tempID, @tempsort
END
CLOSE myCursor
DEALLOCATE myCursor
set @TrailSort=@TopSort
create procedure Pr_GetRegion
@Item varchar(30),
@Value varchar(30),
@IsLock int
WITH ENCRYPTION
as
Begin
declare @Sql as nvarchar(500) set @Sql=N' select distinct r.RegionID,''<img height=1 src=../images/space.gif width=''+ convert(nvarchar(20),20 * r.depth) + ''>'' + r.Names Names ,r.sort '
set @Sql=@Sql + N' from Regions as r inner join FatherAndSonRegion as fs on(r.RegionID=fs.SonRegion) inner join Regions as s on(s.RegionID=fs.FatherRegion) where r.IsLock='+ cast(@IsLock as varchar(1))
if @Item<>''
set @Sql=@Sql+N' and s.'+@Item+' like ''%' + @value+'%'''
set @Sql=@Sql+N' order by r.sort asc ' exec sp_executesql @Sql
end