Hello,
Does anyone know how to return the name of all the databases except the system databases on a server for SQL Server 2005?
Thank you
select * from sys.databases where database_id not in (1, 2, 3, 4)
|||Thank you!Hello,
Does anyone know how to return the name of all the databases except the system databases on a server for SQL Server 2005?
Thank you
select * from sys.databases where database_id not in (1, 2, 3, 4)
|||Thank you!MS SQL 2000:
I can retrieve "host" name of the current connection from "sysprocesses" system table(select host from sysprocesses). But is it possible to get the IP address of the client connection instead of host?
I could not find any stored procedures or extended procedures that would let me retrieve such information.
thank you in advance.
Hi,
there is no such call AFAIK. But you can use the follwing procedure to evaluate your IPAdress:
CREATE PROCEDURE getIPAdress
(
@.Hostname VARCHAR(255)
)
AS
SET NOCOUNT ON
CREATE TABLE #Results
(
Results VARCHAR(4000)
)
DECLARE @.Commandstring VARCHAR(300)
SET @.Commandstring = 'ping ' + @.Hostname
INSERT INTO #Results
EXEC master..xp_cmdshell @.Commandstring
Select DISTINCT SUBSTRING(Results,12,CHARINDEX(':',Results)-12) AS HostIpAdress from #Results
Where Results LIKE 'Reply From%'
DROP TABLE #Results
GO
In SQL Server 2005, you can sure use a more sophisticated method of .NET.
HTH, jens Suessmeyer.
http://www.sqlserver2005.de
|||Thank you for the response.IN 2005 you can try:
select * from sys.dm_exec_connections
This will give you the IP Address of any TCP/IP connections.
Louis
|||Thank you for also giving the solution for SQL Server 2005.
I am downloading and about to give SQL Server Express 2005 a try just for that functionality.
Great opportunity to move toward SQL Server 2005 if it works out :)
*** EDIT ***
I have installed SQL Server 2005 and tried out the query and it worked as I wanted. :)
I've got a module that contains the following function.
Imports System.Data.SqlClient
Module SQL_Sprocs
Function ListUsers()
Dim conn As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("DBConn"))
Dim cmd As SqlCommand = New SqlCommand("list_users", conn)
cmd.CommandType = CommandType.StoredProcedure
conn.Open()
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
ListUsers = dr
dr.Close()
conn.Close()
End Function
End Module
I then want to call this function from my webform. So I'm using the following
Dim dr As SqlClient.SqlDataReader
dr = Timetracker.SQLProcs.ListUsers()
Do While dr.Read
Label1.Text &= dr("first_name") & " " & dr("last_name") & ", "
Loop
dr.Close()
But it's not working. I want to have a module that contains all my sprocs and be able to call them from the individual webpages.
What am I doing wrong?
LbobIt's also private.
You're returning a closed data reader.
dr = cmd.ExecuteReader
ListUsers = dr
dr.Close()
conn.Close()
-------
and you should never break apart the datalayer, and require a reader object to be return back to the primary worker process.
ghetto code.|||Can someone tell me then what I should do with stored procedures that get called from multiple places? In our current app we have a sql_procs.asp which contains all of them, we then use include on the required page and return the recordset.
Any ideas??|||You should never return a data reader to a presentation component, it keeps the connection open until you close, as you've just discovered. If you're looking for a simple solution I'd used a DataSet instead.
I have a package that processes a flat file, which is generated by a separate system each weekday around 3:30AM. I would like my package to store the timestamp of the input file and compare it to the timestamp of the next day's file. If they are the same, then the package can exit without reprocessing a particular file again.
So, my first question is whether a package variable can be updated so that its value will persist from one run to the next?
Second, what is the syntax to retrieve the file's timestamp, either directly from the file connection manager or within a script task?
Thanks,
Phil
Philsky wrote:
I have a package that processes a flat file, which is generated by a separate system each weekday around 3:30AM. I would like my package to store the timestamp of the input file and compare it to the timestamp of the next day's file. If they are the same, then the package can exit without reprocessing a particular file again.
So, my first question is whether a package variable can be updated so that its value will persist from one run to the next?
No! That'd be nice wouldn't it. I've requested similar functionality in the past although not formally via the Product Feedback Center. Perhaps you could submit it?
Philsky wrote:
Second, what is the syntax to retrieve the file's timestamp, either directly from the file connection manager or within a script task?
Thanks,
Phil
There's some code here that shows how you can access this information: http://blogs.conchango.com/jamiethomson/archive/2005/10/10/2253.aspx
Check lines 7 & 8 of the first code block.
-Jamie