Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / July 2008

Tip: Looking for answers? Try searching our database.

SQL Query via the command line pt.2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pand0ra.usa - 30 Jul 2008 16:44 GMT
A couple of more questions oh mighty SQL admins! What do the
following command(s) do? Is this one command or several different
ones? And can I execute this in the same manner as the previous
command (OSQL)?

sysname, Object sysname, Grantee sysname, Grantor sysname,
ProtectTypeuse msdb
CREATE TABLE #ProcPermissions
( Owner  nvarchar(10),
eAction nvarchar(20), eColumn sysname)
INSERT INTO #ProcPermissions EXEC sp_helprotect 'sp_add_dtspackage'
INSERT INTO #ProcPermissions EXEC sp_helprotect 'sp_add_job'
INSERT INTO #ProcPermissions EXEC sp_helprotect 'sp_add_jobstep'
INSERT INTO #ProcPermissions EXEC sp_helprotect 'sp_enum_dtspackages'
SELECT * FROM #ProcPermissions
DROP table #ProcPermissions

Thank you so much for your time!

On Jul 26, 7:50 am, "Tibor Karaszi"

- Hide quoted text -
- Show quoted text -
<tibor_please.no.email_kara...@hotmail.nomail.com> wrote:
> All is in what datatype that function (SERVERPROPERTY) returns. It returns an sql_variant, which can
> *potentially* be a varchar(8000), then the client tool (OSQL) plays it safe by having the output as
> 8000 characters wide. What you can do is to surround the function call with CAST, and pick a
> suitable datatype and length. Something like:

> osql -E -w 5000 -O -Q "SELECT CAST(SERVERPROPERTY('productversion') AS varchar(50)) as version,
> CAST(SERVERPROPERTY('productlevel') AS varchar(50)) as SP, CAST(SERVERPROPERTY('edition') AS
> varchar(50)) as edition"

> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/...

> "pand0ra.usa" <pand0ra....@gmail.com> wrote in message

> news:9967d254-ca72-4a2e-a6cc-6051fb9bc6bd@z72g2000hsb.googlegroups.com...

> > Hello all,
> > I am trying to create a batch file that will pull a list of hosts from
> > a text file and then connect to each host and run some designated SQL
> > commands against those MS SQL hosts. I have been trying to use
> > OSQL.EXE but it pads the output with thousands of training spaces for
> > each column. Is there a way to trim those spaces off in the SQL
> > statement (I don't know SQL at all) or another program that would work
> > better? It's a pain to have each column 8000+ characters wide (~7950
> > of those characters are spaces).

> > osql -S <ipaddress> -U user -P password -w 50 -O -Q "SELECT
> > SERVERPROPERTY('productversion') as version, SERVERPROPERTY
> > ('productlevel') as SP, SERVERPROPERTY ('edition') as edition" >
> > sql1.txt
Hugo Kornelis - 31 Jul 2008 19:15 GMT
>Thank you so much for your time!

I just replied to the first version of this message.

Signature

Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.