Sunday, February 11, 2024

index rebuild

 


Indeex Reubild

DECLARE @Database NVARCHAR(255)   
DECLARE @Table NVARCHAR(255)  
DECLARE @cmd NVARCHAR(1000)  

 

DECLARE DatabaseCursor CURSOR READ_ONLY FOR  
SELECT name FROM master.sys.databases   
WHERE name NOT IN ('master','msdb','tempdb','model','distribution')  -- databases to exclude
--WHERE name IN ('DB1', 'DB2') -- use this to select specific databases and comment out line above
AND state = 0 -- database is online
AND is_in_standby = 0 -- database is not read only for log shipping
ORDER BY 1  

 

OPEN DatabaseCursor  

 

FETCH NEXT FROM DatabaseCursor INTO @Database  
WHILE @@FETCH_STATUS = 0  
BEGIN  

 

   SET @cmd = 'DECLARE TableCursor CURSOR READ_ONLY FOR SELECT ''['' + table_catalog + ''].['' + table_schema + ''].['' +  
   table_name + '']'' as tableName FROM [' + @Database + '].INFORMATION_SCHEMA.TABLES WHERE table_type = ''BASE TABLE'''   

 

   -- create table cursor  
   EXEC (@cmd)  
   OPEN TableCursor   

 

   FETCH NEXT FROM TableCursor INTO @Table   
   WHILE @@FETCH_STATUS = 0   
   BEGIN
      BEGIN TRY   
         SET @cmd = 'ALTER INDEX ALL ON ' + @Table + ' REBUILD' 
         --PRINT @cmd -- uncomment if you want to see commands
         EXEC (@cmd) 
      END TRY
      BEGIN CATCH
         PRINT '---'
         PRINT @cmd
         PRINT ERROR_MESSAGE() 
         PRINT '---'
      END CATCH

 

      FETCH NEXT FROM TableCursor INTO @Table   
   END   

 

   CLOSE TableCursor   
   DEALLOCATE TableCursor  

 

   FETCH NEXT FROM DatabaseCursor INTO @Database  
END  
CLOSE DatabaseCursor   
DEALLOCATE DatabaseCursor

Saturday, November 11, 2023

Import export Power BI users

 

workspace user migration only not report level






Sunday, August 27, 2023

Install SSDT 2015

  Please install SSDT  2015 as follows


1) download sql server 2015

2)download ssdt 2015

SQL Server Data Tools in Visual Studio 2015 | Microsoft Learn

3)download ssms 2019


Create ADO Board

  Please create the ADO Board using following steps


1) Create Features

2)Create Product Backlog

Write Description

Write Acceptation

3)Task