Showing posts with label scripting. Show all posts
Showing posts with label scripting. Show all posts

Tuesday, March 20, 2012

Other Generate Script problems in SQL Server Management Studio

Why have often used scripting settings been removed from SQL Server 2005:

Issues associated with Scripting options:

Query Analyzer allowed the following generic options that have been removed from SSMS:
Identifier Delimiter : None, Version dependent, [] or ""
Do not script the collation.
Generate Transact-SQL to remove referenced component. Script tests for existence prior to attempt to remove component.
Do not include 'ON <filegroup>' clause directing filegroup use.
and table Scripting Options:
Qualify object name by its owner.
Do not include definition of identity property, seed, and increment.
Generate SET ANSI_PADDING ON and SET ANSI_PADDING OFF statements before CREATE TABLE statements.

Also Enterprise Manager Generate SQL Scripts tool had:
Files to Generate: Create one file or one file per object - Gone!
Create Drop object options - now it's one or the other.

As

someone else said in another post - why have Microsoft removed useful functionality

from the scripting options. It doesn't make sense - were these options

over looked or was it a conscious decision.

When will these

settings be reinstated - (and they need to be able to be set for the

whole IDE as well as in the wizard (as per Query Analyzer:Tools|Options

)

3rd Party Scripter for me until this is fixed - damn just need to find one now!

Alex

Hi Alex,

Some of these you will see addressed in SP2 -- Such as Create Drop options.

The others are in backlog of work items for the next general release of SQL Server.

A partial - (as in brief) explanation for why some disappeared had to do with 'forward' compatibility.

I will log your input in our Team Server database if you don't mind.

Thanks,

Terrence Nevins

SQL Server Program Manager

Other Generate Script problems in SQL Server Management Studio

Why have often used scripting settings been removed from SQL Server 2005:

Issues associated with Scripting options:

Query Analyzer allowed the following generic options that have been removed from SSMS:
Identifier Delimiter : None, Version dependent, [] or ""
Do not script the collation.
Generate Transact-SQL to remove referenced component. Script tests for existence prior to attempt to remove component.
Do not include 'ON <filegroup>' clause directing filegroup use.
and table Scripting Options:
Qualify object name by its owner.
Do not include definition of identity property, seed, and increment.
Generate SET ANSI_PADDING ON and SET ANSI_PADDING OFF statements before CREATE TABLE statements.

Also Enterprise Manager Generate SQL Scripts tool had:
Files to Generate: Create one file or one file per object - Gone!
Create Drop object options - now it's one or the other.

As someone else said in another post - why have Microsoft removed useful functionality from the scripting options. It doesn't make sense - were these options over looked or was it a conscious decision.

When will these settings be reinstated - (and they need to be able to be set for the whole IDE as well as in the wizard (as per Query Analyzer:Tools|Options )

3rd Party Scripter for me until this is fixed - damn just need to find one now!

Alex

Hi Alex,

Some of these you will see addressed in SP2 -- Such as Create Drop options.

The others are in backlog of work items for the next general release of SQL Server.

A partial - (as in brief) explanation for why some disappeared had to do with 'forward' compatibility.

I will log your input in our Team Server database if you don't mind.

Thanks,

Terrence Nevins

SQL Server Program Manager

Friday, March 9, 2012

osql script

I have two Osql scripting questions for windows?
1. How can I get my OSQL script to output to a CVS file. Such as "select *
from itemtable"
2. How can I create a osql backup script to will name the backup filename
system_date.bck. This way I have a backup for each day by date.
Thanks
Dan
hi Dan,
Danny wrote:
> I have two Osql scripting questions for windows?
> 1. How can I get my OSQL script to output to a CVS file. Such as "select *
> from itemtable"
SET NOCOUNT ON;
USE pubs;
GO
DECLARE @.fullcmd varchar(1000);
DECLARE @.cmd varchar(1000);
SET @.cmd = 'SELECT * FROM pubs.dbo.authors';
SET @.fullcmd = 'osql -S(Local) -E -q "' + @.cmd + '" -o c:\authors.txt';
-- this will result in a tab delimited columns output..
EXEC master..xp_cmdshell @.fullcmd ;
-- but you can prepare a format file as required, see BOL
PRINT 'PREPARE a format file';
SET @.fullcmd = 'bcp pubs.dbo.authors format nul -c -f c:\f.txt -T'
--EXEC master..xp_cmdshell @.fullcmd ;
PRINT 'MANUALLY MODIFY THE format file setting the "," as column separator
instead of the tab char';
SET @.fullcmd = 'bcp "' + @.cmd + '" queryout "c:\bcpAuthors.txt" -f
c:\f.txt -T';
SELECT @.fullcmd;
EXEC master..xp_cmdshell @.fullcmd;

> 2. How can I create a osql backup script to will name the backup
> filename system_date.bck. This way I have a backup for each day by
> date.
DECLARE @.db sysname;
DECLARE @.dir varchar(500);
DECLARE @.file varchar(256);
SELECT @.db = 'pubs', @.dir = 'c:\', @.file = CONVERT(varchar(8), GETDATE(),
112) + '_' + @.db + '.bak';
DECLARE @.fullpath varchar(1000);
SET @.fullpath = @.dir + @.file;
SELECT @.fullpath;
BACKUP DATABASE @.db
TO DISK = @.fullpath
WITH INIT;
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz http://italy.mvps.org
DbaMgr2k ver 0.21.0 - DbaMgr ver 0.65.0 and further SQL Tools
-- remove DMO to reply