Showing posts with label run. Show all posts
Showing posts with label run. Show all posts

Friday, March 30, 2012

how to diaplay date in MM/dd/yyyy format

how to display date in mm/dd/yy using select query ( i have dates which are in mm/dd/yyyyy format but when i run a query it displaying yyyy-mm-dd format).i want to display date in mm/dd/yyyy format so how to write select query for that

This 'should' work:

SELECT convert( varchar(10), MyColumn, 101 )

For example, using today's date:

SELECT convert( varchar(10), getdate(), 101 )


-
05/25/2007

|||what is this 101 , 102 in code|||

It the style number which indicates how the system should transform your data.

Here is more detail.

http://msdn2.microsoft.com/en-us/library/ms187928.aspx

|||thanks a lot MVPsql

How to diagnose a deadly embrace

I have an application which is running on 40 active workstations. I am
encountering lock outs many times a day. When I run the stored procedure
"sp_who2" I can see the spids that are blocked and by which other spid.
If I "kill xx" where xx is the head of the blocking chain the system frees
up. When doing the "sp_who2" I see a command column which only shows the
start of a command like "insert", 'update", "select" or "AWAITING COMMAND".
Is there a way to see the whole command to isolate which table(s) are
causing the problem?
Are there other tools to help me out?
Desparately in need of help...
Mark
Mark Butler wrote:
> I have an application which is running on 40 active workstations. I
> am encountering lock outs many times a day. When I run the stored
> procedure "sp_who2" I can see the spids that are blocked and by which
> other spid.
> If I "kill xx" where xx is the head of the blocking chain the system
> frees up. When doing the "sp_who2" I see a command column which only
> shows the start of a command like "insert", 'update", "select" or
> "AWAITING COMMAND". Is there a way to see the whole command to
> isolate which table(s) are causing the problem?
> Are there other tools to help me out?
> Desparately in need of help...
> Mark
You can use Profiler to see what command are starting and not completing
or committing as the case may be. If you look at the starting and
completed events, you can see if something did not complete (missing
completed event). That might mean that data was not rolled back. It
sounds like you might have open transactions. Make sure no one is using
SQL Enterprise Manager (or other tools that do not fetch all data at
once) to edit data in tables as they will leave open locks on data.
If the same user is responsibl, you can filter the Profiler data. The
output may generate a lot of information. I would start looking at
SQL:BatchStarting/Completed and RPC:Starting/Completed. If yo uneed more
detail, you can add SQL:StmtStarting/Completed and
SP:StmtStarting/Completed.
David Gugick
Quest Software
www.imceda.com
www.quest.com
|||You could also use DBCC INPUTBUFFER or fn_get_sql on specific spids to find
out what they are doing at a given point in time. See SQL Server Books
Online for more information. You may find my code useful in this scenario:
http://vyaskn.tripod.com/fn_get_sql.htm
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Mark Butler" <mredhat_nospam@.yahoo.com> wrote in message
news:eYpyqXLfFHA.1284@.TK2MSFTNGP14.phx.gbl...
> I have an application which is running on 40 active workstations. I am
> encountering lock outs many times a day. When I run the stored procedure
> "sp_who2" I can see the spids that are blocked and by which other spid.
> If I "kill xx" where xx is the head of the blocking chain the system frees
> up. When doing the "sp_who2" I see a command column which only shows the
> start of a command like "insert", 'update", "select" or "AWAITING
COMMAND".
> Is there a way to see the whole command to isolate which table(s) are
> causing the problem?
> Are there other tools to help me out?
> Desparately in need of help...
> Mark
>
|||You can start SQL Server Profiler to trace which table is causing the lock.
John King
http://www.agileinfollc.com
"Mark Butler" <mredhat_nospam@.yahoo.com> wrote in message
news:eYpyqXLfFHA.1284@.TK2MSFTNGP14.phx.gbl...
>I have an application which is running on 40 active workstations. I am
>encountering lock outs many times a day. When I run the stored procedure
>"sp_who2" I can see the spids that are blocked and by which other spid.
> If I "kill xx" where xx is the head of the blocking chain the system frees
> up. When doing the "sp_who2" I see a command column which only shows the
> start of a command like "insert", 'update", "select" or "AWAITING
> COMMAND". Is there a way to see the whole command to isolate which
> table(s) are causing the problem?
> Are there other tools to help me out?
> Desparately in need of help...
> Mark
>

Wednesday, March 28, 2012

How to determine when and if SQL Agent job will run again?

I need to determine programmatically if and when a SQL Agent job will run next. (a date and time) Is this possible and if so, any suggestions on how? I need to maintain a table of the next pending execution for each job so I can allow the user to cancel the next pending job, but I have to show them the date and time on which it will occur. Since I'm using most of the scheduling capabilities of SQL Agent, I really need to get the next execution time that SQL Agent thinks the job should run rather than trying to calculate when I think it should run based on all the various scheduling scenarios. I'm using SMO in SQL Server 20005.

Thanks

Guess I couldn't see the tree for the forest. Here is the solution in case anyone else has the issue. Get the NextRunDate property of the Job object in the Microsoft.SqlServer.Management.Smo.Agent namespace.

How to determine when and if SQL Agent job will run again?

I need to determine when (maybe) and if (definitely) a SQL Agent job will run again. I need to maintain a table of the next pending execution for each job. I need to be able to update this table from within a SQL Agent job, but preferably from within an executing SSIS package in the job. Is this possible and if so, any suggestions on how?

Thanks

Hello, your question is really SQL agent related so you likely want to post in the mgt tools forum but I can say what I know. SQL agent jobs and job steps can be manipulate from TSQL/Stored procedures so in theory you could call those from an SSIS pacakge. For example, using the SSIS Execute SQL task.

The following looks like a good reference to SQL Agent SPs.

http://msdn2.microsoft.com/en-us/library/ms187763.aspx

Hope that helps

|||

Here is the solution in case anyone else has the issue. Get the NextRunDate property of the Job object in the Microsoft.SqlServer.Management.Smo.Agent namespace.

Monday, March 26, 2012

How to determine SQL version from a command line

Hi, I am trying to run a command line script against 50
SQL servers to determine the SQL ver and SP level
installed but when I run srvinfo -ns this returns way more
info then I require and does not include SP level. I have
run registry searches but this will only give the
installed version of SQL, it will not give me the latest
ver, i.e. if it has had an SP installed or not. Any help
would be great. ThanksYou can use OSQL from the command line to connect to SQL Server. Once
connected issue SELECT @.@.VERSION or use SERVERPROPERTY
Without using SQL you could always do a DIR and seach for sqlservr.exe, from
it's size and file data you should be able to work out which version.
--
HTH
Ryan Waight, MCDBA, MCSE
"Jonathon" <Jonathon_Taaffe@.hotmail.com> wrote in message
news:296d601c3919f$d3ea6f90$a601280a@.phx.gbl...
> Hi, I am trying to run a command line script against 50
> SQL servers to determine the SQL ver and SP level
> installed but when I run srvinfo -ns this returns way more
> info then I require and does not include SP level. I have
> run registry searches but this will only give the
> installed version of SQL, it will not give me the latest
> ver, i.e. if it has had an SP installed or not. Any help
> would be great. Thanks|||Jonathan,
Refer to following url:
http://support.microsoft.com/default.aspx?scid=kb;en-us;q321185
You can run these queries from command prompt, using osql utility by passing quries to -Q
parameter.
--
- Vishal|||You can run 'select @.@.version' with osql in dos.
>--Original Message--
>Hi, I am trying to run a command line script against 50
>SQL servers to determine the SQL ver and SP level
>installed but when I run srvinfo -ns this returns way
more
>info then I require and does not include SP level. I have
>run registry searches but this will only give the
>installed version of SQL, it will not give me the latest
>ver, i.e. if it has had an SP installed or not. Any help
>would be great. Thanks
>.
>|||In article <296d601c3919f$d3ea6f90$a601280a@.phx.gbl>, Jonathon
<Jonathon_Taaffe@.hotmail.com> writes
>Hi, I am trying to run a command line script against 50
>SQL servers to determine the SQL ver and SP level
>installed but when I run srvinfo -ns this returns way more
>info then I require and does not include SP level. I have
>run registry searches but this will only give the
>installed version of SQL, it will not give me the latest
>ver, i.e. if it has had an SP installed or not. Any help
>would be great. Thanks
If you are looking for any SQL Servers then you could try SQL Scan as
well-
http://www.microsoft.com/sql/downloads/securitytools.asp
I use a combination of methods to monitor what servers appear on the
network and in what state.
The registry will tell you which SP you are running, but it will not
tell you if there are any patches on top as well.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVers
ion]
The CurrentVersion value gives you the base version, e.g 8.00.194 = SQL
Server 2000 RTM.
The CSDVersion key will then tell you the service pack level, e.g.
8.00.761 = SP3a. Note this is actually quite useful because the TSQL
@.@.VERSION and similar will only give you 8.00.760, which means SP3 or
SP3a. However since I also have the latest security patch installed
@.@.VERSION says 8.00.818, so a combination is often better.
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com
PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org|||I've just tried, it worked without problem.
From a cmd line :-
OSQL -Sservername -Q"select @.@.Version" -E
--
HTH
Ryan Waight, MCDBA, MCSE
"Ray Miao" <rmiao@.bloomberg.com> wrote in message
news:03d801c391b4$f2bded60$a401280a@.phx.gbl...
> You can run 'select @.@.version' with osql in dos.
> >--Original Message--
> >Hi, I am trying to run a command line script against 50
> >SQL servers to determine the SQL ver and SP level
> >installed but when I run srvinfo -ns this returns way
> more
> >info then I require and does not include SP level. I have
> >run registry searches but this will only give the
> >installed version of SQL, it will not give me the latest
> >ver, i.e. if it has had an SP installed or not. Any help
> >would be great. Thanks
> >.
> >

Monday, March 12, 2012

How to design "product kits"

Hi,

I've run into a bit of a sticky design issue. We have products in
three categories which I will call 'A', 'B' and 'C'. We have "kits"
which contain three products, one from each category.

Below is some sample SQL to set things up, but I need to ensure that
each kit gets three products -- one from each category. Obviously,
this basic SQL doesn't allow that. Any suggestions? Do I need a
different schema design, or is there something else I should be
looking at?

Cheers,
Curtis

CREATE TABLE category (
id int identity primary key,
name varchar(30)
);

CREATE TABLE products (
id int identity primary key,
name varchar(30),
category_id int references category(id)
);

CREATE TABLE kits (
id int identity primary key,
name varchar(30)
);

CREATE TABLE kit_products (
kit_id int references kits(id),
product_id int references products(id)
);>> We have products in three categories which I will call 'A', 'B' and
'C'. <<

... and you declared them as INTEGER.

>> We have "kits" which contain three products, one from each
category. <<

So, do you have only three categories??

>> Do I need a different schema design, ... <<

Oh yeah! You do not have any keys (IDENTITY is never a key by
definition) and "id" is to vague to be a data element name (read
ISO-11179 rules). Category is singular, while the other table names
are plural; ergo, category must have one and only one row? All the
important data is NULL-able.

I am going to assume that you have so many categories that they
require a separate table; if not, put them in a CHECK() clause.

CREATE TABLE Categories
(category_id INTEGER PRIMARY KEY,
category_name VARCHAR(30) NOT NULL);

CREATE TABLE Products
(product_name VARCHAR(30) NOT NULL,
product_id INTEGER NOT NULL UNIQUE,
category_id INTEGER NOT NULL
REFERENCES Categories(id)
ON UPDATE CASCADE
ON DELETE CASCADE,
PRIMARY KEY (product_id, category_id));

CREATE TABLE ProductKits
(kit_id INTEGER NOT NULL
kit_name VARCHAR(30) NOT NULL,
product_id_1 INTEGER NOT NULL,
category_id_1 INTEGER NOT NULL
FOREIGN KEY (product_id_1, category_id_1)
REFERENCES Products (product_id, category_id)
ON UPDATE CASCADE
ON DELETE CASCADE,
product_id_2 INTEGER NOT NULL,
category_id_2 INTEGER NOT NULL
FOREIGN KEY (product_id_2, category_id_2)
REFERENCES Products (product_id, category_id)
ON UPDATE CASCADE
ON DELETE CASCADE,
product_id_3 INTEGER NOT NULL,
category_id_3 INTEGER NOT NULL
FOREIGN KEY (product_id_3, category_id_3)
REFERENCES Products (product_id, category_id)
ON UPDATE CASCADE
ON DELETE CASCADE,
CHECK (category_id_1 = 1
AND category_id_2 = 2
AND category_id_3 = 3));

The sneaky trick is to put both (product_id, category_id) in the
primary key of Products, so both can be referenced. The product_id is
still unique (another assumption, since your original schema allowed a
product to be named NULL or repeated under a thousand different
IDENTITY numbers, making data integrity impossible). I also assume
that the categories for the kits is (1, 2, 3) instead of ('a', 'b',
'c').

If there are onlyn three categories, then use this and no separate
Categories table:

CREATE TABLE Products
(product_name VARCHAR(30) NOT NULL,
product_id INTEGER NOT NULL UNIQUE,
category_id INTEGER NOT NULL
CHECK(category_id IN (3,2,1))
PRIMARY KEY (product_id, category_id));

How to Deploy the reports automatically in SSRS?

Hi,

I am creating a application to show reports for daily based information.

I have created the reports and i am changing the data source at run time.In order to view the updated reports, i have to deploy.

So i need to deploy the reports automatically.

can any one gave a idea to do this.

thanks

Hi,

You can do this via the RS command.

What you need to do is write a script (.rss) that would serve as an input file to the rs command.

this script should loop through a folder and upload all extension with .rdl

Create a folder in your D: drive for example called RS within that have your script and have a sub folder called reports which were you will have all your reports.

once this has been done go to cmd and do the following

1. Map to your folder ie cd: D:\RS

2. type in the following command

rs -i PublishReports.rss -s http://localhost/reportserver

PublishReports.rss is your script and http://localhost/reportserver is where you want to deploy the reports.

Hope this helps.

|||

Hi,

Thanks for your solution.

It's work fine.

How to Deploy the reports automatically in SSRS?

Hi,

I am creating a application to show reports for daily based information.

I have created the reports and i am changing the data source at run time.In order to view the updated reports, i have to deploy.

So i need to deploy the reports automatically.

can any one gave a idea to do this.

thanks

Hi,

You can do this via the RS command.

What you need to do is write a script (.rss) that would serve as an input file to the rs command.

this script should loop through a folder and upload all extension with .rdl

Create a folder in your D: drive for example called RS within that have your script and have a sub folder called reports which were you will have all your reports.

once this has been done go to cmd and do the following

1. Map to your folder ie cd: D:\RS

2. type in the following command

rs -i PublishReports.rss -s http://localhost/reportserver

PublishReports.rss is your script and http://localhost/reportserver is where you want to deploy the reports.

Hope this helps.

|||

Hi,

Thanks for your solution.

It's work fine.

How to deploy reports from my pc to my client's server?

Hi Guys,

I am using MS Visual Studio .Net 2003 to design reports from the data in MS SQL Server.

I have no problem to deploy, view or run the reports in my pc with MS SQL Reporting Services installed.

Now, my client's server with MS SQL Reporting Services only installed, but no MS Visual Studio installed.

How to deploy all my reports in my pc into my client's server so that user can view the reports in the server thru IE?

Thanks.

Yes, you can upload the .RDL file into Server.

You need to open http://<servername>/Reports page and press Upload File Button on the command bar. Then you can browse for your .RDL files (files that are copied from your home computer) and after you upload these reports to your server you may consider to change the Data Source.

For changing the Data Source you must open the report and go to the Properties Tab, than select Data Sources. You can choose from Shared Data source or Custom Data source, after you make your selection you need to press Apply button (on the bottom of the page).

Good luck.

|||

Thanks for your reply.

Just manage to get the server up.

But when I open http://<servername>/Reports I can't see any Upload File Button. I got only "Home | My Subscriptions | Help" on right top corner.


|||

Hi,

#1. go to Control Panel->Administrative Tools -> IIS , open Internet Information Services.

#2. Double click your server name-> goto web sites-> Default WebSite

#3. right click on report server goto directory security tab click edit button and deselect the anonymous acces check box.

do the step 3 for "Reports" also,.

and go to http://<servername>/Reports ull be able to see the upload button now.

Hope this solves your problem.

|||Yupe.. I see it now.. Thanks to both PFerns and Pavel Cristian Gabriel!

Friday, March 9, 2012

How to deploy in run time

Hello, i'm trying to make a report generator for web application, that means
the user will generat the report and save it on the server, the idea is that
report for dummy users, i started to make a wizared to generate my SQL
statment and i did, then i make a class to generate the RDl file and i did,
the problem is how to deploy this generated RDL file at run time,( after
compilation) , i tried to use rs.exe tool but i didn't think that it worked,
also , i want to ask , Is this a right way of thinking to deploy a report at
run time or not,
thank you in advanceI have no idea if this is a good way to handle it, but the API exposed
through SOAP looks like it will let you create a report on the fly. The
ReportingService class has a CreateReport method that looks like it might
fit your needs. Here is the MSDN documentation of the method:
http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_service_ak_79mc.asp
Good luck!
"Wael Nofal" <Wael Nofal@.discussions.microsoft.com> wrote in message
news:20C60FBF-9CF9-45AF-AC33-F94026F4E1C6@.microsoft.com...
> Hello, i'm trying to make a report generator for web application, that
means
> the user will generat the report and save it on the server, the idea is
that
> report for dummy users, i started to make a wizared to generate my SQL
> statment and i did, then i make a class to generate the RDl file and i
did,
> the problem is how to deploy this generated RDL file at run time,( after
> compilation) , i tried to use rs.exe tool but i didn't think that it
worked,
> also , i want to ask , Is this a right way of thinking to deploy a report
at
> run time or not,
> thank you in advance
>

How to delete tmp file which created by Crystal Report automatically

Hi,
Each time I run the vb application, the crystal report will create tmp file in the C:\ and VB*.tmp in the current working dirctory. How can I delete it automatically? Now, I need to delete it manually, otherwise, the huge tmp file will remind in both directories.
ThanksKill FileName