Get Information From Sysobjects In Another Database (CLR, MS SQL 2005)

Mar 12, 2006

Hi All,

I've written a scalar function in C# for the MS SQL Server 2005 that has to have access to two databases in one instance of a server ("database1" and "database2"). I got information from database1, calculate the name of the database2 and got information from user's tables in the database2. But when I'm trying to get informatin from "sys.tables", "sys.columns", "sysobjects" I always get an error "System.Data.SqlClient.SqlException: This statement has attempted to access data whose access is restricted by the assembly."

All databases are inside one server, I can run this quieries in SQL Server management Studio - could anybody help me what should I set/change to get metainformation from another database in the same server (in fact I need a list of fields of a curtain table).

Thanks,

Alex Gerasimov

P.S. Atrribute [SqlFunction(DataAccess = DataAccessKind.Read)] is in the applicaiton.



View 1 Replies


ADVERTISEMENT

How To Replace Sysindexes And Sysobjects In The Query For Sql Server 2005?

Feb 26, 2008

 hi all,i was using the system tables namely sysindexes and sysobjects  in sql server 2000. But now sql server 2005 is using instead of sql server 2000.  Since am using sysindexes and sysobjects, too much time is taking for the execution in sql server 2005. So I need to change the query suitable for sql server 2005.I have read in msdn that the system tables are replaced with corresponding catalog views in sql server 2005. The catelog view for sysobjects is sys.objects. plz check the link  http://technet.microsoft.com/en-us/library/ms187997.aspxCould anyone please tell me how to replace the sysindexes and sysobjects in the query without rewriting the query too much. If I can replacesysobjects with just sys.objects, then it will be very helpful. Is it possible? And what about sysindexes.  Any help anyone could give would be greatly appreciated!

View 8 Replies View Related

ERROR 229: SELECT Permission Denied On Object 'sysobjects', Database ....

Sep 27, 2007

Hi,

I granted all the rights on the database to the user (db_owner, public, db_datawriter, etc...) However, I didn't grant the "System Administrators" role. I also specifically granted the select on those tables (sysobjects and sysindexes) for the user and checked through ‘sp_helprotect sysobjects’ command whether there are no specific revokes for for that user.

However, the user is still getting the below error while trying to expand the "Tables" view in the Enterprise Manager.

ERROR 229: SELECT permission denied on object 'sysobjects', database 'My_test', owner 'dbo', SELECT permission denied on object 'sysindexes', database 'My_test', owner 'dbo'.

Also, the user claims that he can’t seem to do anything with the database, he can’t view any objects, and, when he goes to Query Analyzer, if he tries to run a SELECT query on a table (that he know that this table exists), he gets this error:



SELECT permission denied on object 'tblBillingTrans', database 'My_Test', owner 'dbo'.

Any help would be greatly appreciated!
Thanks,
Alla

View 7 Replies View Related

An Error Occurred While Trying To Access The Database Information. The Msdb Database Could Not Be Opened.

Jun 21, 2007

I'am doing functionality test on DTS packages and saving my DTS packages to meta data services instead of saving them as local packages. We would like to see what information would be provided by saving them this way, but when we try to open the meta data browser (the 3rd icon under DTS) we get the following error:

An error occurred while trying to access the database information. The msdb database could not be opened.

View 3 Replies View Related

DB Design :: Buffer Database - Insert Information From Partners Then Make Update To Main Database

Oct 29, 2015

I actually work in an organisation and we have to find a solution about the data consistancy in the database. our partners use to send details to the organisation and inserted directly in the database, so we want to create a new database as a buffer database to insert informations from the partners then make an update to the main database. is there a better solution instead of that?

View 6 Replies View Related

2005 Index Maintenance Information

Jul 24, 2006

Hi,
Does anyone here know of any on-line references on how to optimize index maintenance in sql 2005? Also do you know of any good DBA books that will explain database maintenance and or best practices?

Thanks.
:D

View 2 Replies View Related

Information Schema In SQL Server 2005

Sep 6, 2007

Information Schema is the part of the SQL-92 standard which exposes the metadata of the database. I have written a small article that exposes the same. Let me know your comments on the same. http://aspalliance.com/1380_Information_Schema_and_SQL_Server_2005

Uday Denduluri
Software Engineer
Refer my articles at http://aspalliance.com/author.aspx?uId=62740

View 5 Replies View Related

Sql Server 2005 Job Failure Information

Dec 18, 2007

Hi,
I have scheduled a job that runs every minute.
If the job does not succeed, then I would like my front end application to be notified.
I am not sure if this is a reasonable way but I am thinking of somehow
populating a table (Only if the scheduled job fails) in sql server and then read that table every minute from the front end application.
So, is it possible to populate a table if a job fails?
I do not see any options for this in the properties of the job.
Thanks

View 6 Replies View Related

License Information In SQL Server 2005

Jan 17, 2008

How do we determine on a SQL 2005 server what license type was selected during the install? Where is the informationkept and how it is tracked by SQL Server 2005.

Thanks in Advance.

Admindba

View 3 Replies View Related

Sysobjects

Jun 26, 2001

How can you modify the crdate in sysobjects?

View 1 Replies View Related

Sysobjects

Mar 20, 2008

I am not aboe to view the userdefined tables in sql 2005. not sure whether my user dont have permission to view. how to view my user permission or not ..

another one , is there any table to find system table instead sysobjects,information_schema in 2000.

View 2 Replies View Related

Information Won't Post To My Database

Apr 15, 2007

I'm having a weird problem with an easy process. I have a section that allows people to enter their name and email address if they wish to be contacted. I have it set up so that when they enter that information into the text boxes, the info is then sent to my SQL database. The code looks right to me, but it never comes up. Here is the code I have for the button_click.
 
Dim NTAdatasource As New SqlDataSource()
NTAdatasource.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToString()
NTAdatasource.InsertCommandType = SqlDataSourceCommandType.Text
NTAdatasource.InsertCommand = "INSERT into ContactUs (YourName, EmailAddress, DateTimeStamp) VALUES (@YourName, @EmailAddress, @DateTimeStamp)"
NTAdatasource.InsertParameters.Add("YourName", txtYourName.Text)
NTAdatasource.InsertParameters.Add("EmailAddress", txtEmailAddress.Text)
NTAdatasource.InsertParameters.Add("DateTimeStamp", DateTime.Now)
Dim RowsAdded As Integer = 0
Try
RowsAdded = NTAdatabase.Insert()
Catch ex As Exception
Server.Transfer("problem.aspx")
End Try
 
If RowsAdded <> 1 Then
Server.Transfer("problem.aspx")
Else
Server.Transfer("success.aspx")
End If
End Sub
 
The strange thing is that when I debug, the "rowsadded" value comes up to 1. The process runs through debugging just fine and redirects me to my "success.aspx" page. What am I doing wrong?
 
Thanks

View 1 Replies View Related

Database Toolbar Information

Apr 5, 2001

I work with multiple servers and I have system administrator rights on all server. My question is, why on some server when I click on a database it shows the General, Table & Index, Space Allocated tool bar, than if I go to a different server, click a database it does not show? I would like to see this toolbar on all my servers when I click a database.
Thanks Reggie

View 1 Replies View Related

Sql Query For Getting Information From Different Database

Feb 18, 2003

I want to write a sql query for information from a table in different database but on the same server.

what is the syntax.


select * from databse2.owner.table ??


i am in application1 database and i want to query from application2 database on the same server.

use application1
go

Select * from application2.dbo.tablename
go



Is this query correct?

View 1 Replies View Related

Query Database Information

Oct 11, 2001

Pardon the possibly senseless question - I have been an NT Administrator for some years, and have just gotten thrown into picking up some SQL DBA work and I'm still feeling my way around.

Is it possible to query the Master database for the setup information (etc) on the other databases? Several have been marked suspect due to a hard drive failure and I am trying to figure out what the original setup of the databases was.

Thanks,
Mary Elizabeth
NW Natural

View 1 Replies View Related

Database Information Report

Jul 17, 2007

Hello,I am trying to use the SQl Server database reporting tools to create areport on the database to find areas for optimization including tableformats, column formats, and sizes. Can anybody please help me withthis. If any body has used any other tool by which I can create abovementioned reports plz do let me know. I will be really thankful foryour help.ThanksSuneel

View 1 Replies View Related

Missing Information From Database

Aug 14, 2007

I have a serious problem with either SQL Server or SQL Reporting Services. I have 7 tables in a database that are relational. I have created serveral reports against this database. Last week when I pulled one of the reports, I was missing information on one of the cells. The reason why I know this is because my boss has us verify the report against the database. That took about an hour to complete. When we found that the report was not correct I repulled the report and the cell that was empty, was now populated. What gives? This is the same report I have pulled for the last month and had no problems until now. Is there a time issue involved between the last update to the database to the time I pull the report? Or maybe there is something wrong with the query?

SELECT Lease.[Lease #], MineralContacts.[Mineral Owner First Name], MineralContacts.[Mineral Owner Last Name], Tract.County, Tract.[Tract Number],
Tract.[Tract Description], Tract.Section, Tract.Block, Tract.Survey, Tract.Abstract, Lease.[Lease Date], Tract.[Title Check Though], Tract.[2ndTitleReview],
Tract.[2nd R/S Complete], Tract.[Title Agent], Tract.[Tract Gross Acres], SubTract.[Tract Net Acres], Draft.[Draft Status], Draft.[Draft Due Date],
Draft.[Draft Amount], Draft.[Draft #], Draft.[ANB Invoice #], Draft.[Lse File Sent to CP], Draft.[Money Wired from CP to EA],
Draft.[STA Approved Draft for pmt], Draft.[STA Recommend to Return Daft], Draft.[KE Advised ANB to Pay Draft], Draft.[KE Advised ANB to Return Draft],
Draft.[Paid Draft Recd], SubTract.Comments, SubTract.Hide
FROM Tract INNER JOIN
SubTract ON Tract.TractID = SubTract.TractID INNER JOIN
Mineral ON SubTract.SubTractID = Mineral.SubTractID INNER JOIN
Lease ON Mineral.MineralID = Lease.MineralID INNER JOIN
Draft ON Lease.LeaseID = Draft.LeaseID INNER JOIN
MineralContacts ON Mineral.MineralID = MineralContacts.MineralID
WHERE (Draft.[Draft Status] IS NOT NULL) AND (Draft.[Draft Due Date] IS NOT NULL)

View 1 Replies View Related

Information Required About SQL Server 2005 Reporting

Dec 17, 2007



Hi Friends,



I was in the phase of switching over to Sql Server Reporting from the normal reports. I plan to go with the SQL server 2005 standard version. Do i need visual studio 2005 to design and deploy report. If I am using only SQL server standard alone for my reporting and publishing, is it possible to assign the user rights to reports, user can just login and can view all the reports that belongs to that user. Since I wont be using the visual Studio 2005, so I want to implement this using the SQL server 2005. So pls help me with your kind information how to proceed ahead.



Thanks,

Sreekoo.



View 1 Replies View Related

Information On Sql Server 2005 Express Edition

Aug 10, 2007



Hello, I'm completly new to SQL server 2005 express and wanted to see if somebody can answer a few questions for me.

I recently had a small application developed to import CSV files into a SQL database. The application imports roughly 200,000 records a day and takes roughly 4 hours or longer to import the data. I greatly under estimated the amount of time that it would take to import the data and I'm looking for some solutions to help speed up the process. I'm currently just using my laptop to hold the data. Would it help speed things up by dedicating a seperate machine to hold the data? If so, what type of machine would be best. I'm looking for a cost effective solution because the data is for personal use.

Any information would be appreciated.

Thanks,

View 1 Replies View Related

Disk Space Information In SQL Server 2005.

Aug 4, 2007

As a normal sql user we are not able to get the disk space information by
executing 'xp_fixeddrive' extended stored procedure.
We are able to get the result using sa user and windows authenticated user.

Any help will be appreciated.

View 3 Replies View Related

Sysobjects Question.

Oct 19, 2001

Any idea what are different types in sysobjects table? How can I seperate views only?

select distinct type from sysobjects

type
----
P
U
S
V
K
D
R

View 2 Replies View Related

Trigger On Sysobjects

Jul 8, 2000

I would very much like to create a trigger on the sysobjects table in my database. When I attempt to do so, I get a permission error. Is there some way I can change the permission setting to allow me to do this?

Thanks.

View 1 Replies View Related

No Replinfo On Sysobjects ?

Oct 3, 2006

HI there , i have recently upgraded my publishers to 2005.

Transactional replciation seems to be running fine.

However in SS2000 i always used to query sysobjects on replinfo to see if a table was replicaed and how it was replicated, 1 = snapshot , 3 = transactional etc.

However after upgrading replinfo on sysobjects is 0 for all my articles, whats up with this ?

Must i use sp_helparticle only now? Also how does the system know if an object is replicated now , i used to think it used the replinfo column on sysobjects, how is this different in 2005?

Thanx

View 3 Replies View Related

Retrieve Select Information From A Database

Mar 31, 2008

If I had a bunch of paragraphs stored in a database field, is there a way, when displaying that data, that I can write instructions to only retrieve the very first paragraph?

View 4 Replies View Related

Difficulty Uploading Information To Database

Dec 1, 2005

This is probably a very simple question but i am having problems with inserting information into database
The function takes the values "FirstName" And "LastName" from  A table Called "Customer" and the value "ProductID" from a table called "Products" and inserts them into a table called " NewOrder".
Everything compiles ok but when I press the button the information is not uploaded to thedatabase. ( There is no error message)
This is the stored procedure
CREATE PROCEDURE SP_NewOrder(@CartID char (36), @CustomerID Varchar (50))AS
INSERT INTO NewOrder (FirstName, LastName, ProductID)
SELECT Customer.FirstName, Customer.LastName, Products.ProductID
From Customer,Products Join ShoppingCart ON Products.ProductID =ShoppingCart.ProductIDWHERE ShoppingCart.CartID = @CartID AND Customer.CustomerID = @CustomerIDGO
This is the Function
Public Shared Function CreateOrder() AS String   Dim customerID As integer   Dim connection as New SqlConnection(connectionString)   Dim command as New SqlCommand("SP_NewOrder",connection)   command.CommandType = CommandType.StoredProcedure   command.Parameters.Add("@CartID", SqlDbType.Char,36)   command.Parameters("@CartID").Value = shoppingCartID   command.Parameters.Add("@CustomerID", SqlDbType.Varchar,36)   command.Parameters("@CustomerID").Value = customerID  Try
  connection.Open()  command.ExecuteNonQuery()  Finally  connection.Close()
        End TryEnd Function
This is the page code
Sub btn3_Click(sender As Object, e As EventArgs)Dim cart as New ShoppingCart()Dim shoppingCartID As IntegerDim customerID As Integer = Context.Session("worldshop_CustomerID")cart.CreateOrder()End Sub
Can Anyone see where I am going wrong
Many thanks
martin

View 2 Replies View Related

Serious Trouble Getting Database Table Information

Feb 7, 2001

I would like to know how to (if it is at all possible) in SQL (or even ADO) to retrieve all the data concerning database X's

a) Tables
b) Tables column names
c) Tables column's data types

I don't want to use the doa.tabledefs object.. .i would prefer to do it in SQL, but using ADO objects (since I am developing stuff in VB) would be ok too.

Please Help.. i have been going crazy trying to find anything useful.. email me back please!

Thanks,
Matt

View 2 Replies View Related

Retrieving Information About All Indexes In Database

Sep 8, 2003

Hi,
I want to get information about all the indexes in a database.
Can any one suggest me a query for this.

Thanks.

View 2 Replies View Related

Accesing Information From An Informix Database

Dec 13, 2006

Hi,

I ´d like to know if there is any way to access an Informix database from sqlserver 2005.

We are trying to build a data warehouse in SS2005, and I want to know If I could avoid the generation of hundreds of flats files from Informix and loading them into SS2005, directly recovering all information from SS2005 across any kind of migration or connection.

Any help would be very appreciated

Regards.

View 2 Replies View Related

Database/Table/Column Information

Jan 17, 2007

Hi,
I need to provide a report that lists the databases in each instance, then the tablenames and the number of rows in each table.

Is there any easy way to do this in SQL 2005?

Cheers
Gregg

View 8 Replies View Related

Get Server Database File Information

Sep 7, 2007

This script gets the file information for every database on a server, and inserts it into temp table #DB_INFO. #DB_INFO is queried multiple ways to give various levels of analysis of file space usage.

This script was tested on SQL Server 7.0, 2000, and 2005.


Edit 2007/9/7: Added FILEGROUP_TYPE and DISK columns.

Edit 2007/9/17: Modified to add various ways to analyze the output and format it to make it easier to understand space usage on the server:
Show Files Details
Total by Database and File
Total by Database and Filegroup
Total by Database and Filegroup Type
Total by Disk, Database, and Filepath
Total by Disk and Database
Total by Database

Edit 2007/9/17: Modified to make the changes suggested by eyechart. I managed to defeat Snitz to get rid of the smiley face () and still have executable code by putting in some extra quotes around the database name.





use master
go
if exists ( select * from tempdb.dbo.sysobjects o
where o.xtype in ('U') and o.id = object_id( N'tempdb..#DB_FILE_INFO' ))
drop table #DB_FILE_INFO
go

if exists ( select * from tempdb.dbo.sysobjects o
where o.xtype in ('U') and o.id = object_id( N'tempdb..#DB_INFO' ))
drop table #DB_INFO
go
set nocount on
go
create table #DB_FILE_INFO (
[ID]intnot null
identity (1, 1) primary key clustered ,
[DATABASE_NAME]sysnamenot null ,
[FILEGROUP_TYPE]nvarchar(4)not null ,
[FILEGROUP_ID]smallintnot null ,
[FILEGROUP]sysnamenot null ,
[FILEID]smallintnot null ,
[FILENAME]sysnamenot null ,
[DISK]nvarchar(1)not null ,
[FILEPATH]nvarchar(260)not null ,
[MAX_FILE_SIZE]intnull ,
[FILE_SIZE]intnot null ,
[FILE_SIZE_USED]intnot null ,
[FILE_SIZE_UNUSED]intnot null ,
[DATA_SIZE]intnot null ,
[DATA_SIZE_USED]intnot null ,
[DATA_SIZE_UNUSED]intnot null ,
[LOG_SIZE]intnot null ,
[LOG_SIZE_USED]intnot null ,
[LOG_SIZE_UNUSED]intnot null ,
)
go

declare @sqlnvarchar(4000)
set @sql =
'use ['+'?'+'] ;
if db_name() <> N''?'' goto Error_Exit

insert into #DB_FILE_INFO
(
[DATABASE_NAME],
[FILEGROUP_TYPE],
[FILEGROUP_ID],
[FILEGROUP],
[FILEID],
[FILENAME],
[DISK],
[FILEPATH],
[MAX_FILE_SIZE],
[FILE_SIZE],
[FILE_SIZE_USED],
[FILE_SIZE_UNUSED],
[DATA_SIZE],
[DATA_SIZE_USED],
[DATA_SIZE_UNUSED],
[LOG_SIZE],
[LOG_SIZE_USED],
[LOG_SIZE_UNUSED]
)
selecttop 100 percent
[DATABASE_NAME] = db_name(),
[FILEGROUP_TYPE]= case when a.groupid = 0 then ''Log'' else ''Data'' end,
[FILEGROUP_ID]= a.groupid,
a.[FILEGROUP],
[FILEID]= a.fileid,
[FILENAME]= a.name,
[DISK]= upper(substring(a.filename,1,1)),
[FILEPATH]= a.filename,
[MAX_FILE_SIZE] =
convert(int,round(
(case a.maxsize when -1 then null else a.maxsize end*1.000)/128.000
,0)),
[FILE_SIZE]= a.[fl_size],
[FILE_SIZE_USED] = a.[fl_used],
[FILE_SIZE_UNUSED] = a.[fl_unused],
[DATA_SIZE]= case when a.groupid <> 0 then a.[fl_size] else 0 end,
[DATA_SIZE_USED]= case when a.groupid <> 0 then a.[fl_used] else 0 end,
[DATA_SIZE_UNUSED] = case when a.groupid <> 0 then a.[fl_unused] else 0 end,
[LOG_SIZE] = case when a.groupid = 0 then a.[fl_size] else 0 end,
[LOG_SIZE_USED] = case when a.groupid = 0 then a.[fl_used] else 0 end,
[LOG_SIZE_UNUSED] = case when a.groupid = 0 then a.[fl_unused] else 0 end
from
(
Select
aa.*,
[FILEGROUP]= isnull(bb.groupname,''''),
-- All sizes are calculated in MB
[fl_size]=
convert(int,round((aa.size*1.000)/128.000,0)),
[fl_used]=
convert(int,round(fileproperty(aa.name,''SpaceUsed'')/128.000,0)),
[fl_unused]=
convert(int,round((aa.size-fileproperty(aa.name,''SpaceUsed''))/128.000,0))
from
dbo.sysfiles aa
left join
dbo.sysfilegroups bb
on ( aa.groupid = bb.groupid )
) a
order by
case when a.groupid = 0 then 0 else 1 end,
a.[FILEGROUP],
a.name

Error_Exit:

'

--print @sql

exec sp_msforeachdb @sql

--select * from #DB_FILE_INFO

declare @DATABASE_NAME_LENvarchar(20)
declare @FILEGROUP_LENvarchar(20)
declare @FILENAME_LENvarchar(20)
declare @FILEPATH_LENvarchar(20)

select
@DATABASE_NAME_LEN= convert(varchar(20),max(len(rtrim(DATABASE_NAME)))),
@FILEGROUP_LEN= convert(varchar(20),max(len(rtrim(FILEGROUP)))),
@FILENAME_LEN= convert(varchar(20),max(len(rtrim(FILENAME)))),
@FILEPATH_LEN= convert(varchar(20),max(len(rtrim(FILEPATH))))
from
#DB_FILE_INFO

if object_id('tempdb..##DB_Size_Info_D115CA380E2B4538B6CBBB51') is not null
begin
drop table ##DB_Size_Info_D115CA380E2B4538B6CBBB51
end

-- Setup code to reduce column sizes to max used
set @sql =
'
select
[DATABASE_NAME]= convert(varchar('+@DATABASE_NAME_LEN+'), a.[DATABASE_NAME] ),
a.[FILEGROUP_TYPE],
[FILEGROUP_ID],
[FILEGROUP]= convert(varchar('+@FILEGROUP_LEN+'), a.[FILEGROUP]),
[FILEID],
[FILENAME]= convert(varchar('+@FILENAME_LEN+'), a.[FILENAME] ),
a.[DISK],
[FILEPATH]= convert(varchar('+@FILEPATH_LEN+'), a.[FILEPATH] ),
a.[MAX_FILE_SIZE],
a.[FILE_SIZE],
a.[FILE_SIZE_USED],
a.[FILE_SIZE_UNUSED],
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when a.[FILE_SIZE] is null or a.[FILE_SIZE] = 0
then NULL
else (100.00000*a.[FILE_SIZE_USED])/(1.00000*a.[FILE_SIZE])
end ,1)) ,
a.[DATA_SIZE],
a.[DATA_SIZE_USED],
a.[DATA_SIZE_UNUSED],
a.[LOG_SIZE],
a.[LOG_SIZE_USED],
a.[LOG_SIZE_UNUSED]
into
##DB_Size_Info_D115CA380E2B4538B6CBBB51
from
#DB_FILE_INFO a
order by
a.[DATABASE_NAME],
case a.[FILEGROUP_ID] when 0 then 0 else 1 end,
a.[FILENAME]
'

--print @sql

exec ( @sql )

selecttop 100 percent
*
into
#DB_INFO
from
##DB_Size_Info_D115CA380E2B4538B6CBBB51 a
order by
a.[DATABASE_NAME],
case a.[FILEGROUP_ID] when 0 then 0 else 1 end,
a.[FILENAME]

drop table ##DB_Size_Info_D115CA380E2B4538B6CBBB51

set nocount off

print 'Show Details'
select * from #DB_INFO

print 'Total by Database and File'
select
[DATABASE_NAME]= isnull([DATABASE_NAME],' All Databases'),
[FILENAME]= isnull([FILENAME],''),
FILE_SIZE= sum(FILE_SIZE),
FILE_SIZE_USED= sum(FILE_SIZE_USED),
FILE_SIZE_UNUSED= sum(FILE_SIZE_UNUSED),
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when sum(a.[FILE_SIZE]) is null or sum(a.[FILE_SIZE]) = 0
then NULL
else (100.00000*sum(a.[FILE_SIZE_USED]))/(1.00000*sum(a.[FILE_SIZE]))
end ,1)) ,
DATA_SIZE= sum(DATA_SIZE),
DATA_SIZE_USED= sum(DATA_SIZE_USED),
DATA_SIZE_UNUSED= sum(DATA_SIZE_UNUSED),
LOG_SIZE= sum(LOG_SIZE),
LOG_SIZE_USED= sum(LOG_SIZE_USED),
LOG_SIZE_UNUSED= sum(LOG_SIZE_UNUSED)
from
#DB_INFO a
group by
[DATABASE_NAME],
[FILENAME]
with rollup
order by
case when [DATABASE_NAME] is null then 1 else 0 end ,
[DATABASE_NAME],
case when [FILENAME] is null then 1 else 0 end ,
[FILENAME]


print 'Total by Database and Filegroup'

select
--[Server]= convert(varchar(15),@@servername),
[DATABASE_NAME]= isnull([DATABASE_NAME],'** Total **'),
[FILEGROUP]=
case when [FILEGROUP] is null then '' when [FILEGROUP] = '' then 'LOG' else [FILEGROUP] end,
FILE_SIZE= sum(FILE_SIZE),
FILE_SIZE_USED= sum(FILE_SIZE_USED),
FILE_SIZE_UNUSED= sum(FILE_SIZE_UNUSED),
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when sum(a.[FILE_SIZE]) is null or sum(a.[FILE_SIZE]) = 0
then NULL
else (100.00000*sum(a.[FILE_SIZE_USED]))/(1.00000*sum(a.[FILE_SIZE]))
end ,1)) ,
--MAX_SIZE= SUM([MAX_FILE_SIZE]),
DATA_SIZE= sum(DATA_SIZE),
DATA_SIZE_USED= sum(DATA_SIZE_USED),
DATA_SIZE_UNUSED= sum(DATA_SIZE_UNUSED),
LOG_SIZE= sum(LOG_SIZE),
LOG_SIZE_USED= sum(LOG_SIZE_USED),
LOG_SIZE_USED= sum(LOG_SIZE_UNUSED)
from
#DB_INFO A
group by
[DATABASE_NAME],
[FILEGROUP]
with rollup
order by
case when [DATABASE_NAME] is null then 1 else 0 end ,
[DATABASE_NAME],
case when [FILEGROUP] is null then 10 when [FILEGROUP] = '' then 0 else 1 end ,
[FILEGROUP]


print 'Total by Database and Filegroup Type'

select
--[Server]= convert(varchar(15),@@servername),
[DATABASE_NAME]= isnull([DATABASE_NAME],'** Total **'),
[FILEGROUP_TYPE]= isnull([FILEGROUP_TYPE],''),
FILE_SIZE= sum(FILE_SIZE),
FILE_SIZE_USED= sum(FILE_SIZE_USED),
FILE_SIZE_UNUSED= sum(FILE_SIZE_UNUSED),
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when sum(a.[FILE_SIZE]) is null or sum(a.[FILE_SIZE]) = 0
then NULL
else (100.00000*sum(a.[FILE_SIZE_USED]))/(1.00000*sum(a.[FILE_SIZE]))
end ,1)) ,
DATA_SIZE= sum(DATA_SIZE),
DATA_SIZE_USED= sum(DATA_SIZE_USED),
DATA_SIZE_UNUSED= sum(DATA_SIZE_UNUSED),
LOG_SIZE= sum(LOG_SIZE),
LOG_SIZE_USED= sum(LOG_SIZE_USED),
LOG_SIZE_USED= sum(LOG_SIZE_UNUSED)
from
#DB_INFO A
group by
[DATABASE_NAME],
[FILEGROUP_TYPE]
with rollup
order by
case when [DATABASE_NAME] is null then 1 else 0 end ,
[DATABASE_NAME],
case when [FILEGROUP_TYPE] is null then 10 when [FILEGROUP_TYPE] = 'Log' then 0 else 1 end


print 'Total by Disk, Database, and Filepath'
select
[DISK]= isnull([DISK],''),
[DATABASE_NAME]= isnull([DATABASE_NAME],''),
[FILEPATH]= isnull([FILEPATH],''),
FILE_SIZE= sum(FILE_SIZE),
FILE_SIZE_USED= sum(FILE_SIZE_USED),
FILE_SIZE_UNUSED= sum(FILE_SIZE_UNUSED),
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when sum(a.[FILE_SIZE]) is null or sum(a.[FILE_SIZE]) = 0
then NULL
else (100.00000*sum(a.[FILE_SIZE_USED]))/(1.00000*sum(a.[FILE_SIZE]))
end ,1)) ,
DATA_SIZE= sum(DATA_SIZE),
DATA_SIZE_USED= sum(DATA_SIZE_USED),
DATA_SIZE_UNUSED= sum(DATA_SIZE_UNUSED),
LOG_SIZE= sum(LOG_SIZE),
LOG_SIZE_USED= sum(LOG_SIZE_USED),
LOG_SIZE_UNUSED= sum(LOG_SIZE_UNUSED)
from
#DB_INFO a
group by
[DISK],
[DATABASE_NAME],
[FILEPATH]
with rollup
order by
case when [DISK] is null then 1 else 0 end ,
[DISK],
case when [DATABASE_NAME] is null then 1 else 0 end ,
[DATABASE_NAME],
case when [FILEPATH] is null then 1 else 0 end ,
[FILEPATH]



print 'Total by Disk and Database'
select
[DISK]= isnull([DISK],''),
[DATABASE_NAME]= isnull([DATABASE_NAME],''),
FILE_SIZE= sum(FILE_SIZE),
FILE_SIZE_USED= sum(FILE_SIZE_USED),
FILE_SIZE_UNUSED= sum(FILE_SIZE_UNUSED),
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when sum(a.[FILE_SIZE]) is null or sum(a.[FILE_SIZE]) = 0
then NULL
else (100.00000*sum(a.[FILE_SIZE_USED]))/(1.00000*sum(a.[FILE_SIZE]))
end ,1)) ,
DATA_SIZE= sum(DATA_SIZE),
DATA_SIZE_USED= sum(DATA_SIZE_USED),
DATA_SIZE_UNUSED= sum(DATA_SIZE_UNUSED),
LOG_SIZE= sum(LOG_SIZE),
LOG_SIZE_USED= sum(LOG_SIZE_USED),
LOG_SIZE_USED= sum(LOG_SIZE_UNUSED)
from
#DB_INFO a
group by
[DISK],
[DATABASE_NAME]
with rollup
order by
case when [DISK] is null then 1 else 0 end ,
[DISK],
case when [DATABASE_NAME] is null then 1 else 0 end ,
[DATABASE_NAME]



print 'Total by Disk'
select
[DISK]= isnull([DISK],''),
FILE_SIZE= sum(FILE_SIZE),
FILE_SIZE_USED= sum(FILE_SIZE_USED),
FILE_SIZE_UNUSED= sum(FILE_SIZE_UNUSED),
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when sum(a.[FILE_SIZE]) is null or sum(a.[FILE_SIZE]) = 0
then NULL
else (100.00000*sum(a.[FILE_SIZE_USED]))/(1.00000*sum(a.[FILE_SIZE]))
end ,1)) ,
DATA_SIZE= sum(DATA_SIZE),
DATA_SIZE_USED= sum(DATA_SIZE_USED),
DATA_SIZE_UNUSED= sum(DATA_SIZE_UNUSED),
LOG_SIZE= sum(LOG_SIZE),
LOG_SIZE_USED= sum(LOG_SIZE_USED),
LOG_SIZE_USED= sum(LOG_SIZE_UNUSED)
from
#DB_INFO a
group by
[DISK]
with rollup
order by
case when [DISK] is null then 1 else 0 end ,
[DISK]


print 'Total by Database'
select
--[Server]= convert(varchar(20),@@servername),
[DATABASE_NAME]= isnull([DATABASE_NAME],'** Total **'),
FILE_SIZE= sum(FILE_SIZE),
FILE_SIZE_USED= sum(FILE_SIZE_USED),
FILE_SIZE_UNUSED= sum(FILE_SIZE_UNUSED),
FILE_USED_PCT=
convert(numeric(5,1),round(
case
when sum(a.[FILE_SIZE]) is null or sum(a.[FILE_SIZE]) = 0
then NULL
else (100.00000*sum(a.[FILE_SIZE_USED]))/(1.00000*sum(a.[FILE_SIZE]))
end ,1)) ,
DATA_SIZE= sum(DATA_SIZE),
DATA_SIZE_USED= sum(DATA_SIZE_USED),
DATA_SIZE_UNUSED= sum(DATA_SIZE_UNUSED),
LOG_SIZE= sum(LOG_SIZE),
LOG_SIZE_USED= sum(LOG_SIZE_USED),
LOG_SIZE_UNUSED= sum(LOG_SIZE_UNUSED)
from
#DB_INFO A
group by
[DATABASE_NAME]
with rollup
order by
case when [DATABASE_NAME] is null then 1 else 0 end ,
[DATABASE_NAME]





CODO ERGO SUM

View 1 Replies View Related

Cannot Install Sql 2005 SP2, Error: Your Account Information Could Not Be Verified

Apr 16, 2007

Hi all,

I am running a named instance of SQL Server 2005 Enterprise Edition, side by side with named instance of SQL Server 2000 in Windows Server 2003. When I start the installation. I am unable to proceed from authentication stage.

The error description for Database Services and Reporting Services under both sa and windows authentication mode is: Encryption not supported on client Sqlcmd error: Microsoft SQL Native client: Client Unable to establish connection

In Service Manager, all SQL Server 2005 services are running with Logon as Administrator, and I am also able to connect to SSAS, SSRS, SSIS via Management studio both via Windows authentication and sa account information.



Would you please inform if I have to change any security settings before SP2 installation here.

How to add myself a Sql Server Administrator. The link in Surface Area Configuration to Add new Administrator doesn't work.

View 4 Replies View Related

Accessing Column Name From Sysobjects

Sep 6, 2001

Hi all,
I have a question about accessing a specific column from the database.
I know when we use: select name from sysobjects would select all the table names and the constraints from the database. I want to select all the column names in each of the table. How can I go about doing this.
Thank you

View 1 Replies View Related

Create Trigger On Sysobjects

Aug 16, 2000

Hi there,

Once in a while, I find down there are some missing objects in production database. Because we share the sa password with couple of developers, therefore, it's hard find down who did it. So, I try to create a trigger in sysobjects table to prevent this problem, however, I keep getting the error message "error 229: create trigger permission denied on object 'sysobjects'"
although I log in using sa. Can someone give me some suggestions how to prevent this from happening beside using trace profiler and also why do I get the denied message when create trigger on sysobject even with sa login.

Thanks in advance

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved