“Print to OneNote” Should Offer an Infinite Canvas Option

I have been paperless since 2005 using first Journal and then OneNote. Yet to this day, when I print from Edge or Outlook to OneNote, the content is chopped into pages, breaking up images and adding unnecessary whitespace between paragraphs.

It should be possible to print to an endless page in OneNote (as a new page already is when you create it). An option to keep the text editable and the images as individual objects would be a plus.

Vote it up on UserVoice!

 

Paging through Pages in a OneNote Section

With its OneDrive-based synchronization, OneNote is a great tool to take notes on your Surface and also have your notes available on your desktop afterwards. Once you’re reviewing the notes there or scanning through them, clicking away with the mouse can get old, though. To shuffle through your pages quickly use the keyboard shortcut <Ctrl>+<Page Down> and <Ctrl>+<Page Up>.

Find a Field in a Database

If you believe a particular field may exist somewhere in your database but you don’t know the table or view it may appear in (or you want to do an inventory of how often and where a field appears), there’s information about that in sys.all_objects and sys.all_columns. Say, you’ve found a table with a UserID column in it and can’t find the table that matches that UserID with a real name. (It should be pointed out that the following script does rely on the database designer having used the same field name in both tables.)

You’ll need to replace “SEC_NAME” with the field name/portion thereof you’re looking for.

SELECT sys.all_objects.name AS [Table/View], sys.all_columns.name AS [Column], sys.all_objects.type_desc AS [Type]
FROM sys.all_objects
INNER JOIN sys.all_columns
ON sys.all_objects.object_id = sys.all_columns.object_id
WHERE (sys.all_objects.type = ‘V’ OR sys.all_objects.type = ‘U’) AND sys.all_columns.name LIKE ‘%SEC_NAME%’
ORDER BY sys.all_objects.name, sys.all_columns.name

 

 

Find_Field_2015_11_30

Top 3 Rows from Each Table in a Database

Searching through an unfamiliar database for a value for which you don’t know where it lives (table or column) can take a long time if you just right-click on each table and choose “Select Top 1000 Rows” in SQL Server Management Studio. The sp_MSForEachTable stored procedure can make that a single step.

USE <Database_Name>;
EXEC sp_MSForEachTable ‘SELECT TOP 3 ”?” AS TableName, * FROM ?’;

For more information: https://www.mssqltips.com/sqlservertip/1905/iterate-through-sql-server-database-objects-without-cursors/

 

Shrinking the Log that Won’t Shrink

Sometimes, you can’t shrink the log very well because the end of the log is in a virtual log file towards the end of the physical log. After selecting the database, you find this information with

DBCC LOGINFO;

loginfo_2015_11_20_02

The Status column indicates the end of the log. Before you can shrink the log, you’ll need it to wrap around (start using the first virtual log file, rather than the high 600s, in this case) and do a log backup so that the end of the physical log is not in use (status should be 0).

You’ll notice that there are six virtual log files remaining that haven’t even been touched yet. To bring the end of the log to what is here row 614, run the SHRINKFILE command with a value less than row 614 here (measured in MB). You can get that value by dividing the value in StartOffset twice by 1024 (e.g., 95779749888 / 1024 / 1024 = 91342.6875, though instead of 91342, you could probably just guesstimate or pick an intentionally low number). Afterwards, the log will end at row 614 (this case), and should wrap around soon.

USE [Database Name];
GO

DBCC SHRINKFILE ([Logical File Name], [MB Target]);
GO

 

Connect the Acer C120 LED Projector to the Surface Pro 3

Credit: Acer

Credit: Acer

Connecting Acer’s C120 Pico projector to the Surface Pro 3 is harder than you may think due to the Surface Pro 3’s low power output on its sole USB port. The projector is designed to connect via USB and then install its driver off the projector (presumably stored in some kind of ROM on the projector), but usually the Surface Pro 3 won’t even make it to the installation screen. Even the external power adapter for the C120 has not been enough to get it going. I finally got it working by connecting the thin USB cable (plug with the white plastic in it) to the USB port on the Surface Pro 3’s power adapter, and the main USB cable (plug with the blue plastic in it) to the Surface Pro 3 afterwards. Sometimes, it takes a little while for the driver install to complete. Note that for projection, you’ll want your Surface to be set to display screen elements at 100%.

USB port on power adapter - connect the secondary USB cable here

USB port on power adapter – connect the secondary USB cable here

Log Files – Size, Space Used, Wait Description

Improved on the previous post some when I noticed that dbcc sqlperf(logspace) already gives you the log size in MB and also adds the log space used. Converting the floats to int in this manner may be kind of ugly, but it gets me close enough to the results I’m after – giving me sufficient data (database name, log file size, log space used, description why truncation may have to wait for each database in the database instance) to make decisions which logs to clean up.

 

DECLARE @t TABLE([Database Name] nvarchar(50), [Log Size (MB)] int, [Log Space Used (%)] int, Status smallint);

INSERT INTO @t([Database Name], [Log Size (MB)], [Log Space Used (%)], Status) EXEC (‘dbcc sqlperf(logspace);’)

SELECT t2.Name AS [Datebase Name], t1.[Log Size (MB)], t1.[Log Space Used (%)], t2.[log_reuse_wait_desc] AS [Wait Desc]

FROM @t AS t1

INNER JOIN sys.databases AS t2

ON t1.[Database Name] = t2.[Name]

ORDER BY [Database Name]

sql_script_2015_10_27_02

Log Files – Get Size and Reuse Wait Description

Ever seen that job description line “other duties as assigned?” You know you have. How appropriate to start a SharePoint blog with T-SQL…

The SQL logs were growing too large (even on SIMPLE recovery model – yes, that’s possible) and needed truncating and shrinking. sys.database_files is supposed to do a better job than sys.master_files, but the former only returns the current database, while the latter returns all databases in the database instance. The code below gives me the database name, size in MB, and the log reuse wait description utilizing sys.database_files for the size.

sql_script_2015_10_27

DECLARE @t TABLE([Database Name] nvarchar(50), [Size (MB)] int, [Wait Desc] nvarchar(250));

INSERT INTO @t([Database Name], [Size (MB)], [Wait Desc]) EXEC sys.sp_MSforeachdb 'use [?]; select Name as [Database Name], database_id AS [Size (MB)], log_reuse_wait_desc as [Wait Desc] from sys.databases AS ResultA where Name = db_name();  select Name as [Database Name], size AS [Size (MB)], physical_name AS [Wait Desc] from sys.database_files where type = 1';
SELECT * FROM (SELECT t1.[Database Name], t2.[Size (MB)] * 8 / 1024 AS [Size (MB)], t1.[Wait Desc] FROM @t AS t1 INNER JOIN sys.master_files ON t1.[Size (MB)] = sys.master_files.database_id INNER JOIN @t AS t2 ON t2.[Wait Desc] = sys.master_files.physical_name) AS t3 ORDER BY t3.[Database Name]

Credits:

sys.master_files issues: https://connect.microsoft.com/SQLServer/feedback/details/377223/sys-master-files-does-not-show-accurate-size-information

More details on sp_MSforeachdb: http://weblogs.sqlteam.com/joew/archive/2008/08/27/60700.aspx

Calculating actual MB: http://www.sqlservercentral.com/Forums/Topic932220-146-1.aspx