May 21, 2010 at 2:03 pm
hi experts,
This is 2005.
This code generates a report - works fine.
But I want to reduce the column width so each line will be on 1 line when the report is printed.
When I try SELECT CAST(ServerName varchar(15)) as Server,
I get error "Incorrect syntax near 'varchar'."
How can I trim the column width on the output?
Thanks, John
SET @sqlcmd = 'sqlcmd -Q '
SET @cmd = '"SELECT CAST(ServerName varchar(15)) as Server, LoginName as FailedLogin, ClientName as ComputerName, LoginDate from DBA.dbo.AuditDatabaseLogins WHERE AuditType = ''Login Failed'' AND LoginDate between ''' + convert(varchar(10), @PriorMonthStart, 112) + ''' and ''' + convert(varchar(10), @PriorMonthEnd, 112) + ''' " -o C:\AuditReports\TestSqlCmd35.txt'
SET @sqlcmd = @sqlcmd + @cmd;
Print @sqlcmd;
EXEC xp_cmdshell @sqlcmd,no_output;
May 22, 2010 at 11:39 am
SELECT CAST(ServerName [font="Arial Black"]AS[/font] varchar(15)) as Server,
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply