November 2, 2006 at 5:20 am
I don't know if the code I'm posting is enough, someone a while ago gave me the following code, basically it prints into a listbox the text from a stored procedure :-
sql = "select" & _
" text" & _
" from" & _
" syscomments where id in (select id from sysdepends where depid=" & lsttables.itemdata(i) & ")" & _
" and" & _
" id not in(select constid from sysconstraints where id =" & lsttables.itemdata(i) & ")"
Set rs5 = cn.Execute(sql)
If rs5.RecordCount > 0 Then
While Not rs5.EOF
List1.AddItem rs5("text")
rs5.MoveNext
wend
unfortunatly it does print all of it instead of getting
CREATE PROCEDURE spAdd_Memo @sMemo as VarChar(200), @sDate as VarChar(200),@sEnddate as varchar(200)
AS
INSERT INTO [Reminder] ([Date], [Reminder],[enddate])
VALUES
(@sDate,@sMemo,@sEnddate)
GO
I get
CREATE PROCEDURE spAdd_Memo @sMemo as VarChar(200), @sDate as VarChar(200),@sEnddate as varchar(200)
AS
INSERT INTO [Reminder] ([Date], [Reminder],[enddate])
VALUES
(@sDate,@sMemo,@sEnddate)
missing the final line ie GO
can someone tell me what's wrong please, I'm still new to SQL, many thanks in advance
November 2, 2006 at 6:16 am
Look at the query results in QA. The go is NOT SAVED in the table. You'll have to put one manullay if you need it.
November 2, 2006 at 6:29 am
it's not just Go that get's missed, I tried it again on another SP and I go
CREATE PROCEDURE spDeleteReminder @sMemo as VarChar(200),@sDate as varchar (200)
AS
instead of
CREATE PROCEDURE spDeleteReminder @sMemo as VarChar(200),@sDate as varchar (200)
AS
DELETE FROM [reminder] WHERE [reminder] = @sMemo and [date] = @sDate
GO
November 2, 2006 at 6:56 am
IS it possible that the text is in th elistbox, but not visisble to you?
Also do you have obejcts that containt more than 4000 characters (they will be saved in 2+ rows in syscomments).
November 2, 2006 at 7:08 am
I think the short answer to both questions is no, I used a debug.print to see if the text was there but hidden.
November 2, 2006 at 7:21 am
This works fine for me :
Sub a()
Dim sql As String
Dim rs5 As ADODB.Recordset
Set rs5 = New ADODB.Recordset
sql = "select" & _
" text" & _
" from" & _
" syscomments where id in (select id from sysdepends where depid=object_id('Client'))" & _
" and" & _
" id not in(select constid from sysconstraints where id =object_id('Client'))"
Set rs5 = MyCn.Execute(sql)
If rs5.RecordCount > 0 Then
While Not rs5.EOF
Debug.Print rs5("text")
Debug.Print "GO" & vbCrLf
rs5.MoveNext
Wend
End If
End Sub
Don't know what else to try !
November 2, 2006 at 7:34 am
I am at a loss, it's not just the fact that "GO" doesn't get printed, it's that sometimes whole lines get missed of too, I've even printed off quite large SP's but always minus 1 or 2 lines off the bottom, I don't think it's a character limit that's doing it.
Thanks anyway for trying
November 2, 2006 at 7:57 am
What results are you getting if you run the same queries from Query analyser?
November 2, 2006 at 8:08 am
I've not been able to get it to work at all in the QA
November 2, 2006 at 8:13 am
Try this :
select text from dbo.syscomments where id in (select id from sysdepends where depid = object_id('OneTableNameHere')) and id not in(select constid from sysconstraints where id =object_id('OneTableNameHere'))
Just supply one of your tables in the 2 spots with ''OneTableNameHere''.
November 2, 2006 at 8:32 am
That appears to work, so what is the difference? by the way, I'm very grateful for your patience
November 2, 2006 at 8:33 am
That appears to work, any idea why? thanks again for your patience
November 2, 2006 at 8:46 am
There are no difference in the select statement part. Only the tools to display the data changed. I wanted to make sure that the query returned the correct results!
Can you try concatenating the data to a big textbox to see if everything gets printed there?
November 2, 2006 at 8:49 am
I've alread tried that, but no luck
November 2, 2006 at 9:06 am
Short of going to your workplace I see nothing else I can do.
Good luck finding the solution to that problem .
Viewing 15 posts - 1 through 15 (of 20 total)
You must be logged in to reply to this topic. Login to reply