Showing posts with label Administration. Show all posts
Showing posts with label Administration. Show all posts

Monday, April 8, 2013

Control the zoom of pdf files

 

I read a lot of pdf files. One thing I always found rather annoying is that the pdf files open at very high zoom percentage , something like 263% so I have to adjust the zoom for every document.

Fixing this is easy, Go to Edit | Preferences :

image

Then Go to Page Display | Default Layout and Zoom :

blog_AdobePageDisplaySettings

Choose the desired value. That’s it , the next time you’ll open pdf documents, the zoom will be 100%.

Monday, March 11, 2013

List Tables associated with a fulltext catalog

SELECT t.name AS TableName, c.name AS [CatalogName]
FROM sys.tables t JOIN sys.fulltext_indexes i
ON t.object_id = i.object_id JOIN sys.fulltext_catalogs c
ON i.fulltext_catalog_id = c.fulltext_catalog_id
blog_table_FTCatalog

Monday, November 26, 2012

compare 2 tables with different names or schema

Problem:

You have 2 tables that you would like to compare at the column level (retrieve a list of the columns with different data types and/or names).
It happened to me today and the tables had 100+ columns so...

Alternative 1:

if the tables have the same names and a primary key , you can use one hidden gem of SQL Server (since version 90) called tablediff.exe .

Alternative 2:

My problem is the following , both tables belong to the same schema but hold different names. One of the tables is a simple import table (used to import text files) and has no primary key. Archiving the data from the import table to the destination table fails due a potential data truncation.

For the sake  of the example I will a use a database called TestDb that have 2 tables : books and books 1.


As you can see here the only difference is the BookTitle field that has a different length.
Run the following query :

The except statement will select (without duplicates) the elements contained in the left table that are not present in the right table (here books1)
here is the result:

Rgds.

Thursday, October 18, 2012

SQL Template to delete SQL job, maintenance plan and schedule

Problem: 
on our test servers , or servers that used to be managed by third party companies, the sql job list can become ...messy.
I came with a SQL server template to delete the job, the maintenance plan and the schedule if unused.

1. Create the template:

open the "view Template" window:

the template menu appears by default at the right of the SSMS window.


Create a folder of you choice in the Template explorer list , right click and choose "new template"
Name the template as you wish , right click the template and choose "Edit".
2. Now copy  the code that you can download from here

within the code you will notice special strings , these are the template parameters :


3.Save the template
4. Using the template:

Create a new query on the server on which you want to run the template.
Then simply drag the template you just saved on the blank query window
The template code is then copied on the new query window.
Then here is the cool stuff: click  on CTRL+SHIFT+M and you will be prompted to enter the parameters:

The first parameter  is to specify the job name, the second parameter (Delete_Maintenance_plan) should be  set to 1 if you want to delete the associated maintenance plan. Of course this is only a simple script, error check should be added to check if there is actually a maintenance plan etc..

Nonetheless it is still useful, and shows the basics of using templates.


Tuesday, October 16, 2012

sqlmaint.exe failed. [SQLSTATE 42000] (Error 22029)

We still have an SQL 2000 production server from a third party supplier. The backups failed for several days and looking on serveral blogs I found that some had disk space issues.

I did not have a disk space issue BUT a consultant from the third party had restricted the rights of the DATA folder to administrators only !

so if you run into this error :
  1. check that you have sufficient disk space
  2. check the data folder security :)

Monday, September 10, 2012

SQL Error 7302 Cannot Create linked server for OleDb Provider

Symptoms:


You Create a linked server for an excel or Access file. The following procedure relates to Excel 2003 (Microsoft.Jet.Oledb.4.0) and Excel 2007. (Ace driver – Microsoft Office 12 Access OleDb Provider.
You cannot make the connection and receive the error message “cannot load Microsoft Jet oledb provider for linked server null – SQL Error 7302”.

Note: Do not install MS Office 2007 on a server to connect to Excel or Access 2007 files. Only connectivity tools are needed (ACE Drivers).
          
If you try to run a select on a worksheet you can see the following message in the Event viewer (Applications):
The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID
{2206CDB0-19C1-11D1-89E0-00C04FD7A829}
to the user <user> SID (sid).  This security permission can be modified using the Component Services administrative tool.

RESOLUTION

Grant the user permissions to start the COM component. To do this, follow
these steps:

1. Click Start, click Run, type regedit in the Open box, and
then click OK.

2. Locate and then click the following registry subkey:
HKEY_CLASSES_ROOT\CLSID\CLSID value
Note In this subkey, "CLSID value" is a placeholder for the CLSID
information that appears in the message.

3. In the right pane, double-click AppID.
The Edit String dialog box appears. Leave this dialog box open and continue
to the next step.

4. Click Start, click Run, type dcomcnfg in the Open box, and then click OK.

If a Windows Security Alert message prompts you to keep blocking the
Microsoft Management Console program, click to unblock the program.
5. In Component Services, double-click Component Services, double-click
Computers, double-click My Computer, and then click DCOM Config.

6. In the details pane, locate the program by using the friendly name.
If the AppGUID identifier is listed instead of the friendly name, locate the
program by using this identifier.

7. Right-click the program, and then click Properties.

8. Click the Security tab.

9. In the Launch and Activation Permissions area, click Customize, and then
click Edit.

10. Click Add, type the user's account name, and then click OK.

11. While the user is selected, click to select the Allow check boxes for
the following items: 
.. Local Launch
.. Remote Launch
.. Local Activation
.. Remote Activation

12. Click OK two times.

13. Quit Registry Editor.

Thursday, August 9, 2012

Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050)

I spent 2 days searching for the above error , the situation is as follows :

1. we have 2 servers, one for dev, one for production using the same domain account both for the SQL Server service and SQLAgent service.
2. the user is not sysadmin on either server.
3. Calling sp_send_dbmail  works fine in SSMS on both servers
4. On my production server , it did not work and had the above error.

On some posts, I read that some people added the SQL Server agent account on the sysadmin group and "it worked" (sounds to me as a quick and dirty solution).

Finally noticed that job owners were different on both servers:
- on the development server , the job owner is a database user (db_owner), with DatabaseMailUserRole.
- on the production server, the job owner is our sysadmin user (not listed in DatabaseMailUserRole).

I just changed the job owner on the production server and it worked !! No sysadmin user to set up, it works with the application user.

Wednesday, July 11, 2012

Unable to start mail session (reason: No mail profile defined) - Message in Error Log

Message
[098] SQLServerAgent terminated (normally)
This is: the most common message that will be logged when there is no "Mail Session" defined for the SQL Server Agent Alert System
.

To Fix this or to make this message disappear in the Error Log, you have to enable "Mail Session" and re-start the SQL Server Agent.
To Do this,


  • Connect to the Server
  • Right Click on the "SQL Server Agent" and go to "Properties"
  • Then Go to "Alert System" Tab
  • Make sure the check box "Enable Mail Profile" is checked
  • Click OK to exit
  • Re-start the SQL Server Agent Service