Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Tuesday, March 20, 2012

CASE count wierd join needed maybe? just one more field needed!

Right, I used your handy answers to get a solution that worked.. Your
last method was the one to use but i left it running for 3 hours and
it still hadn't returned any results! (and it's a stupidly high spec
server with pretty much just sql on there)

anyway.. so in SQL Server managment studio i found the "Views" section
(sorta like tempory tables i presume) and popped this into a new one
call kev_bin.

WITH Bin1 AS (SELECT ItemID, MAX(DateTimeCreated) AS MDate
FROM dbo.BinItem AS Bin1
GROUP BY ItemID)
SELECT Bin2.ItemID, Bin2.BinName
FROM dbo.BinItem AS Bin2 INNER JOIN
Bin1 AS Bin1 ON Bin2.ItemID = Bin1.ItemID
AND Bin2.DateTimeCreated = Bin1.MDate

I could then go back to my orignal SQL and use the following to grap
the data from the newly created table kev_bin above:

Select ... .. ...
kbin.BinName as location

Quote:

Originally Posted by

>From ...


...
dbo.kev_bin kbin
...
WHERE ..
item.ItemID = kbin.ItemID
....

and this runs in about 20 seconds :D

thanks again for all your help, i couldn't have done it without!(kevin@.nu-urbanmusic.co.uk) writes:

Quote:

Originally Posted by

anyway.. so in SQL Server managment studio i found the "Views" section
(sorta like tempory tables i presume) and popped this into a new one
call kev_bin.


Views are just a logical concept. Except for indexed view, they are not
materialised, and they are expanded so that the optimizer works with the
expanded query. That is, essentiall a macro.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||On Nov 6, 10:31 pm, Erland Sommarskog <esq...@.sommarskog.sewrote:

Quote:

Originally Posted by

(ke...@.nu-urbanmusic.co.uk) writes:

Quote:

Originally Posted by

anyway.. so in SQL Server managment studio i found the "Views" section
(sorta like tempory tables i presume) and popped this into a new one
call kev_bin.


>
Views are just a logical concept. Except for indexed view, they are not
materialised, and they are expanded so that the optimizer works with the
expanded query. That is, essentiall a macro.
>
--
Erland Sommarskog, SQL Server MVP, esq...@.sommarskog.se
>
Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx


Hi Kev,

Glad I could help :)

Jsql

Wednesday, March 7, 2012

Carrage Returns, Stored Procedures

Question:
What would be the best way to add carrage returns to a record, and would my
method create alot of overhead and wasted space. What would be the best
method to minimize overhead and wasted space.
Scenario:
Server MS SQL 2000
Table name= mitTickets
Fields= problem,details, created, lastupdate
UPDATE [mitTickets] SET [mitTickets].details= Now() &
Chr(13)+Chr(10)+[@.detailstxtbox]+Chr(13)+Chr(10)+Chr(13)+Chr(10)+[descriptio
n], [mitTickets].lastupdate = Now()
WHERE (((mitTickets.ID)=1));
Current Text in record [Data Example for mitTickets.Details]
Backup failed. Backup failure investigated and found tape ejected.
I would like to create a stored procedure that will append the current Date
and Time to each update that is being submitted via a web form. I only want
the web form to add text and have the stored procedure append the input text
the the existing record so that the data looks like the following. and have
it also update the field [lastupdate]
10/4/2003 9:10:32 AM
Tape inserted, backup completed successfully.
10/4/2003 7:15:02 AM
Backup failure investigated and found tape ejected.
10/4/2003 6:27:08 AM
Backup failed.
Thank You,
DaveAssuming it is a VARCHAR(8000),
CREATE PROCEDURE dbo.addDetails
(
@.mitTicketID INT,
@.detail VARCHAR(255)
)
AS
BEGIN
DECLARE @.append VARCHAR(512)
SET @.append = CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10)
+ CONVERT(CHAR(10), GETDATE(), 101) + ' '
+ STUFF(RIGHT(CONVERT(VARCHAR(255), GETDATE(), 109), 14), 9, 4, ' ')
+ CHAR(13) + CHAR(10) + @.detail
UPDATE mitTickets
SET
details = details + @.append,
lastUpdate = GETDATE()
WHERE ID = @.mitTicketID
END
GO
You can change all that formatting to this, if you're happy with MMM DD
YYYY HH:MMAM format:
CONVERT(VARCHAR(26), GETDATE())
I don't know what you mean by overhead and wasted space; if you want a
carriage return in the column, there isn't a more efficient way than putting
a carriage return in the column. Not sure what kind of magic you might be
expecting there?
In any case, I think this should be redesigned. Why do you want to store
all that detail in a huge column? That column almost looks like a table.
Why don't you store detail rows in a relational table... it will make the
handling of adding rows much easier, it will make reporting easier, it will
certainly make *removal* of older data easier, it will avoid the problems
you'll have when you have to make it TEXT because all of your data reaches
8000 characters at some point, and it will completely eliminate the
redundancy of having a lastupdate column.
"new" <dduryea@.inetmicro.com> wrote in message
news:C0Xfb.50792$nU6.8338649@.twister.nyc.rr.com...
> Question:
> What would be the best way to add carrage returns to a record, and would
my
> method create alot of overhead and wasted space. What would be the best
> method to minimize overhead and wasted space.
> Scenario:
> Server MS SQL 2000
> Table name= mitTickets
> Fields= problem,details, created, lastupdate
> UPDATE [mitTickets] SET [mitTickets].details= Now() &
>
Chr(13)+Chr(10)+[@.detailstxtbox]+Chr(13)+Chr(10)+Chr(13)+Chr(10)+[descriptio
> n], [mitTickets].lastupdate = Now()
> WHERE (((mitTickets.ID)=1));
>
> Current Text in record [Data Example for mitTickets.Details]
> Backup failed. Backup failure investigated and found tape ejected.
>
> I would like to create a stored procedure that will append the current
Date
> and Time to each update that is being submitted via a web form. I only
want
> the web form to add text and have the stored procedure append the input
text
> the the existing record so that the data looks like the following. and
have
> it also update the field [lastupdate]
> 10/4/2003 9:10:32 AM
> Tape inserted, backup completed successfully.
> 10/4/2003 7:15:02 AM
> Backup failure investigated and found tape ejected.
> 10/4/2003 6:27:08 AM
> Backup failed.
>
> Thank You,
> Dave
>|||Hi
I am not sure why you wish to add this to the database as a single field.
What would happend if you wanted to query the data e.g all activity on a
certain day?
It would be better to add the carriage returned on output, either when
selecting the data or probably more preferably through the user interface.
You can use the getdate() function to get the current system date and time.
John
"new" <dduryea@.inetmicro.com> wrote in message
news:C0Xfb.50792$nU6.8338649@.twister.nyc.rr.com...
> Question:
> What would be the best way to add carrage returns to a record, and would
my
> method create alot of overhead and wasted space. What would be the best
> method to minimize overhead and wasted space.
> Scenario:
> Server MS SQL 2000
> Table name= mitTickets
> Fields= problem,details, created, lastupdate
> UPDATE [mitTickets] SET [mitTickets].details= Now() &
>
Chr(13)+Chr(10)+[@.detailstxtbox]+Chr(13)+Chr(10)+Chr(13)+Chr(10)+[descriptio
> n], [mitTickets].lastupdate = Now()
> WHERE (((mitTickets.ID)=1));
>
> Current Text in record [Data Example for mitTickets.Details]
> Backup failed. Backup failure investigated and found tape ejected.
>
> I would like to create a stored procedure that will append the current
Date
> and Time to each update that is being submitted via a web form. I only
want
> the web form to add text and have the stored procedure append the input
text
> the the existing record so that the data looks like the following. and
have
> it also update the field [lastupdate]
> 10/4/2003 9:10:32 AM
> Tape inserted, backup completed successfully.
> 10/4/2003 7:15:02 AM
> Backup failure investigated and found tape ejected.
> 10/4/2003 6:27:08 AM
> Backup failed.
>
> Thank You,
> Dave
>

careless to remove data

I am careless to 'delete from myTable'
any other method to recover the data ?
thanks a lot..If you have not truncate your log, the data should be stay in the log
file and you should be able to restore from the log file.
Agnes wrote:
> I am careless to 'delete from myTable'
> any other method to recover the data ?
> thanks a lot..|||Restore from your most recent backup...
If it just happened and your db is in "Full Recovery" mode, backup the tran
log now
You can then RESTORE with STOPAT to do a point in time recovery
HTH. Ryan
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:emI3qwzUGHA.1160@.TK2MSFTNGP09.phx.gbl...
>I am careless to 'delete from myTable'
> any other method to recover the data ?
> thanks a lot..
>|||Hopefully his db wasn't in "Simple" recovery..
HTH. Ryan
<stanleycn@.gmail.com> wrote in message
news:1143642476.867540.66940@.g10g2000cwb.googlegroups.com...
> If you have not truncate your log, the data should be stay in the log
> file and you should be able to restore from the log file.
>
> Agnes wrote:
>

Careless Delete SP , HOw can I recover (Urgent help)

I delete 40 SO so careless ly, Any method to recover ?Agnes wrote:
> I delete 40 SO so careless ly, Any method to recover ?
>
restore as a different database?!!|||don't you have a change management process in place with all your source cod
e
in a source code control like Visual Source Safe? Maybe you'll have to use a
backup and get them from there...
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Agnes" wrote:

> I delete 40 SO so careless ly, Any method to recover ?
>
>|||I really want to cry and don't know how to do now.
Origianll, I choose all SP and generate a SQL script , I copy the script
into SQL Analzyer , and run it
I press 'stop' carelessly, then I found all the SP are dropped already.
Then I am so stupid that close the SQL analzyer, and reopen it.
NOW, I LOST everything, I check that there is a log in
G:\Program Files\Microsoft SQL Server\MSSQL\Data\myDataBase_Log
is That I can use it recover it ''
Please help ~~~~
"Zarko Jovanovic" <mind_lessNOSPAM@.bigfoot.com>
'?:1115028697.621239@.internet.fina.hr...
> Agnes wrote:
> restore as a different database?!!|||NO, i didn't got any source safe..
"mark baekdal" <markbaekdal@.discussions.microsoft.com> glsD:8A540508-E6EF-4483-9E
AF-88CCEE65C100@.microsoft.com...
> don't you have a change management process in place with all your source
> code
> in a source code control like Visual Source Safe? Maybe you'll have to use
> a
> backup and get them from there...
>
> regards,
> Mark Baekdal
> http://www.dbghost.com
> http://www.innovartis.co.uk
> +44 (0)208 241 1762
> Build, Comparison and Synchronization from Source Control = Database
> change
> management for SQL Server
>
>
> "Agnes" wrote:
>|||Hi Agnes,
Since you dont have any change management system or a local copy of the
stored procedures stored as flat files.
You could probably try restoring a backup of the database.(looks like the
only way u have)
Prad
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:uW399pvTFHA.3184@.TK2MSFTNGP15.phx.gbl...
>I delete 40 SO so careless ly, Any method to recover ?
>|||Backup database ' I didn't do any back up...
"Pradeep Kutty" <pradeepk@.healthasyst.com> glsD:eGdPULwTFHA.1152@.tk2msftngp13.phx
.gbl...
> Hi Agnes,
> Since you dont have any change management system or a local copy of the
> stored procedures stored as flat files.
> You could probably try restoring a backup of the database.(looks like the
> only way u have)
> Prad
> "Agnes" <agnes@.dynamictech.com.hk> wrote in message
> news:uW399pvTFHA.3184@.TK2MSFTNGP15.phx.gbl...
>|||update your CV.
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Agnes" wrote:

> Backup database ' I didn't do any back up...
> "Pradeep Kutty" <pradeepk@.healthasyst.com> ???g?ó?l¥ó·s?D:eGdPUL
wTFHA.1152@.tk2msftngp13.phx.gbl...
>
>|||Hi,
Check the recovery model for your database. If it is FULL recovery model we
can try out a Point in time recovery. But since you do not
have the backup, I exactly can not say a step by step process to recover the
stored procedures,
Thanks
Hari
SQL Server MVP
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:%233prORwTFHA.2940@.TK2MSFTNGP10.phx.gbl...
> Backup database ' I didn't do any back up...
> "Pradeep Kutty" <pradeepk@.healthasyst.com>
glsD:eGdPULwTFHA.1152@.tk2msftngp13.phx.gbl...
the
>|||What is CV '
"mark baekdal" <markbaekdal@.discussions.microsoft.com> glsD:F02D1C3C-A912-42A1-A3
8B-5028F1DDEF79@.microsoft.com...
> update your CV.
>
> regards,
> Mark Baekdal
> http://www.dbghost.com
> http://www.innovartis.co.uk
> +44 (0)208 241 1762
> Build, Comparison and Synchronization from Source Control = Database
> change
> management for SQL Server
>
>
> "Agnes" wrote:
>

Friday, February 24, 2012

Capturing a PDF file

I have a report that is being rendered to PDF using the UrlAccess method
from a C# WindowsForms application. Can someone indicate how I can capture
the file from the server to eliminate the step of opening IE and having to
click Open on the download dialog.
i.e. I want to give the user a seamless one-click route to viewing, and then
printing, the PDF.
I assume it can be done using the HttpRequest class but I'd appreciate a
leg-up...
brian smithhttp://servername/reportserver?/Sales/YearlySalesSummary&rs:Format=PDF&rs:Command=RenderSearch
for URL Access in Books on line... The Format parameter is documented
there..Have fun!
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Brian Smith" <bsmith@.nospam.leazesdotcom> wrote in message
news:OvA18QOZEHA.2260@.TK2MSFTNGP12.phx.gbl...
> I have a report that is being rendered to PDF using the UrlAccess method
> from a C# WindowsForms application. Can someone indicate how I can capture
> the file from the server to eliminate the step of opening IE and having to
> click Open on the download dialog.
> i.e. I want to give the user a seamless one-click route to viewing, and
then
> printing, the PDF.
> I assume it can be done using the HttpRequest class but I'd appreciate a
> leg-up...
> brian smith
>|||Err, that's exactly what I'm doing (is that a typo - I'm using
Command=Render - don't think there is a RenderSearch command).
My question concerns capturing the rendered byte stream - but I've found the
answer in the FindRenderSave sample application.
brian
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:u5CWb$OZEHA.3128@.TK2MSFTNGP09.phx.gbl...
>
http://servername/reportserver?/Sales/YearlySalesSummary&rs:Format=PDF&rs:Command=RenderSearch
> for URL Access in Books on line... The Format parameter is documented
> there..Have fun!
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Brian Smith" <bsmith@.nospam.leazesdotcom> wrote in message
> news:OvA18QOZEHA.2260@.TK2MSFTNGP12.phx.gbl...
> > I have a report that is being rendered to PDF using the UrlAccess method
> > from a C# WindowsForms application. Can someone indicate how I can
capture
> > the file from the server to eliminate the step of opening IE and having
to
> > click Open on the download dialog.
> > i.e. I want to give the user a seamless one-click route to viewing, and
> then
> > printing, the PDF.
> >
> > I assume it can be done using the HttpRequest class but I'd appreciate a
> > leg-up...
> >
> > brian smith
> >
> >
>