Wednesday, December 21, 2011

6 steps to take backup of all the objects from 'user' layer


6 steps to take backup of all the objects from 'user' layer

While working on client side with lot of customizations, someone must take the backup of all the changes which already have done in an application.

A very short way of taking backup from a selected layer is as follows;

1. Create a new project and open it.
2. Click on the Advance filter/Sort for this project, it will open the following screen


Note: Make sure the above options should be selected for this scenario.

3. Click on ‘Select’ button.
4. Remove all the ranges from this query form and add only one range. The form will now looks like this;



5. Press OK, form will be closed
6. Press OK

The new project will contains the entire objects, group by their consecutive groups.

Wednesday, June 15, 2011

Backup all sql server 2005 Database using Script

Backup all sql server 2005 Database using Script


DECLARE @name VARCHAR(50) -- database name DECLARE @path VARCHAR(256) -- path for backup files DECLARE @fileName VARCHAR(256) -- filename for backup DECLARE @fileDate VARCHAR(20) -- used for file name
SET @path = 'C:\Backup\'
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
DECLARE db_cursor CURSOR FOR
SELECT
name FROM master.dbo.sysdatabases WHERE name NOT IN ('master','model','msdb','tempdb')
OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name
WHILE @@FETCH_STATUS = 0 BEGIN
SET
@fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName

FETCH NEXT FROM db_cursor INTO @name END


CLOSE
db_cursor DEALLOCATE db_cursor

transported from http://bit.ly/kHYOsC

Tuesday, May 10, 2011

Search for pattern in all table in SQL


CREATE PROC SearchAllTables
)
@SearchStr nvarchar(100)
(
AS
BEGIN

-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.
-- Purpose: To search all columns of all tables for a given search string
-- Written by: Narayana Vyas Kondreddi
-- Site: http://vyaskn.tripod.com
-- Tested on: SQL Server 7.0 and SQL Server 2000
-- Date modified: 28th July 2002 22:50 GMT


CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)

WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)
IF @ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)
END
END
END

SELECT ColumnName, ColumnValue FROM #Results
END

Tuesday, April 26, 2011

Run as different user option in Windows 2008 and windows 7



"If you are running "Windows Server 2008 R2" then you can hold Shift and right click. An option "Run as different use
will then appear


if you use windows 7 after installing the ShellRunAs utility from the below link,it doesn't work as expected and you need to perform the two
extra steps to get the Run as different user option


After you download ShellRunAs from here, copy it to your Windows
System32 folder,ie..C:WindowsSystem32.

Open a command line
Start-->Run-->cmd
and Run: shellrunas /reg

other soulution is to create batch file and write in this file
"runas /user:CONTOSO\ALICIA "C:\Program Files\Dynamics AX\50\Client\Bin\Ax32.exe