dbTalk Databases Forums  

Two quick questions.

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Two quick questions. in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Smith
 
Posts: n/a

Default Two quick questions. - 02-06-2008 , 11:00 AM






Two quick questions.

1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.

2. If I used truncate table, can I recover that in Point in time recovery.


Thanks in advance.



Reply With Quote
  #2  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM






Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #3  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #4  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #5  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #6  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #7  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #8  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #9  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
  #10  
Old   
Russell Fields
 
Posts: n/a

Default Re: Two quick questions. - 02-06-2008 , 01:34 PM



Smith,

Comments in line:

Quote:
1. I have a stored procedure call SPAccess and in that there are three
columns... (now I want if User1 access that stored procedure he/she can
access 2 columns of data and if User2 access then he/she access all three
columns of data) how I can fullfill that.
You could use an IF to run two different queries depending on the user.

IF USER_NAME() = 'Fred'
SELECT a, b, c FROM MyTable
ELSE
SELECT a, b FROM MyTable

Or you could use a CASE to return all columns be control what information is
revealed.

SELECT a, b,
CASE
WHEN USER_NAME() = 'Fred' THEN
c
ELSE
NULL
END AS c
FROM MyTable


Quote:
2. If I used truncate table, can I recover that in Point in time recovery.
If you restored a fully logged database to a point in time prior to the
truncate, you would have the contents up to that point in time. I trust
that you realize that the entire database has to be restored, since there is
no function to restore a single table.

(Workaround for a 'table restore': Restore the database to another name,
e.g. RecoveringMyDatabase, to the proper time. Copy the table contents from
RecoveringMyDatabase to MyDatabase. Deal with any referential problems that
remain.)

RLF




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.