Showing posts with label dbo. Show all posts
Showing posts with label dbo. Show all posts

Wednesday, March 28, 2012

Hide databases in SQL EM from dbo owner

If i create a new SQL login and give that login db ownership for a test db.
When that user adds my SQL Server through his own SQL EM, why does he/she
also see all other objects (databases, sql security logins, DTS, ...)?

Is there a way for the user to open SQL EM but only see his/her db and
nothing
more?

Thank youIn article <0Fp2d.21814$0h7.1558418@.news20.bellglobal.com>,
sergea@.nospam.ehmail.com says...
> If i create a new SQL login and give that login db ownership for a test db.
> When that user adds my SQL Server through his own SQL EM, why does he/she
> also see all other objects (databases, sql security logins, DTS, ...)?
> Is there a way for the user to open SQL EM but only see his/her db and
> nothing
> more?

Now you know why they call it "Enterprise Manager". If you don't want
someone gaining access to your database, and you don't trust the users
with SA access then you are screwed. Even if you did hide it, somehow,
the SA account can gain access to it.

Only DBA's should be using EM.

--
--
spamfree999@.rrohio.com
(Remove 999 to reply to me)|||On Thu, 16 Sep 2004 19:50:20 -0400, serge wrote:

>Is there a way for the user to open SQL EM but only see his/her db and
>nothing
>more?

Hi Serge,

Not as far as I know. This information is available in tables in the
master database that everybody has access to. EM presents it nicely, but
it's possible to retrieve the same information by executing some queries
in Query Analyzer, osql or any other tool.

Users can see the name of the database, but not the contents, so you
shouldn't be too worried about it (unless you have a database called
MyPlansToRipOffTheBoss - but you could always choose a less obvious name).

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)|||Hi

EM is not really something you should be giving to just anybody! If you
really want to do this, then you may want to create a separate instance,
although this may be a heavy overhead if you require more than a couple.

John

"serge" <sergea@.nospam.ehmail.com> wrote in message
news:0Fp2d.21814$0h7.1558418@.news20.bellglobal.com ...
> If i create a new SQL login and give that login db ownership for a test
db.
> When that user adds my SQL Server through his own SQL EM, why does he/she
> also see all other objects (databases, sql security logins, DTS, ...)?
> Is there a way for the user to open SQL EM but only see his/her db and
> nothing
> more?
> Thank you|||Thank you for the responses.

What about this SQL Web Data Administrator that can be run
using IIS or VS.Net.

Has anyone tried this? If so, maybe through this web front-end, there
might be better ways to control which tools to show for the users?

Wednesday, March 21, 2012

Hi friend

I have a stored procedure which accepts 3 arguments that are used in the WHERE clause of a SELECT Statement

CREATE PROCEDURE [dbo].[MyProcedure] @.argYear INT, @.argMonth INT, @.argDay INT
AS

SELECT *

FROM MyData

WHERE
MyData.Year = @.argYear AND MyData.Month = @.argMonth AND MyData.Day = @.argDay

The problem that I am having is @.argDay is an "optional" argument. If @.argDay is NULL then I want to basically ignore the "AND MyData.Day = @.argDay" condition.

Is there an easier way to do this than:

IF @.argDay is NULL

SELECT *


FROM MyData


WHERE

MyData.Year = @.argYear AND MyData.Month = @.argMonth

ELSE

SELECT *


FROM MyData


WHERE

MyData.Year = @.argYear AND MyData.Month = @.argMonth AND MyData.Day = @.argDay


END IF

Thanks

You can OR in a not null condition to handle it; perhaps something like:

Code Snippet

SELECT *
FROM MyData
WHERE MyData.Year = @.argYear
AND MyData.Month = @.argMonth

AND ( MyData.Day = @.argDay or @.argDay is null )

|||

One method is something like this:

WHERE ( MyData.Year = @.argYear

AND MyData.Month = @.argMonth

AND ( MyData.Day = @.argDay

OR MyData.Day IS NULL

)

)

|||

Whatever you are using it is the best method. If you add expression on variable the Index Scan will be forced on your query..

The current query is neat & clean, will give a best performance. Stick it there itself.

|||Thanks for all your help - it works!
|||

I want to learn ASP.Net with c# from the basic stage.If you get some useful links and tutorials,please send me.

Monday, February 27, 2012

HELP: problem with using xp_sendmail

below is code snippet (which im assuming is the cause of the problem) from a certain stored procedure

EXEC Master.dbo.xp_sendmail
@.dbuse = 'DanoneSSS',
@.recipients = 'xxx@.yyy.co.jp',
@.subject = 'mmm nnn',
@.message = @.parMessage,
@.query = 'SELECT CHECK_JS_CODE, CHECK_TYPE FROM T_CHECK_LOG WHERE CHECK_STATUS = 0 ORDER BY CHECK_ID',
@.attachments = 'ResultSet.txt',
@.attach_results = TRUE,
@.no_header = TRUE,
@.separator = '',
@.ansi_attachment = TRUE

as in my case, when i execute this particular stored procedure, SQL Server sends me the email AND with the necessary attachment

however, when i create a Job with "EXEC dbo.SOSOStoredProcedure," though the Job executes successfully, no EMAIL is sent to me.

the funny thing is, when i comment out the following lines

@.query = 'SELECT CHECK_JS_CODE, CHECK_TYPE FROM T_CHECK_LOG WHERE CHECK_STATUS = 0 ORDER BY CHECK_ID',
@.attachments = 'ResultSet.txt',
@.attach_results = TRUE,
@.no_header = TRUE,
@.separator = '',
@.ansi_attachment = TRUE

the Job executes successfully with an EMAIL being sent to me

does SQL Server's job CANNOT handle xp_sendmail that returns a RESULT set? or i may be mistaken somewhere...

thanks!Who is the owner of the job and what is the permission level ?|||Originally posted by rnealejr
Who is the owner of the job and what is the permission level ?

thanks for the reply...

but i did getting it working though...

by carefully reading through BO regarding xp_sendmail, it seems that in using xp_sendmail to send file attachments, the specific procedure must be defined in the master database. this is what i have done.

then, defined a permission level for the procedure's properties, and the specific entry in SQL Agent.

i may have gotten it working... but there still may be a gap in my understanding, and i would appreciate if anyone could check on this - Books Online could get so scarce in regards to explanations and examples.

again, thanks...|||the specific procedure must be defined in the master database

This is only done if the sa wants to conceal the behavior of xp_sendmail.
Which if that were the case you would have been unsuccessful regardless of where you ran the stored procedure.

then, defined a permission level for the procedure's properties, and the specific entry in SQL Agent.

Can you elaborate ?|||Alter the SP.
In the same sp, use exec master..xp_cmdshell 'isql "Your query" -o drive:\filename.txt etc'
Then remove the query portion from xp_sendmail.
Run the job again. It would work.|||I beleive (rightly or wrongly) that you are unable to run an open query within an xp_sendmail.

I am trying to run a stored procedure with an open query within it. wrapping it within an xp_sendmail.

Which fails.

Any sugestions on how to get this running.

Thanks

Sunday, February 19, 2012

HELP...Splitting a string in T-SQL

I have a situation where I am querying the master.dbo.sysaltfiles to return
the path to the datafiles. What I am really interested in is the path...not
the filenames.
Example:
select @.DataPath = FileName From master.dbo.sysaltfiles WHERE name =
@.CurrentDB
This returns: M:\Microsoft SQL Server\CurrentDB.mdf
What I need is just the path:
Example:
M:\Microsoft SQL Server\
I was looking for something like VB's split string or something to remove
the filename.
What can I do to achieve the desired result?
Thanks!
RonThere are plenty of string functions in T-SQL that will help with this.
Check out REVERSE, CHARINDEX and SUBSTRING.
"RSH" <way_beyond_oops@.yahoo.com> wrote in message
news:%23Yp4navNGHA.2884@.TK2MSFTNGP12.phx.gbl...
> I have a situation where I am querying the master.dbo.sysaltfiles to
> return the path to the datafiles. What I am really interested in is the
> path...not the filenames.
> Example:
> select @.DataPath = FileName From master.dbo.sysaltfiles WHERE name =
> @.CurrentDB
> This returns: M:\Microsoft SQL Server\CurrentDB.mdf
>
> What I need is just the path:
> Example:
> M:\Microsoft SQL Server\
> I was looking for something like VB's split string or something to remove
> the filename.
> What can I do to achieve the desired result?
>
> Thanks!
> Ron
>|||Excellent. If possible could you give me a sample of how to use them to
achieve what I'm going for?
Thanks,
Ron
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:OY9JLgvNGHA.3984@.TK2MSFTNGP14.phx.gbl...
> There are plenty of string functions in T-SQL that will help with this.
> Check out REVERSE, CHARINDEX and SUBSTRING.
>
> "RSH" <way_beyond_oops@.yahoo.com> wrote in message
> news:%23Yp4navNGHA.2884@.TK2MSFTNGP12.phx.gbl...
>|||Here is an example
declare @.c varchar(50)
select @.c ='M:\Microsoft SQL Server\CurrentDB.mdf'
select left(@.c,(len(@.C) -CHARINDEX('',reverse(@.c)))+1)
Just replace @.c with your field name
http://sqlservercode.blogspot.com/|||Thank you so much!
I'm under the gun so I needed to "learn" quickly. I appreciate your help!
Ron
"SQL" <denis.gobo@.gmail.com> wrote in message
news:1140535404.793871.132130@.g47g2000cwa.googlegroups.com...
> Here is an example
> declare @.c varchar(50)
> select @.c ='M:\Microsoft SQL Server\CurrentDB.mdf'
> select left(@.c,(len(@.C) -CHARINDEX('',reverse(@.c)))+1)
> Just replace @.c with your field name
> http://sqlservercode.blogspot.com/
>|||Hi There,
I hope this help to solve the problem.
Select identity(int,1,1) Seq into Seq From sysobjects
Select * from seq
Select Substring(String,1,Max(seq)) From
(
Select * From Seq ,(
Select 'c:\aa\bb\cc\dd\ee' As String) S
Where substring(String,seq,1) = '\'
) SS Group By String
Drop Table Seq
With Warm regards
Jatinder Singh