Showing posts with label enter. Show all posts
Showing posts with label enter. Show all posts

Monday, March 12, 2012

How can I keep my DB secure on SQL Server

hi
this is my 1st time on this forum, I need to keep my DB secure on SQL server, that no body can enter into my DB and couldnt see my tables and other elements of DB.
Regards
AHKALTER DATABASE MyDataBasename SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE|||That's no good, Thrasymachus. Administrators can still get to the data. The only way to make sure that absolutely no one can get to the data, is to kill all the current user connections to the database, drop the database, and run the hard disks the database used to sit on through an MRI machine. Salting the earth is an optional step, but is considered a best practice ;-).

Friday, February 24, 2012

How Can I get my sproc to return records with 0 as ClientID

Can anyone help me modify this sproc's Where clause or Joins to let (T) task records with a 0 to be returned?

If I enter a ClientID I want to return only those task records with the ClientID I entered (this works).

If I enter no ClientID I want to return all task records, even those with a 0 in the ClientID field.

ALTER PROCEDURE dbo.CMAdmin

@.SID int


AS
SELECT
A.CompanyName,
C.FirstName,
C.LastName,
C.ClientID,Convert(varchar(10),
T.ActionDate, 10) AS [Action Date],
T.Priority,
T.Status,
T.Subject,
T.Note,
T.CompletionDate, 10) AS Completed,
T.DateEntered AS Entered,
T.EnteredBy AS [Entered By],

CASE
WHEN A.[CompanyName] IS NULL OR A.[CompanyName] = '' THEN
C.[FirstName] +' '+ C.[LastName]
ELSE A.[CompanyName]
END AS DRName

FROM
tblClients C LEFT OUTER JOIN tblClientAddresses A
ON C.ClientID = A.ClientID LEFT OUTER JOIN dbo.tblTasks T
ON C.ClientID = T.ClientID

WHERE
C.ClientID = Isnull(@.SID,C.ClientID)

hi

u can modify the where close like this

ALTER PROCEDURE dbo.CMAdmin

@.SID int


AS
SELECT
A.CompanyName,
C.FirstName,
C.LastName,
C.ClientID,Convert(varchar(10),
T.ActionDate, 10) AS [Action Date],
T.Priority,
T.Status,
T.Subject,
T.Note,
T.CompletionDate, 10) AS Completed,
T.DateEntered AS Entered,
T.EnteredBy AS [Entered By],

CASE
WHEN A.[CompanyName] IS NULL OR A.[CompanyName] = '' THEN
C.[FirstName] +' '+ C.[LastName]
ELSE A.[CompanyName]
END AS DRName

FROM
tblClients C LEFT OUTER JOIN tblClientAddresses A
ON C.ClientID = A.ClientID LEFT OUTER JOIN dbo.tblTasks T
ON C.ClientID = T.ClientID

WHERE
C.ClientID = COALESCE(@.SID,C.ClientID)

this query will return all records when client id is null and when it is not null it only returns rows specified in the where condition

for more details

http://www.sqlteam.com/item.asp?ItemID=2077

regards