Local cstr, svr, spName Clear Close Tables All cstr = "Driver={SQL Native client};Server=(local);Database=AWS2W;Trusted_Connection=Yes" svr = Sqlstringconnect(cstr) If svr > 0 If Not Directory("StoredProcedures") Md "StoredProcedures" Endif TEXT TO Cmd TEXTMERGE NOSHOW PRETEXT 15 select cast(c.text as text) pText, p.name pName, p.object_id from sys.procedures p inner join sys.syscomments c on p.object_id = c.id order by p.object_id, c.colid ENDTEXT = SQLExec(svr,cmd,'sp') If Reccount('sp') > 0 lastobj = -99999 cText = "" spName = "**" Scan Scan While sp.object_id = lastobj cText = cText + pText Endscan If spName <>"**" cText = STRTRAN(cText,"create procedure ","Alter Procedure ",1,1,1) = Strtofile(Alltrim(cText),"StoredProcedures\"+Forceext(spName,"sql")) Endif lastobj = sp.object_id cText = pText spName = pname Endscan Endif Endif SQLDisconnect(0)I am using the tSQL cast functin to accomplish the unicode conversion.
>Local cstr, svr, spName >Clear >Close Tables All >cstr = "Driver={SQL Native client};Server=(local);Database=AWS2W;Trusted_Connection=Yes" >svr = Sqlstringconnect(cstr) >If svr > 0 > If Not Directory("StoredProcedures") > Md "StoredProcedures" > Endif > = SQLExec(svr,"sp_Stored_Procedures null,'dbo'","sp") > If Reccount('sp') > 0 > Index On Procedure_name Tag pn Desc > Locate > Scan > spName = Left(Procedure_name,At(";",Procedure_name)-1) > TEXT TO Cmd TEXTMERGE NOSHOW PRETEXT 15 > SELECT RTRIM(text) ttext FROM syscomments where text like > '%<<ALLTRIM(spName)>>%' and texttype = 2 > ENDTEXT > If SQLExec(svr,Cmd, "spText") > -1 > = Strtofile(ALLTRIM(STRCONV(tText,10)),"StoredProcedures\"+Forceext(spName,"sql")) > Endif > Endscan > Endif >Endif >SQLDisconnect(0) >>