تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] كيف أستخدم دالة معرفة مسبقاً ضمن الاستعلام؟
#5
اذا كنت تريد استخدامه لعملية تعديل سجلات الجدول فهذا استعلام  :

PHP كود :
DECLARE @x int;
set @x= (Select ROW_NUMBER() OVER(ORDER BY (SELECT 1)))
DECLARE @
TBooksNames TABLE (id intChrCol nvarchar(255));
insert into @TBooksNames(id,ChrCol)values(@x,(CHAR(243)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,(CHAR(240)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,(CHAR(245)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,(CHAR(246)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,(CHAR(242)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,(CHAR(241)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,(CHAR(248)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,(CHAR(250)))
set @+= 1
insert into 
@TBooksNames(id,ChrCol)values(@x,'ال')
DECLARE @
End int,@CharXT nvarchar(255);
set @End =(Select count(*) from @TBooksNames);
set @x=1;
WHILE @
< @End
begin
    set 
@CharXT=(select ChrCol from @TBooksNames where id=@x);
    
update @TBooksNames set ChrCol=REPLACE(ChrCol ,@CharXT ,'X'where id=@x;
    
set @+=1;
end;
Select from @TBooksNames

ملاحظة :
تستطيع استبدال الجدول الوهمي بجدول حقيقي بقاعدة البيانات و هذا يختصر الكود بشكل كبير و لا يبقى منه الا القليل مع اطيب امنياتي لك بالتوفيق و النجاح انشاء الله .
الرد }}}


الردود في هذا الموضوع
RE: كيف أستخدم دالة معرفة مسبقاً ضمن الاستعلام؟ - بواسطة asemshahen5 - 02-11-20, 09:23 PM


التنقل السريع :


يقوم بقرائة الموضوع: