Showing posts with label asimple. Show all posts
Showing posts with label asimple. Show all posts

Thursday, February 16, 2012

can I return output from stored procedure into an HTA to display in browser?

Hi all. I have a stored procedure on my sql server that returns a
simple informtation about that tim a database was backed up. I owuld
like to create an HTA that operator types can look at to make sure
that the backups finished, can someone help me do this?

The stored procedure in called sp_lastback and the output looks like
this:

database days since backup timestamp of backup
dbase1 0 2004-10-14 00:41:21.000
dbase2 0 2004-10-14 00:08:36.000
dbase3 1 2004-10-13 22:46:57.000

Can this be done? If someone could help me with this simple problem, I
could probably reuse the same method a 100 useful ways.

Thanks in advance!"sumGirl" <emebohw@.netscape.net> wrote in message
news:a5e13cff.0410141529.23a19fd8@.posting.google.c om...
> Hi all. I have a stored procedure on my sql server that returns a
> simple informtation about that tim a database was backed up. I owuld
> like to create an HTA that operator types can look at to make sure
> that the backups finished, can someone help me do this?
> The stored procedure in called sp_lastback and the output looks like
> this:
> database days since backup timestamp of backup
> dbase1 0 2004-10-14 00:41:21.000
> dbase2 0 2004-10-14 00:08:36.000
> dbase3 1 2004-10-13 22:46:57.000
> Can this be done? If someone could help me with this simple problem, I
> could probably reuse the same method a 100 useful ways.
> Thanks in advance!

You'll probably get a better response in a group for HTA users. I guess you
could write a client script to execute the procedure with ADO, then loop
over the ResultSet and build the .hta file dynamically, but I have no idea
about any details.

Simon|||Here's a generic technique to render a resultset using dynamic html. There
may be better ways to accomplish the task, though.

<html>
<head>
<body>
<Script Language="VBScript"
Sub btnListBackups_OnClick()

Set oConnection = CreateObject("ADODB.Connection")

oConnection.Open "Provider=SQLOLEDB" & _
";Data Source=" & "DBDELTA1" & _
";Integrated Security=SSPI"

Set recordSet = oConnection.Execute("EXEC tempdb..sp_lastback")
myResultTable = "<table border=""1"">"
myResultTable = myResultTable & "<tr>"
For i = 0 To recordSet.Fields.Count - 1
myResultTable = myResultTable & _
"<th>" & _
recordSet.Fields(i).Name & _
"</th>"
Next
myResultTable = myResultTable & "</tr>"
Do While Not recordSet.EOF
myResultTable = myResultTable & "<tr>"
For i = 0 To recordSet.Fields.Count - 1
myResultTable = myResultTable & _
"<td>" & _
recordSet.Fields(i).Value & _
"</td>"
Next
myResultTable = myResultTable & "</tr>"
recordSet.MoveNext
Loop
myResultTable = myResultTable & "</table>"
recordSet.Close
oConnection.Close

Results.innerHTML = myResultTable
End Sub

</script
<input type="button" id="btnListBackups" value="List Backups">
<hr>
<nobr Id=Results></nobr>
</body>
</html
--
Hope this helps.

Dan Guzman
SQL Server MVP

"sumGirl" <emebohw@.netscape.net> wrote in message
news:a5e13cff.0410141529.23a19fd8@.posting.google.c om...
> Hi all. I have a stored procedure on my sql server that returns a
> simple informtation about that tim a database was backed up. I owuld
> like to create an HTA that operator types can look at to make sure
> that the backups finished, can someone help me do this?
> The stored procedure in called sp_lastback and the output looks like
> this:
> database days since backup timestamp of backup
> dbase1 0 2004-10-14 00:41:21.000
> dbase2 0 2004-10-14 00:08:36.000
> dbase3 1 2004-10-13 22:46:57.000
> Can this be done? If someone could help me with this simple problem, I
> could probably reuse the same method a 100 useful ways.
> Thanks in advance!|||Thanks Dan! Thats exactly the kind of example I can run with!

Tuesday, February 14, 2012

Can I release temp SQL Tables?

In Query Analyzer I am creating a Select statement using temp tables. For a
simple example:
Select abc.def into #tmptable from ABCTable.
If I make changes to the query and then rerun it, it tells me that the
object (which is the temp table) already exist in the database. I have to
close my Query Analyzer window and then reopen it.
So my question is this: Is there a command that I can include in the Query
Analyzer window that will release the Temp Table without having to close the
window?
DROP TABLE #TABLENAME
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>
|||drop table #tmptable
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>
|||Thanks everyone for the quick response.
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ejKaNaGRGHA.4920@.tk2msftngp13.phx.gbl...
> drop table #tmptable
>
> "Preacher Man" <nospam> wrote in message
> news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
>
|||and u can put a check in too :
IF OBJECT_ID ('tempdb..#testtemp') IS NOT NULL
BEGIN
DROP TABLE #testtemp
END
CREATE TABLE #testtemp (numb int)
INSERT #testtemp VALUES (1)
INSERT #testtemp VALUES (1)
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>

Can I release temp SQL Tables?

In Query Analyzer I am creating a Select statement using temp tables. For a
simple example:
Select abc.def into #tmptable from ABCTable.
If I make changes to the query and then rerun it, it tells me that the
object (which is the temp table) already exist in the database. I have to
close my Query Analyzer window and then reopen it.
So my question is this: Is there a command that I can include in the Query
Analyzer window that will release the Temp Table without having to close the
window?DROP TABLE #TABLENAME
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>|||drop table #tmptable
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>|||Thanks everyone for the quick response.
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ejKaNaGRGHA.4920@.tk2msftngp13.phx.gbl...
> drop table #tmptable
>
> "Preacher Man" <nospam> wrote in message
> news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
>|||and u can put a check in too :
IF OBJECT_ID ('tempdb..#testtemp') IS NOT NULL
BEGIN
DROP TABLE #testtemp
END
CREATE TABLE #testtemp (numb int)
INSERT #testtemp VALUES (1)
INSERT #testtemp VALUES (1)
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>

Can I release temp SQL Tables?

In Query Analyzer I am creating a Select statement using temp tables. For a
simple example:
Select abc.def into #tmptable from ABCTable.
If I make changes to the query and then rerun it, it tells me that the
object (which is the temp table) already exist in the database. I have to
close my Query Analyzer window and then reopen it.
So my question is this: Is there a command that I can include in the Query
Analyzer window that will release the Temp Table without having to close the
window?DROP TABLE #TABLENAME
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>|||drop table #tmptable
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>|||Thanks everyone for the quick response.
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:ejKaNaGRGHA.4920@.tk2msftngp13.phx.gbl...
> drop table #tmptable
>
> "Preacher Man" <nospam> wrote in message
> news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
>|||and u can put a check in too :
IF OBJECT_ID ('tempdb..#testtemp') IS NOT NULL
BEGIN
DROP TABLE #testtemp
END
CREATE TABLE #testtemp (numb int)
INSERT #testtemp VALUES (1)
INSERT #testtemp VALUES (1)
"Preacher Man" <nospam> wrote in message
news:OaUixWGRGHA.4952@.TK2MSFTNGP09.phx.gbl...
> In Query Analyzer I am creating a Select statement using temp tables. For
> a simple example:
> Select abc.def into #tmptable from ABCTable.
> If I make changes to the query and then rerun it, it tells me that the
> object (which is the temp table) already exist in the database. I have to
> close my Query Analyzer window and then reopen it.
> So my question is this: Is there a command that I can include in the
> Query Analyzer window that will release the Temp Table without having to
> close the window?
>