Friday, December 23, 2011

How to grant update permission to specific columns in a table in sql?

Do you know how to grant select permissions on TBL_XXXXXX table in XXX instance in XXXX server. And also grant update permissions on the same table at column level for the columns columnname1 and columnname2.?

By executing below query, select permission granted to the table ‘TBL_XXXXXX’ for the user ‘databaseusername’.

GRANT SELECT ON [TBL_XXXXXX] TO databaseusername

By executing below query, update permission granted to the specific columns in a table ‘TBL_XXXXXX’ for the user ‘databaseusername’

GRANT UPDATE(columnname1) ON [TBL_XXXXXX] TO databaseusername

GRANT UPDATE(columnname2) ON [TBL_XXXXXX] TO databaseusername

That’s it.

Wednesday, December 21, 2011

How to resync the existing log shipping setup:

1. Take full backup of Primary database in the primary server.

2. Copy to secondary server database backup location drive.

3. Disable all jobs (Backup job in primary server, Copy and Restore jobs in secondary server)

To change secondary datbase into online.

Restore database secondarydatabasename
With recovery

4. Restore the secondary server database using primary server database backup file with standby /readonly or with norecovery mode.

5. Enable
       ->Backup job first
       ->Copy job Next
       ->Restore job last.

6. View successive schedules for successful job history.

That’s it

Hope you will re configure the existing non-sync log shipping setup into sync mode.

DTS Packages Error log details Findings.

How to view dtspackage error log in a table?

Select * from msdb..sysdtssteplog order by endtime desc
Select * from msdb..sysdtstasklog order by endtime desc

Select * from msdb..sysdtspackagelog order by logdate desc

How to find dtspackage owner name ?

Select * from msdb..sysdtspackages where name ='dtspackagename'

Monday, November 28, 2011

My MCTS certificate.

I have done my MCTS certification .


If anybody need assistance in doing certifications,Please contact me .

Tuesday, November 8, 2011

Steps to find the Cpu cores and Cpu Sockets in SQL 2000, SQL2005 and Sql2008 through Powershell in SQL2008.

In SQL Server Management Studio 2008 (executed on the server where you want the information) right click anywhere in the object explorer tree under that server and select Start PowerShell.  Then paste the command I showed below.  Alternatively you can just run Powershell.exe on the server, and paste that command and get the desired results

Let’s write function named GetCpuinfo.

function GetCPUinfo {
    param ([array]$servernames = ".")
    foreach ($servername in $servernames) {
        [array]$wmiinfo = Get-WmiObject Win32_Processor -computer $servername
        $cpu = ($wmiinfo[0].name) -replace ' +', ' '
        $description = $wmiinfo[0].description
        $cores = ( $wmiinfo | Select SocketDesignation | Measure-Object ).count
        $sockets = ( $wmiinfo | Select SocketDesignation -unique | Measure-Object ).count
        Switch ($wmiinfo[0].architecture) {
            0 { $arch = "x86" }
            1 { $arch = "MIPS" }
            2 { $arch = "Alpha" }
            3 { $arch = "PowerPC" }
            6 { $arch = "Itanium" }
            9 { $arch = "x64" }
        }
        $manfg = $wmiinfo[0].manufacturer
        $obj = New-Object Object
        $obj | Add-Member Noteproperty Servername -value $servername
        $obj | Add-Member Noteproperty CPU -value $cpu
        $obj | Add-Member Noteproperty Description -value $description
        $obj | Add-Member Noteproperty Sockets -value $sockets
        $obj | Add-Member Noteproperty Cores -value $cores
        $obj | Add-Member Noteproperty Architecture -value $arch
        $obj | Add-Member Noteproperty Manufacturer -value $manfg
        $obj
    }
}

·             # The Get-WMIObject cmdlet enables you to get any WMI object. You can also use Get-WMIObject to list out the WMI classes present to aid in discovery. #


Function is called with a listing of servers as the single parameter. If parameter is not specified, the local server "." is used.

$result = GetCPUinfo server1, server2, server3

the output can then be showed into a Format-Table or similar.

$result | format-table -auto

Output should be look like this.

# To find the number of CPU Total Cores (Processor count) in the SQL through query analyzer in Sql2000, Sql2005 and Sql2008.

# To find the number of CPU Total Cores (Processor count) in the SQL through query analyzer in Sql2000, Sql2005 and Sql2008.

Run the XP_MSVER in the query analyzer.


  

Monday, October 31, 2011

Determining the Space Used by all tables in a Database?


Determining the Space Used by all tables in a Database

Lets create one temporary table to store the output of stored procedure ‘SP_MSFOREACHTABLE’.

CREATE TABLE #tbl_SPACETABLE(NAME VARCHAR(100),ROWS INT,RESERVED VARCHAR(100),DATA VARCHAR(100),INDEXSIZE VARCHAR(100),UNSUSED VARCHAR(100))

Insert the stored procedure ‘SP_MSFOREACHTABLE ‘ results by using below command.

INSERT INTO #tbl_SPACETABLE EXEC SP_MSFOREACHTABLE @COMMAND1="EXEC SP_SPACEUSED '?' "

It will insert below columns in the table #tbl_SPACETABLE.

name nvarchar(128) Name of the object for which space usage information was requested.
The schema name of the object is not returned. If the schema name is required, use the sys.dm_db_partition_stats or sys.dm_db_index_physical_stats dynamic management views to obtain equivalent size information.
rows char(11) Number of rows existing in the table. If the object specified is a Service Broker queue, this column indicates the number of messages in the queue.
reserved varchar(18) Total amount of reserved space for objname.
data varchar(18) Total amount of space used by data in objname.
index_size varchar(18) Total amount of space used by indexes in objname.
unused varchar(18) Total amount of space reserved for objname but no yet used.

SP_SPACEUSED stored procedure is used to find the space used by objects in
a database.

? is passed as argument for sp_spaceused stored procedure to retrieve space for all tables in a database.

Fetch the space used by all tables in a database by runnning below query

SELECT * FROM #tbl_SPACETABLE

If you need to fetch space for single table,then use below query.

SP_SPACEUSED 'TABLE_NAME'

Hope you will find the space of all tables easily.

MYSQL::Setting Validate_Password componet for MySQL Database to ensure password policy settings

Inadequate Password Settings for MySQL Database We observed that the `validate_password%` settings on hostname `<insert hostname>` a...