Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Tuesday, February 14, 2012

CommandText on Report Server

When a report runs is it possible to retrieve the command text and modify it in order to append some additional "where" conditions, before the sql is processed to return data to the report?

You can write code like this

declare sSQL varchar(500)

declare sWhere varchar(200)

set sSQL = "Select * from mytable"

if lenght(@.Parameter1) > 0

begin

sWhere = " Where mycolume = '" + @.Parameter2 + "'"

end

sSQL = sSQL + sWhere

EXEC (sSQL)

|||

Thanks for the reply, but I need to be clearer with the question that I am asking.

I have written code to construct the piece of SQL that I need to append - it retrieves conditions from the database which define some additional filtering for security.

What I need to know is if it is possible at runtime to trap the SQL statement stored in the <CommandText> element of the RDL for the report that is running - append my additional segment of SQL just before it gets processed. Bear in mind that a Report designed may have several SQL statements from individual parts of the overall report - a data set tp provide values for parameters, a dataset for each section on a report, chart and matrix for example.

Should I be looking at doing it via a Data Processing extension, therefore trapping any report that that is run via SSRS?

Command works in DOS but not in xp_cmdshell

Can anyone give clues as to why the same copy command works in
DOS and not in xp_command shell.I am an admin in both servers and
in the database.

The results indicate one file is copied but no file is found
at destination.

Your input is appreciated

Vincento

copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"

works just fine but

use
master
exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"'What is the user context that the script is running in? Usually it is
system (I think), which isn't going to have access rights to corp156.

Zach

Vincento Harris wrote:
> Can anyone give clues as to why the same copy command works in
> DOS and not in xp_command shell.I am an admin in both servers and
> in the database.
> The results indicate one file is copied but no file is found
> at destination.
> Your input is appreciated
> Vincento
>
>
> copy "D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\back1.
> txt" "\\corp156\d$\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\"
> works just fine but
> use
> master
> exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\back1.
> txt" "\\corp156\d$\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\"'|||"Vincento Harris" <wumutek@.yahoo.com> wrote in message
news:2fa13ee7.0410130938.3a4db7ec@.posting.google.c om...
> Can anyone give clues as to why the same copy command works in
> DOS and not in xp_command shell.I am an admin in both servers and
> in the database.
> The results indicate one file is copied but no file is found
> at destination.
> Your input is appreciated
> Vincento
>
>
> copy "D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\back1.
> txt" "\\corp156\d$\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\"
> works just fine but
> use
> master
> exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\back1.
> txt" "\\corp156\d$\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\QMISDEV\"'

I tried this out, and it worked fine for me (I didn't test using a share,
but I did test using folder names with spaces) - was the result you saw "1
file(s) copied"? Or did you run this as a scheduled job perhaps? When a
sysadmin executes xp_cmdshell, it runs as the MSSQL service account, so you
might want to check that account's permissions also.

Simon|||"Simon Hayes" <sql@.hayes.ch> wrote in message news:<416d9609$1_3@.news.bluewin.ch>...
> "Vincento Harris" <wumutek@.yahoo.com> wrote in message
> news:2fa13ee7.0410130938.3a4db7ec@.posting.google.c om...
> > Can anyone give clues as to why the same copy command works in
> > DOS and not in xp_command shell.I am an admin in both servers and
> > in the database.
> > The results indicate one file is copied but no file is found
> > at destination.
> > Your input is appreciated
> > Vincento
> > copy "D:\Program Files\Microsoft SQL
> > Server\MSSQL\BACKUP\QMISDEV\back1.
> > txt" "\\corp156\d$\Program Files\Microsoft SQL
> > Server\MSSQL\BACKUP\QMISDEV\"
> > works just fine but
> > use
> > master
> > exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
> > Server\MSSQL\BACKUP\QMISDEV\back1.
> > txt" "\\corp156\d$\Program Files\Microsoft SQL
> > Server\MSSQL\BACKUP\QMISDEV\"'
> I tried this out, and it worked fine for me (I didn't test using a share,
> but I did test using folder names with spaces) - was the result you saw "1
> file(s) copied"? Or did you run this as a scheduled job perhaps? When a
> sysadmin executes xp_cmdshell, it runs as the MSSQL service account, so you
> might want to check that account's permissions also.
> Simon
I appreciate your answers guys .It does work on the same server for me too.
When the mssqlserver was under local admin account
The result was " Access denied"

When I made this account part of the admin account
The result was "1 file copied" and it actually works

So my problem was not making mssqlservice account an admin
of the //server (//corp156)

Thanks again for the exceptional contributions I always get from
this group

Vincento

command window open when SQL agent start

When i start mssqlserver service, it do not start SQLAgent
It is listed in the dependancies of both
when i start the sqlAgent manually, there is a command window that opens up with nothing in it, just the cursor blinking, BUT everything runs fine, the msssqlServer and the SQLAgent are both running
if i close that window, SQLAgent stop, and naturally, the connection to the DB is lost as well.
This never use to do that before
?
Thanx
************************************************** ********************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
You need to check the configuration for the service. Go to
Services(from Control Panel or Administrative Tools -
depending on your OS).
Go to the sqlserveragent service and view the properties for
the service. Select the LogOn tab and make sure to uncheck
the "Allow service to interact with desktop" checkbox.
-Sue
On Wed, 23 Jun 2004 07:51:56 -0700, korivo
(mathieu_corriveau@.hotmail.com) wrote:

>When i start mssqlserver service, it do not start SQLAgent
>It is listed in the dependancies of both
>when i start the sqlAgent manually, there is a command window that opens up with nothing in it, just the cursor blinking, BUT everything runs fine, the msssqlServer and the SQLAgent are both running
>if i close that window, SQLAgent stop, and naturally, the connection to the DB is lost as well.
>This never use to do that before
>?
>Thanx
>************************************************* *********************
>Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
>Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

command window open when SQL agent start

When i start mssqlserver service, it do not start SQLAgent
It is listed in the dependancies of both
when i start the sqlAgent manually, there is a command window that opens up
with nothing in it, just the cursor blinking, BUT everything runs fine, the
msssqlServer and the SQLAgent are both running
if i close that window, SQLAgent stop, and naturally, the connection to the
DB is lost as well.
This never use to do that before
?
Thanx
****************************************
******************************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...You need to check the configuration for the service. Go to
Services(from Control Panel or Administrative Tools -
depending on your OS).
Go to the sqlserveragent service and view the properties for
the service. Select the LogOn tab and make sure to uncheck
the "Allow service to interact with desktop" checkbox.
-Sue
On Wed, 23 Jun 2004 07:51:56 -0700, korivo
(mathieu_corriveau@.hotmail.com) wrote:

>When i start mssqlserver service, it do not start SQLAgent
>It is listed in the dependancies of both
>when i start the sqlAgent manually, there is a command window that opens up
with nothing in it, just the cursor blinking, BUT everything runs fine, the
msssqlServer and the SQLAgent are both running
>if i close that window, SQLAgent stop, and naturally, the connection to the
DB is lost as well.
>This never use to do that before
>?
>Thanx
> ****************************************
******************************
>Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
>Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resourc
es...

Command USE with variable

Why I can′t use the command USE with variable?

declare @.banco varchar(20)
select @.banco='xpto'
USE @.banco

I have try in other way without success

DECLARE @.banco varchar(50)
declare @.SQL varchar(50)
select @.banco='xpto'
print @.banco
select @.SQL='USE '+@.banco
print @.SQL
exec(@.SQL)

Help me, please.

Rodrigo

It is executed at both compile time and run time, so I presume that is the reason. Not all commands can use variables in place of constants. the TOP command, for instance, only takes constants until it was altered in SQL 2005. For USE sysntax and description:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_tsqlcon_6lyk.asp

|||

I am developing a routine to desfragment
the indexes of all tables of the server... I′ve found one in the books online (DBCC SHOWCONTIG session), but I ′m trying to convert it to defrag all objetcs in all databases of my instance. So I have think in a "Cursor" that get the name of the databases in the "sysdatabases" system table. Than set each database to current and run the script. Fallow the script:

For this, I have think in set the database to run the script on the database context.

Can you help me?

/*Perform a 'USE <database name>' to select the database in which to run the script.*/ -- Declare variables SET NOCOUNT ON DECLARE @.tablename VARCHAR (128) DECLARE @.execstr VARCHAR (255) DECLARE @.objectid INT DECLARE @.indexid INT DECLARE @.frag DECIMAL DECLARE @.maxfrag DECIMAL -- Decide on the maximum fragmentation to allow SELECT @.maxfrag = 30.0 -- Declare cursor DECLARE tables CURSOR FOR SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' -- Create the table CREATE TABLE #fraglist ( ObjectName CHAR (255), ObjectId INT, IndexName CHAR (255), IndexId INT, Lvl INT, CountPages INT, CountRows INT, MinRecSize INT, MaxRecSize INT, AvgRecSize INT, ForRecCount INT, Extents INT, ExtentSwitches INT, AvgFreeBytes INT, AvgPageDensity INT, ScanDensity DECIMAL, BestCount INT, ActualCount INT, LogicalFrag DECIMAL, ExtentFrag DECIMAL) -- Open the cursor OPEN tables -- Loop through all the tables in the database FETCH NEXT FROM tables INTO @.tablename WHILE @.@.FETCH_STATUS = 0 BEGIN -- Do the showcontig of all indexes of the table INSERT INTO #fraglist EXEC ('DBCC SHOWCONTIG (''' + @.tablename + ''') WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS') FETCH NEXT FROM tables INTO @.tablename END -- Close and deallocate the cursor CLOSE tables DEALLOCATE tables -- Declare cursor for list of indexes to be defragged DECLARE indexes CURSOR FOR SELECT ObjectName, ObjectId, IndexId, LogicalFrag FROM #fraglist WHERE LogicalFrag >= @.maxfrag AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0 -- Open the cursor OPEN indexes -- loop through the indexes FETCH NEXT FROM indexes INTO @.tablename, @.objectid, @.indexid, @.frag WHILE @.@.FETCH_STATUS = 0 BEGIN PRINT 'Executing DBCC INDEXDEFRAG (0, ' + RTRIM(@.tablename) + ', ' + RTRIM(@.indexid) + ') - fragmentation currently ' + RTRIM(CONVERT(varchar(15),@.frag)) + '%' SELECT @.execstr = 'DBCC INDEXDEFRAG (0, ' + RTRIM(@.objectid) + ', ' + RTRIM(@.indexid) + ')' EXEC (@.execstr) FETCH NEXT FROM indexes INTO @.tablename, @.objectid, @.indexid, @.frag END -- Close and deallocate the cursor CLOSE indexes DEALLOCATE indexes -- Delete the temporary table DROP TABLE #fraglist GO |||

Here is one way with using sp_MSforeachdb and DBCC DBREINDEXALL

Both of these things are undocumented and you might not want to run it on a production server

EXEC sp_MSForEachDB 'IF ''?'' NOT IN (''master'', ''model'', ''msdb'', ''tempdb'')
DBCC DBREINDEXALL (''?'') '

-- nobody can be connected to the db for the above statement to work

also you could do something like this

DECLARE @.SQL NVarchar(4000)
SET @.SQL = ''
SELECT @.SQL = @.SQL + 'EXEC ' + NAME + '..sp_MSforeachtable @.command1=''DBCC DBREINDEX (''''*'''')'', @.replacechar=''*''' + Char(13)
FROM MASTER..Sysdatabases
where dbid > 6
PRINT @.SQL

EXEC (@.SQL)

However if you exceed 4000 characters this will fail

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||

For EXECUTE you can use varchar(8000), or in 2005 you can use varchar(max).

|||Please don't use undocumented system stored procedures. They are not guaranteed to remain in every version of SQL Server. In fact we removed several system stored procedures or modified their behavior in SQL Server 2005.|||

Set options or use statement executed within dynamic SQL is only valid within that scope. So in your case, you have to perform the USE and the DBCC statement within the same dynamic SQL execution like:

exec('use ' + @.somedb + '; dbcc index...')

Command Type for dataset using Custom Data Processing Extension

Hi,
I'm writing a custom data processing extension, but I cannot get
anything other than a command type of "Text" in the dataset for the
report I have setup to use the Data extension I have written.
Does anyone know what or where the available command types are derived
from?
GregI still haven't had any luck resolving this, hoping someone can help :)

command type = Stored procedure

Hi,
does anyone know an URL with an example of using "StoredProcedure" as
"Command type" in reporting services. Normally it defaults to "Text" instead
of "StoredProcedure"
thanks,
Ludowell its the same as the text only u write the name of the sp(no need exec..).
if the sp has input parameters the RS will add them by default as Report
parameters.
I think it's the best way 2 use RS...
"Ludo Van Dun" wrote:
> Hi,
> does anyone know an URL with an example of using "StoredProcedure" as
> "Command type" in reporting services. Normally it defaults to "Text" instead
> of "StoredProcedure"
> thanks,
> Ludo
>
>

Command to start SQL Server Enterprise Manager

Hi,
Is there any command to start SQL Server Enterprise Manager from
the command prompt other than "SQL Server Enterprise Manager.MSC"
which cannot be called a short-cut.
Regards,
sasi.
Unless this IS an mmc snap-in there is no workaround for that. AFAIK
HTH, jens Suessmeyer.
|||sasiraj wrote on 20 Oct 2005 02:11:58 -0700:

> Is there any command to start SQL Server Enterprise Manager from
> the command prompt other than "SQL Server Enterprise Manager.MSC"
> which cannot be called a short-cut.
How about creating a batch file with a short name, and put
start "" "sql server enterprise manager.msc"
in it. The initial "" is there because start treats the first item as a
window title if it is enclosed in quotes, and you need to quote the msc
filename due to the spaces. This line will start EM and then the batch file
will immediately exit. Call it something like sqlem.cmd and put it somewhere
in your PATH (eg. c:\windows) and then you can run EM using just sqlem at
the command line.

Dan

Command to run for a query

I nee to query the passwordtxt table. I have never even made a query before
and i was wondering if some couold tell me the command to do so. I have the
table selected but not sure what to type in the window
Thanks
If you want to return data from a table the "SELECT" command is used. Here
is the syntax for a SELECT command (from Books Online). To find out more
read Books Online.
SELECT select_list
[ INTO new_table ]
FROM table_source
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] ]
----
-
Need SQL Server Examples check out my website
http://www.geocities.com/sqlserverexamples
"rocker40" <rocker40@.discussions.microsoft.com> wrote in message
news:F0AA7C7E-56C0-457E-80ED-D9A76C9C80F7@.microsoft.com...
> I nee to query the passwordtxt table. I have never even made a query
before
> and i was wondering if some couold tell me the command to do so. I have
the
> table selected but not sure what to type in the window
> Thanks

Command to run for a query

I nee to query the passwordtxt table. I have never even made a query before
and i was wondering if some couold tell me the command to do so. I have the
table selected but not sure what to type in the window
ThanksIf you want to return data from a table the "SELECT" command is used. Here
is the syntax for a SELECT command (from Books Online). To find out more
read Books Online.
SELECT select_list
[ INTO new_table ]
FROM table_source
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] ]
----
----
-
Need SQL Server Examples check out my website
http://www.geocities.com/sqlserverexamples
"rocker40" <rocker40@.discussions.microsoft.com> wrote in message
news:F0AA7C7E-56C0-457E-80ED-D9A76C9C80F7@.microsoft.com...
> I nee to query the passwordtxt table. I have never even made a query
before
> and i was wondering if some couold tell me the command to do so. I have
the
> table selected but not sure what to type in the window
> Thanks

command to reference another table

Hi all,

I am new to this site and I hope anyone out there can help me. I was tasked to change the constraints of my existing table. Lets call it table1. This table has an attribute that needs to take the value of another attribute of another table ( let's call it tables2) and that attribute must satisfy a certain expression ( I suppose I can isolate it by using the select statement ).

Anyone know how to get this done.

Please advice.

Thanks and appreciated.Hi all,

I am new to this site and I hope anyone out there can help me. I was tasked to change the constraints of my existing table. Lets call it table1. This table has an attribute that needs to take the value of another attribute of another table ( let's call it tables2) and that attribute must satisfy a certain expression ( I suppose I can isolate it by using the select statement ).

Anyone know how to get this done.

Please advice.

Thanks and appreciated.
u have given very little information.Read the sticky (first post on this forum) first|||This sounds like homework to me. If it is, please post the URL for the assignment, or at least scan the page so we can see the "whole tamale" and solve the problem once instead of giving you what you asked for, but not what the teacher wants. If this is not homework, please see How to ask a question to get quick and correct answers? (http://www.dbforums.com/showthread.php?t=1212452#post4527530) in this forums FAQ.

-PatP|||Hi all,

I have yet to try this statement:-

alter table coursefee
add check ( course_code = course.course_code and
course.quota is not null );

coursefee :- table1
course_code :- PK of table1
course :- table2
course.course_code :- PK of table2
course.quota :- another attribute of table2

My intention is set a constraint on table1 where there will be an error if there is an insert on table2 whereby quota ( from table1) is null.

Is this plausible?

Sorry to trouble all again.|||I don't think you can reference another table in a CHECK CONSTRAINT. I suspect that you'll need to use a trigger if you really want to do this, but I wouldn't recommend doing it, for many reasons.

-PatP

command to load data from txt file to sql server 2005

Hi guys,

i would like to know the command used to load the data from the txt file to the sql server 2005.

Thanks in advance

Lalitha

Check this thread for suggestions:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1746695&SiteID=1

Command to export data from sql server to text file in sql query analyzer

Hi,
Does anyone know how to export a query to a text file by using query
analyzer with command, i dun want to manual click it.
Thanks a lot!
regards,
florenceleeDo you mean save the results to a file? If so, you can set the output of
the query to go to Text, Grid or File from the Query pull-down menu. If you
don't even want to do that then you could use osql.exe rather than Query
Analyzer. The -o parameter allows you to specify an output file to which
you'd like the query results to go.
Cheers,
Mike
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> Hi,
> Does anyone know how to export a query to a text file by using query
> analyzer with command, i dun want to manual click it.
>
> --
> Thanks a lot!
> regards,
> florencelee
>|||Hi,
I understand by using osql, can use sql quey analyzer and i dun want
to output to text file and save manually, i just want a command which can
behave in the same way as in osql but i need to do in query analyzer'
Thanks a lot!
regards,
florencelee
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> Hi,
> Does anyone know how to export a query to a text file by using query
> analyzer with command, i dun want to manual click it.
>
> --
> Thanks a lot!
> regards,
> florencelee
>|||There's not a TSQL command for that. Most of us who need to do this in TSQL
use xp_cmdshell and
OSQL.EXE.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:%23CjGX9r0EHA.1932@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I understand by using osql, can use sql quey analyzer and i dun want
> to output to text file and save manually, i just want a command which can
> behave in the same way as in osql but i need to do in query analyzer'
> --
> Thanks a lot!
> regards,
> florencelee
> "Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
> news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
>

Command to export data from sql server to text file in sql query analyzer

Hi,
Does anyone know how to export a query to a text file by using query
analyzer with command, i dun want to manual click it.
Thanks a lot!
regards,
florencelee
Do you mean save the results to a file? If so, you can set the output of
the query to go to Text, Grid or File from the Query pull-down menu. If you
don't even want to do that then you could use osql.exe rather than Query
Analyzer. The -o parameter allows you to specify an output file to which
you'd like the query results to go.
Cheers,
Mike
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> Hi,
> Does anyone know how to export a query to a text file by using query
> analyzer with command, i dun want to manual click it.
>
> --
> Thanks a lot!
> regards,
> florencelee
>
|||Hi,
I understand by using osql, can use sql quey analyzer and i dun want
to output to text file and save manually, i just want a command which can
behave in the same way as in osql but i need to do in query analyzer?
Thanks a lot!
regards,
florencelee
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> Hi,
> Does anyone know how to export a query to a text file by using query
> analyzer with command, i dun want to manual click it.
>
> --
> Thanks a lot!
> regards,
> florencelee
>
|||There's not a TSQL command for that. Most of us who need to do this in TSQL use xp_cmdshell and
OSQL.EXE.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:%23CjGX9r0EHA.1932@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I understand by using osql, can use sql quey analyzer and i dun want
> to output to text file and save manually, i just want a command which can
> behave in the same way as in osql but i need to do in query analyzer?
> --
> Thanks a lot!
> regards,
> florencelee
> "Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
> news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
>

Command to export data from sql server to text file in sql query analyzer

Hi,
Does anyone know how to export a query to a text file by using query
analyzer with command, i dun want to manual click it.
--
Thanks a lot!
regards,
florenceleeDo you mean save the results to a file? If so, you can set the output of
the query to go to Text, Grid or File from the Query pull-down menu. If you
don't even want to do that then you could use osql.exe rather than Query
Analyzer. The -o parameter allows you to specify an output file to which
you'd like the query results to go.
--
Cheers,
Mike
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> Hi,
> Does anyone know how to export a query to a text file by using query
> analyzer with command, i dun want to manual click it.
>
> --
> Thanks a lot!
> regards,
> florencelee
>|||Hi,
I understand by using osql, can use sql quey analyzer and i dun want
to output to text file and save manually, i just want a command which can
behave in the same way as in osql but i need to do in query analyzer'
--
Thanks a lot!
regards,
florencelee
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> Hi,
> Does anyone know how to export a query to a text file by using query
> analyzer with command, i dun want to manual click it.
>
> --
> Thanks a lot!
> regards,
> florencelee
>|||There's not a TSQL command for that. Most of us who need to do this in TSQL use xp_cmdshell and
OSQL.EXE.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:%23CjGX9r0EHA.1932@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I understand by using osql, can use sql quey analyzer and i dun want
> to output to text file and save manually, i just want a command which can
> behave in the same way as in osql but i need to do in query analyzer'
> --
> Thanks a lot!
> regards,
> florencelee
> "Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
> news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> > Hi,
> > Does anyone know how to export a query to a text file by using query
> > analyzer with command, i dun want to manual click it.
> >
> >
> > --
> > Thanks a lot!
> >
> > regards,
> >
> > florencelee
> >
> >
>|||Florencelee,
Press Ctrl-Shift-F in Query Analyzer.
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
Florencelee wrote:
> Hi,
> Does anyone know how to export a query to a text file by using query
> analyzer with command, i dun want to manual click it.
>
> --
> Thanks a lot!
> regards,
> florencelee
>|||You can use xp_cmdshell and BCP OUT ... This combination works great...
Thanks
GYK
"Tibor Karaszi" wrote:
> There's not a TSQL command for that. Most of us who need to do this in TSQL use xp_cmdshell and
> OSQL.EXE.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
> news:%23CjGX9r0EHA.1932@.TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I understand by using osql, can use sql quey analyzer and i dun want
> > to output to text file and save manually, i just want a command which can
> > behave in the same way as in osql but i need to do in query analyzer'
> >
> > --
> > Thanks a lot!
> >
> > regards,
> >
> > florencelee
> > "Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
> > news:uQMYVup0EHA.2572@.tk2msftngp13.phx.gbl...
> > > Hi,
> > > Does anyone know how to export a query to a text file by using query
> > > analyzer with command, i dun want to manual click it.
> > >
> > >
> > > --
> > > Thanks a lot!
> > >
> > > regards,
> > >
> > > florencelee
> > >
> > >
> >
> >
>
>

Command to display SQL Statements

Does anyone know the command to display the whole SQL statement for a
connection after apply sp3?
Thanks,
LijunTake a look at the fn_get_sql topic in books online, assuming you updated...
"Lijun Zhang" <nospam@.nospam.nospam> wrote in message
news:#UPomeMnDHA.2592@.TK2MSFTNGP10.phx.gbl...
> Does anyone know the command to display the whole SQL statement for a
> connection after apply sp3?
> Thanks,
> Lijun
>|||Hi Lijun,
I agree with Aaron, you can use the fn_get_sql function to retrieve the SQL handle (sql_handle
column of the sysprocesses) and help you diagnose problematic processes.
You can also use "DBCC INPUTBUFFER" to easily display the LAST statement sent from a
client. The system process ID (SPID) for the user connection can be displayed in the output of
the sp_who system stored procedure.
Does that answer your question? Please feel free to post in the group if this solves your
problem or if you would like further assistance.
Best regards,
Billy Yao
Microsoft Online Partner Support

Command to clear DTS Package Logs + Versions

Hello. Is there any command that you can clear old DTS
package execution Logs? Also, when you store packages as
*.dts files, it saves the versions right in the file. Is
there a command that can clear older versions, either ALL
of them, or say, after 30 days?!? I know these things
can be done manully thru the GUI, looking for a way to
automate it if possible. Thanks, BruceRegarding the structured storage files, we always delete the existing DTS
file before saving so the file only contains one version. We keep the
packages under source control for versioning.
Hope this helps.
Dan Guzman
SQL Server MVP
"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
news:3bc501c51fff$3d0b4f00$a601280a@.phx.gbl...
> Hello. Is there any command that you can clear old DTS
> package execution Logs? Also, when you store packages as
> *.dts files, it saves the versions right in the file. Is
> there a command that can clear older versions, either ALL
> of them, or say, after 30 days?!? I know these things
> can be done manully thru the GUI, looking for a way to
> automate it if possible. Thanks, Bruce|||And in terms of the package logs, you would need to write
your own utility using the DTS Object model. Search books
online for the RemovePackageLogRecords method. In terms of
deleting based on dates, the package log date is tied to the
PackageLogRecord object.
-Sue
On Thu, 3 Mar 2005 06:42:35 -0800, "Bruce de Freitas"
<bruce@.defreitas.com> wrote:

>Hello. Is there any command that you can clear old DTS
>package execution Logs? Also, when you store packages as
>*.dts files, it saves the versions right in the file. Is
>there a command that can clear older versions, either ALL
>of them, or say, after 30 days?!? I know these things
>can be done manully thru the GUI, looking for a way to
>automate it if possible. Thanks, Bruce|||Thanks Dan, was hoping there was some automated
method/command of clearing the old versions, as they
exist already on numerous packages. Doesn't sound it.
THanks, Bruce
>--Original Message--
>Regarding the structured storage files, we always delete
the existing DTS
>file before saving so the file only contains one
version. We keep the
>packages under source control for versioning.
>--
>Hope this helps.
>Dan Guzman
>SQL Server MVP
>"Bruce de Freitas" <bruce@.defreitas.com> wrote in
message
>news:3bc501c51fff$3d0b4f00$a601280a@.phx.gbl...
as[vbcol=seagreen]
Is[vbcol=seagreen]
ALL[vbcol=seagreen]
>
>.
>|||ok Sue, intersting stuff. We'll check it out. THanks,
Bruce
>--Original Message--
>And in terms of the package logs, you would need to write
>your own utility using the DTS Object model. Search books
>online for the RemovePackageLogRecords method. In terms
of
>deleting based on dates, the package log date is tied to
the
>PackageLogRecord object.
>-Sue
>On Thu, 3 Mar 2005 06:42:35 -0800, "Bruce de Freitas"
><bruce@.defreitas.com> wrote:
>
as[vbcol=seagreen]
Is[vbcol=seagreen]
ALL[vbcol=seagreen]
>.
>

Command to clear DTS Package Logs + Versions

Hello. Is there any command that you can clear old DTS
package execution Logs? Also, when you store packages as
*.dts files, it saves the versions right in the file. Is
there a command that can clear older versions, either ALL
of them, or say, after 30 days?!? I know these things
can be done manully thru the GUI, looking for a way to
automate it if possible. Thanks, Bruce
Regarding the structured storage files, we always delete the existing DTS
file before saving so the file only contains one version. We keep the
packages under source control for versioning.
Hope this helps.
Dan Guzman
SQL Server MVP
"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
news:3bc501c51fff$3d0b4f00$a601280a@.phx.gbl...
> Hello. Is there any command that you can clear old DTS
> package execution Logs? Also, when you store packages as
> *.dts files, it saves the versions right in the file. Is
> there a command that can clear older versions, either ALL
> of them, or say, after 30 days?!? I know these things
> can be done manully thru the GUI, looking for a way to
> automate it if possible. Thanks, Bruce
|||And in terms of the package logs, you would need to write
your own utility using the DTS Object model. Search books
online for the RemovePackageLogRecords method. In terms of
deleting based on dates, the package log date is tied to the
PackageLogRecord object.
-Sue
On Thu, 3 Mar 2005 06:42:35 -0800, "Bruce de Freitas"
<bruce@.defreitas.com> wrote:

>Hello. Is there any command that you can clear old DTS
>package execution Logs? Also, when you store packages as
>*.dts files, it saves the versions right in the file. Is
>there a command that can clear older versions, either ALL
>of them, or say, after 30 days?!? I know these things
>can be done manully thru the GUI, looking for a way to
>automate it if possible. Thanks, Bruce
|||Thanks Dan, was hoping there was some automated
method/command of clearing the old versions, as they
exist already on numerous packages. Doesn't sound it.
THanks, Bruce
>--Original Message--
>Regarding the structured storage files, we always delete
the existing DTS
>file before saving so the file only contains one
version. We keep the
>packages under source control for versioning.
>--
>Hope this helps.
>Dan Guzman
>SQL Server MVP
>"Bruce de Freitas" <bruce@.defreitas.com> wrote in
message[vbcol=seagreen]
>news:3bc501c51fff$3d0b4f00$a601280a@.phx.gbl...
as[vbcol=seagreen]
Is[vbcol=seagreen]
ALL
>
>.
>
|||ok Sue, intersting stuff. We'll check it out. THanks,
Bruce
>--Original Message--
>And in terms of the package logs, you would need to write
>your own utility using the DTS Object model. Search books
>online for the RemovePackageLogRecords method. In terms
of
>deleting based on dates, the package log date is tied to
the[vbcol=seagreen]
>PackageLogRecord object.
>-Sue
>On Thu, 3 Mar 2005 06:42:35 -0800, "Bruce de Freitas"
><bruce@.defreitas.com> wrote:
as[vbcol=seagreen]
Is[vbcol=seagreen]
ALL
>.
>

Command to clear DTS Package Logs + Versions

Hello. Is there any command that you can clear old DTS
package execution Logs? Also, when you store packages as
*.dts files, it saves the versions right in the file. Is
there a command that can clear older versions, either ALL
of them, or say, after 30 days?!? I know these things
can be done manully thru the GUI, looking for a way to
automate it if possible. Thanks, BruceRegarding the structured storage files, we always delete the existing DTS
file before saving so the file only contains one version. We keep the
packages under source control for versioning.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
news:3bc501c51fff$3d0b4f00$a601280a@.phx.gbl...
> Hello. Is there any command that you can clear old DTS
> package execution Logs? Also, when you store packages as
> *.dts files, it saves the versions right in the file. Is
> there a command that can clear older versions, either ALL
> of them, or say, after 30 days?!? I know these things
> can be done manully thru the GUI, looking for a way to
> automate it if possible. Thanks, Bruce|||And in terms of the package logs, you would need to write
your own utility using the DTS Object model. Search books
online for the RemovePackageLogRecords method. In terms of
deleting based on dates, the package log date is tied to the
PackageLogRecord object.
-Sue
On Thu, 3 Mar 2005 06:42:35 -0800, "Bruce de Freitas"
<bruce@.defreitas.com> wrote:
>Hello. Is there any command that you can clear old DTS
>package execution Logs? Also, when you store packages as
>*.dts files, it saves the versions right in the file. Is
>there a command that can clear older versions, either ALL
>of them, or say, after 30 days?!? I know these things
>can be done manully thru the GUI, looking for a way to
>automate it if possible. Thanks, Bruce|||Thanks Dan, was hoping there was some automated
method/command of clearing the old versions, as they
exist already on numerous packages. Doesn't sound it.
THanks, Bruce
>--Original Message--
>Regarding the structured storage files, we always delete
the existing DTS
>file before saving so the file only contains one
version. We keep the
>packages under source control for versioning.
>--
>Hope this helps.
>Dan Guzman
>SQL Server MVP
>"Bruce de Freitas" <bruce@.defreitas.com> wrote in
message
>news:3bc501c51fff$3d0b4f00$a601280a@.phx.gbl...
>> Hello. Is there any command that you can clear old DTS
>> package execution Logs? Also, when you store packages
as
>> *.dts files, it saves the versions right in the file.
Is
>> there a command that can clear older versions, either
ALL
>> of them, or say, after 30 days?!? I know these things
>> can be done manully thru the GUI, looking for a way to
>> automate it if possible. Thanks, Bruce
>
>.
>|||ok Sue, intersting stuff. We'll check it out. THanks,
Bruce
>--Original Message--
>And in terms of the package logs, you would need to write
>your own utility using the DTS Object model. Search books
>online for the RemovePackageLogRecords method. In terms
of
>deleting based on dates, the package log date is tied to
the
>PackageLogRecord object.
>-Sue
>On Thu, 3 Mar 2005 06:42:35 -0800, "Bruce de Freitas"
><bruce@.defreitas.com> wrote:
>>Hello. Is there any command that you can clear old DTS
>>package execution Logs? Also, when you store packages
as
>>*.dts files, it saves the versions right in the file.
Is
>>there a command that can clear older versions, either
ALL
>>of them, or say, after 30 days?!? I know these things
>>can be done manully thru the GUI, looking for a way to
>>automate it if possible. Thanks, Bruce
>.
>

Command to Backup user & System tables

Can anyone tell me the command(s) you use to backup your user and system databases?xp_sqlmaint '-PlanName "DBMaint System DBs" -Rpt F:\MSSQL2K\MSSQL\LOG\BckpSysDBs.txt -DelTxtRpt 2DAYS -RmUnusedSpace 10 1 -WriteHistory -BkUpDB -BkUpMedia DISK -DelBkUps 2DAYS -UseDefDir -VrfyBackup -BkExt "BAK"'

xp_sqlmaint '-PlanName "DBMaint User DBs" -Rpt F:\MSSQL2K\MSSQL\LOG\BckpUserDBs.txt -DelTxtRpt 2DAYS -RmUnusedSpace 10 1 -WriteHistory -BkUpDB -BkUpMedia DISK -DelBkUps 2DAYS -UseDefDir -VrfyBackup -BkExt "BAK"'|||thanks..