Analyzing string or binary data would be truncated error

Based on the ideas in this post, I've made an improved and dynamic version to help in determining the violating records when inserting into a table:
http://sqlblogcasts.com/blogs/danny/archive/2008/01/12/scuffling-with-string-or-binary-data-would-be-truncated.aspx

create procedure cst_checktruncatederror  as
begin
set nocount on
declare @src nvarchar(max) = 'sourcetable'
declare @tgt nvarchar(max) = 'targettable'
declare @cols nvarchar(max)
declare @sql nvarchar(max)

-- create temporary empty version of destination table (target proxy)
-- note: use a global temp table, because a normal one goes out-of-scope when the dynamic sql returns
if (object_id('tempdb..##target') is not null) drop table ##target
set @sql = concat('SELECT * INTO ##target FROM ',@tgt,' where 1=0')
print @sql
exec sp_executesql @sql

-- get a comma-separated string with block-quoted columnnames that are comparable
set ansi_padding on
set @sql = concat('
select @colsOUT =
substring
(
(
select concat('',['',column_name,'']'')
from information_schema.columns
where table_name = ''',@tgt,'''
and data_type <> ''geography''
for xml path(''''), type
).value(''.'',''nvarchar(max)'')
,2,100000
)
')
print @sql
exec sp_executesql @sql, N'@colsOUT nvarchar(max) OUTPUT', @colsOUT=@cols OUTPUT
print @cols

-- load source to target proxy
set @sql = concat('
INSERT INTO ##target (',@cols,')
SELECT ',@cols,'
FROM ',@src,'
')
print @sql

SET ANSI_WARNINGS OFF -- truncates fields instead of throwing "string or binary data would be truncated error" error!
-- 1. do not use * to insert, because the column order might be off
-- 2. wrap fieldnames in blockquotes [] because reserved words might have been used, e.g. STATE or UNIQUE
-- 3. exclude data types: geography
-- 4. TO DO: destination columns might be NULLable, while the source is not. That results in a different error
exec sp_executesql @sql
SET ANSI_WARNINGS ON

-- return violating records
set @sql = concat('
SELECT ',@cols,'
FROM ',@src,'
except
SELECT ',@cols,'
FROM ##target
')
print @sql
exec sp_executesql @sql

-- clean up
if (object_id('tempdb..##target') is not null) drop table ##target
end

Install Epson AcuLaser AL-C900 on Windows 8

The Epson C900 AcuLaser can be easily installed on Windows 7 x64 and before using the Vista x64 driver available from the Epson website. In fact, most legacy printers can be installed using this method.

There might be an official in-box driver available for your (older) Windows operating system, i.e. it comes shipped with the C900 driver and recognizes the printer when it is connected via USB. No downloaded driver is then required.

Officially, there is no support and no driver for Windows 8 x64 for this printer. But luckily, the in-box driver is still present; it is just not recognized automatically on connection.

Manually install the Epson AL-C900 driver

Perform the following steps to get any legacy printer working on Windows 8:
  1. Open Devices and Printers
  2. Add a printer
  3. Click "The printer that I want isn't listed"
  4. Select "Add a local printer", next
  5. Select "Use an existing port" and select "USB000", next
    This "Virtual printer port for USB" only exists when the printer is connected and turned on!
  6. Select the following driver:
    Manufacturer: Epson
    Printers: Epson AL-C900
    Note: if the AL-C900 is not in the list, press "Windows Update" to get it
    next
  7. Done!
The printer will now function, but only on the physical USB port that is linked to the virtual USB000 port. You need to figure out by trying port for port which one this is. Also note that in some cases it can take up to five minutes for a print job to start on this printer.

Delete an existing port mapping

Delete an existing - visible or invisible - port mapping as follows:
  1. Open Device and Printers
  2. Click Print server properties
  3. Select Ports tab
  4. Select USB port with the mapped printer driver
  5. Click "Delete port"
Cannot delete port

Clear the printer spool folder beforehand by running these statements from a command prompt and reboot:

net stop spooler
del %systemroot%\system32\spool\printers\*.shd
del %systemroot%\system32\spool\printers\*.spl
net start spooler

USB printer is not recognized

If the USB printer is not recognized by Windows 8.1 (you don't even get the "USB device not recognized" message) then try the following:
  • Control Panel -> Troubleshooting -> Hardware and Sound: Use a printer-> Next
  • Device Manager -> Universal Serial Bus controllers -> Delete all Generic USB Hub entries and reboot
After reboot, open the Device Manager and plug in the printer. It should automatically appear. When the unplugged, it should immediately disappear.