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!Hello,
I don't know if I got it right, but to return anything from a Stored procedure just make something like:
Select client_datecreated from clients
if you need a date put it as a field then in C# execute the command and use the sqldatareader class:
check msdnhere
The command can be a Stored as well as a query.
|||Do i need to set an output parameter in the SP? The syntax in the SP is confusing me.|||select convert(char(10),fieldname in table,101) as test_Date from tablename
the 101 is a code which gives the date in mm/dd/yyyy format.
You should check with 'books online" in your SQL server help section.that gives you a list of different format you may want your date to be in.
convert basicly is truncating your date to have 10 characters otherwise you will have the hours:minute:seconds too in your result.
|||
If you would like to get data as return parameter (not return Value which is always int) you have to define it as OUTPUT in stored procedure definition, and also you have to setup this parameter as output in your SQLcommand object parameters definition.
If you would like to return it as cell in result table you do not have to define parameter and you can just do select yourdatafied from yourtable at the end of your stored procedure.
But SQL Command with output parameter is more elegant solution and will work a little faster ( .net do not have to create table structure for returned data)
and you can use executeNonQuery instead of execute scalar or execute reader.
See VB or C# help for syntax how to do this if you will have problems post again, but help is very good in VS so you should be good.
SELECT COUNT(DISTINCT DT) FROM Event
SELECTConvert(Varchar,DT,101),Count(*))FROM EventGroup byConvert(Varchar,DT,101)|||
SELECTCOUNT(DISTINCTDAY(DT)+' /'+MONTH(DT)+' /'+YEAR(DT))FROMEvent
I have the following two tables
mainprofile (profile varchar(20), description)
accprofile (profile varchar(20), acct_type int)
Sample data could be
mainprofile
------
prof1 | profile one
prof2 | profile two
prof3 | profile three
accprofile
-----
prof1 | 0
prof1 | 1
prof1 | 2
prof2 | 0
Now doing a join between these two tables would return multiple rows,
but I would like to know whether it would be possible to return
acct_type horizontally in a column of the result set, e.g.
prof1 | profile one | [0,1,2]
prof2 | profile two | [0]
I could probably manage this with cursors, but it would be very
resource intensive. Is there a better way?
Regards,
LouisFor a one time data display or if this is used by a single application or a
report, you should consider retrieving the resultset to the client side,
leverage the display/presentation language's string manipulative features
and appropriately format the data there.
If this is more of a general requirement and used by several applications,
in certain cases it may make some sense to do it at the server using t-SQL.
For some options see: http://www.projectdmx.com/tsql/rowconcatenate.aspx
--
Anith|||
Quote:
Originally Posted by
For some options see: http://www.projectdmx.com/tsql/rowconcatenate.aspx
Regards,
Louis