Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA
|||You could get the currently logged in user's name using:
SELECT USER_NAME()
The owner of an object can be determined as shown below:
SELECT USER_NAME(OBJECTPROPERTY(OBJECT_ID('sysobjects'), 'OwnerID'))
In the above example, I used sysobjects as the table name.
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat
|||Just a note: SUSER_SNAME() returns the login name, and that doesn't
necessarily have to match the user name - but objects are owned by the user
names.
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Rick Sawtell" <r_sawtell@.hotmail.com> wrote in message
news:uR2I1CTYFHA.2884@.tk2msftngp13.phx.gbl...
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA
|||You could just check the catalogue:
SELECT CASE WHEN EXISTS(
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOGUE = 'SearchDB' --Replace the desired database
name here.
AND TABLE_SCHEMA = USER_NAME()
AND TABLE_NAME = 'SearchTable' --Replace the desired table
name here.
)
THEN 'True'
ELSE 'False'
END
Sincerely,
Anthony Thomas
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat
Showing posts with label owner. Show all posts
Showing posts with label owner. Show all posts
Thursday, March 8, 2012
Check an user is the owner of a table
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
--
Venkat"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could get the currently logged in user's name using:
SELECT USER_NAME()
The owner of an object can be determined as shown below:
SELECT USER_NAME(OBJECTPROPERTY(OBJECT_ID('sysobjects'), 'OwnerID'))
In the above example, I used sysobjects as the table name.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
--
Venkat|||Just a note: SUSER_SNAME() returns the login name, and that doesn't
necessarily have to match the user name - but objects are owned by the user
names.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Rick Sawtell" <r_sawtell@.hotmail.com> wrote in message
news:uR2I1CTYFHA.2884@.tk2msftngp13.phx.gbl...
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could just check the catalogue:
SELECT CASE WHEN EXISTS(
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOGUE = 'SearchDB' --Replace the desired database
name here.
AND TABLE_SCHEMA = USER_NAME()
AND TABLE_NAME = 'SearchTable' --Replace the desired table
name here.
)
THEN 'True'
ELSE 'False'
END
Sincerely,
Anthony Thomas
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
--
Venkat
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
--
Venkat"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could get the currently logged in user's name using:
SELECT USER_NAME()
The owner of an object can be determined as shown below:
SELECT USER_NAME(OBJECTPROPERTY(OBJECT_ID('sysobjects'), 'OwnerID'))
In the above example, I used sysobjects as the table name.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
--
Venkat|||Just a note: SUSER_SNAME() returns the login name, and that doesn't
necessarily have to match the user name - but objects are owned by the user
names.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Rick Sawtell" <r_sawtell@.hotmail.com> wrote in message
news:uR2I1CTYFHA.2884@.tk2msftngp13.phx.gbl...
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could just check the catalogue:
SELECT CASE WHEN EXISTS(
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOGUE = 'SearchDB' --Replace the desired database
name here.
AND TABLE_SCHEMA = USER_NAME()
AND TABLE_NAME = 'SearchTable' --Replace the desired table
name here.
)
THEN 'True'
ELSE 'False'
END
Sincerely,
Anthony Thomas
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
--
Venkat
Check an user is the owner of a table
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could get the currently logged in user's name using:
SELECT USER_NAME()
The owner of an object can be determined as shown below:
SELECT USER_NAME(OBJECTPROPERTY(OBJECT_ID('syso
bjects'), 'OwnerID'))
In the above example, I used sysobjects as the table name.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat|||Just a note: SUSER_SNAME() returns the login name, and that doesn't
necessarily have to match the user name - but objects are owned by the user
names.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Rick Sawtell" <r_sawtell@.hotmail.com> wrote in message
news:uR2I1CTYFHA.2884@.tk2msftngp13.phx.gbl...
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could just check the catalogue:
SELECT CASE WHEN EXISTS(
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOGUE = 'SearchDB' --Replace the desired database
name here.
AND TABLE_SCHEMA = USER_NAME()
AND TABLE_NAME = 'SearchTable' --Replace the desired table
name here.
)
THEN 'True'
ELSE 'False'
END
Sincerely,
Anthony Thomas
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could get the currently logged in user's name using:
SELECT USER_NAME()
The owner of an object can be determined as shown below:
SELECT USER_NAME(OBJECTPROPERTY(OBJECT_ID('syso
bjects'), 'OwnerID'))
In the above example, I used sysobjects as the table name.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat|||Just a note: SUSER_SNAME() returns the login name, and that doesn't
necessarily have to match the user name - but objects are owned by the user
names.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Rick Sawtell" <r_sawtell@.hotmail.com> wrote in message
news:uR2I1CTYFHA.2884@.tk2msftngp13.phx.gbl...
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there any way to check that the logged in user is the owner of a
> given table? Can any one give me the T-Sql statement for this.
> --
> Venkat
>
DECLARE @.Login sysname
SET @.Login = SUSER_SNAME()
SELECT
COUNT(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = '<databasename>'
AND TABLE_SCHEMA = @.Login
AND TABLE_NAME = '<tablename>'
Rick Sawtell
MCT, MCSD, MCDBA|||You could just check the catalogue:
SELECT CASE WHEN EXISTS(
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOGUE = 'SearchDB' --Replace the desired database
name here.
AND TABLE_SCHEMA = USER_NAME()
AND TABLE_NAME = 'SearchTable' --Replace the desired table
name here.
)
THEN 'True'
ELSE 'False'
END
Sincerely,
Anthony Thomas
"Venkat" <tammana@.inooga.com> wrote in message
news:esmSq4SYFHA.612@.TK2MSFTNGP12.phx.gbl...
Hi,
Is there any way to check that the logged in user is the owner of a
given table? Can any one give me the T-Sql statement for this.
Venkat
Subscribe to:
Posts (Atom)