Showing posts with label number. Show all posts
Showing posts with label number. Show all posts

Friday, March 30, 2012

need to changes the default port address of apache server

can any one guide me how to change the default port address of apache which is 80 to any other port number. coz the default port number is taken by iis also.

I'm not sure if this is what you are looking for, but this artical has a section on 'Changing the port number'

http://www.tivohelp.com/archive/tivohelp.swiki.net/31.html

Hope this helps.

Jarret

sql

Need To CalcuThe Number Of Days Between The Current Date And A Stored Date

I need help with creating a query that compares the current date with a stored date field. If the difference between the two dates is greater or equal to 5 days for example, I need to be able to return these records. I am not sure if this can be done through a query alone but any help and suggestions would greatly be appreciated. Thanks in advance.yes it can be done through a query, but the standard sql for it will almost certainly not work in whatever database system you're using

date functions are notoriously non-standard, and each database system pretty much has its own proprietary functions

if you wouldn't mind mentioning which database system you're using, we could probably help you|||Nevermind I figured it out. I am using a SQL server 2000 database to query my data. I used the Datediff() function in conjunction with getdate(). See examples below for anyone else needing help with this topic.

DATEDIFF([day], dbo.table.field, GETDATE()) AS DAYS,
DATEDIFF([HOUR], dbo.table.field, GETDATE()) AS HOURS|||moved to SQL Server forum|||The solution you arrived at will work, but will not benefit from any indexing on your dbo.table.field column. If, instead, you used the DateAdd() function to find the date five days prior to the current date, then the optimizer will be able to use an index on dbo.table.field for comparisons:Where dbo.table.field >= DateAdd(day, -5, GetDate())

Wednesday, March 28, 2012

Need to audit structure change

How to audit changes made by SQL users on table
structure. Some changes include data type, column name,
and number of columns.
Thanks for suggestion.Look up sp_trace_create in the books online - one of the security audit
event types will allow you to capture all DDL which should get everything
you're looking for here. You can also use sql profiler to build the trace
for you and then script it out if you don't want to use the GUI all the
time...
Richard Waymire, MCSE, MCDBA
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jim Fuller" <anonymous@.discussions.microsoft.com> wrote in message
news:020801c3ba8a$69ee1650$a101280a@.phx.gbl...
quote:

> How to audit changes made by SQL users on table
> structure. Some changes include data type, column name,
> and number of columns.
> Thanks for suggestion.

Need to add dup rows to sp

I have a sp that is used for membership cards, there is a column Number_of_Cards. We enter the number of cards a member wants. I need to create duplicate rows in my results based on the number entered in this field for each member. Anyone have any Ideas how to generate dup rows based on this column?

Thanks for any thoughts,Well, I don't like the sounds of it ;-) , but this is how you would do it in your sproc:


DECLARE @.LoopCount int
SELECT @.LoopCount = 1

WHILE @.LoopCount <= @.CardCount
BEGIN
INSERT INTO...
SET @.LoopCount = @.LoopCount + 1
END

Note that Transact-SQL does not have a FOR...NEXT loop construct. You need to make do with a WHILE loop.

Terri|||Thank you, I will give it a try. I know this sounds bad, but it is for a merge to membership cards and I need to do it this way to use Microsoft Word for the process.

Thanks again.|||I have been working with the example and have run into an issue. I thought you might have an idea. I think the problem is that the first loop does the INTO temp_Cards then the next loop fails because the temp_Cards table already exists.


CREATE PROCEDURE dbo.eP_CardProcess2 (@.Start datetime,@.End datetime,@.LoopCount int)
AS SELECT @.LoopCount =1

WHILE @.LoopCount <= (Select dbo.tblPledges.Number_Of_Cards From dbo.tblPledges Where (dbo.tblPledges.StartDate BETWEEN @.Start AND @.End) AND (dbo.tblPledges.Print_Card = 1) AND (dbo.tblPledges.Cards_Printed=0))
BEGIN
SELECT dbo.tblPledges.Number_Of_Cards,dbo.tblPledges.Card_Start_Date,dbo.tblPledges.Card_End_Date,dbo.tblPledges.Alternate_Card_Name,dbo.tblGivers.Email,dbo.tblPledges.RenewalDate INTO #temp_Cards
FROM dbo.tblPledges INNER JOIN dbo.tblClient ON dbo.tblPledges.Client_ID = dbo.tblClient.Client_ID WHERE (dbo.tblPledges.StartDate BETWEEN @.Start AND @.End) AND (dbo.tblPledges.Print_Card = 1) AND (dbo.tblPledges.Cards_Printed=0)
SET @.LoopCount = @.LoopCount + 1
END

sql

Monday, March 26, 2012

Need summary rows in a query, but how?

I have ORDERS which contain a number of ITEMS. Both are stored as rows in a
single table, tblOrders.
I would like to make a query that returns a list of items, then a total for
the order as a whole. Something like...
ORDER ID PART ID NAME QUANTITY PRICE NET
1000 1 widget 10 10 100
1000 2 gazeeza 5 5 25
125 < summary row
It appears this is the idea behind CUBE or ROLLUP, but as is typical, the
documentation on this is useless. Does anyone have any examples of how to
actually use this and get the output the way you want?
It appears you have to use GROUP BY for this sort of thing, and this brings
up another question. In the examples above, I want the grouping for the
summary to work only on the ORDER ID. However, as far as I can tell, in order
to get any output at all you need to list every column in the GROUP BY. This
kind of defeats the purpose in this case.
Any pointers?
Maury
"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:1AFFFE59-A8F4-4BD1-8626-C9757BE6597C@.microsoft.com...

> ORDER ID PART ID NAME QUANTITY PRICE NET
> 1000 1 widget 10 10 100
> 1000 2 gazeeza 5 5 25
> 125 < summary row
>
That is not the result of a query. It's a report. It usually makes more
sense to use tools like reporting services for this kind of thing.
To do it in SQL you won't need CUBE/ROLLUP. UNION is probably more
appropriate:
SELECT order_id, tot, part_id, name, quantity, price, net
FROM
(SELECT 0 AS tot, order_id, part_id, name, quantity, price, net
FROM tbl_orders
UNION ALL
SELECT 1, order_id, NULL, NULL, NULL, NULL, SUM(net)
FROM tbl_orders
GROUP BY order_id) AS T
ORDER BY order_id, tot, part_id ;
Apparently your Order table is very denormalized. I hope and expect that you
are aware of that.
Hope this helps.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
sql

Need summary rows in a query, but how?

I have ORDERS which contain a number of ITEMS. Both are stored as rows in a
single table, tblOrders.
I would like to make a query that returns a list of items, then a total for
the order as a whole. Something like...
ORDER ID PART ID NAME QUANTITY PRICE NET
1000 1 widget 10 10 100
1000 2 gazeeza 5 5 25
125 < summary row
It appears this is the idea behind CUBE or ROLLUP, but as is typical, the
documentation on this is useless. Does anyone have any examples of how to
actually use this and get the output the way you want?
It appears you have to use GROUP BY for this sort of thing, and this brings
up another question. In the examples above, I want the grouping for the
summary to work only on the ORDER ID. However, as far as I can tell, in orde
r
to get any output at all you need to list every column in the GROUP BY. This
kind of defeats the purpose in this case.
Any pointers?
Maury"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:1AFFFE59-A8F4-4BD1-8626-C9757BE6597C@.microsoft.com...

> ORDER ID PART ID NAME QUANTITY PRICE NET
> 1000 1 widget 10 10 100
> 1000 2 gazeeza 5 5 25
> 125 < summary row
>
That is not the result of a query. It's a report. It usually makes more
sense to use tools like reporting services for this kind of thing.
To do it in SQL you won't need CUBE/ROLLUP. UNION is probably more
appropriate:
SELECT order_id, tot, part_id, name, quantity, price, net
FROM
(SELECT 0 AS tot, order_id, part_id, name, quantity, price, net
FROM tbl_orders
UNION ALL
SELECT 1, order_id, NULL, NULL, NULL, NULL, SUM(net)
FROM tbl_orders
GROUP BY order_id) AS T
ORDER BY order_id, tot, part_id ;
Apparently your Order table is very denormalized. I hope and expect that you
are aware of that.
Hope this helps.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

Need summary rows in a query, but how?

I have ORDERS which contain a number of ITEMS. Both are stored as rows in a
single table, tblOrders.
I would like to make a query that returns a list of items, then a total for
the order as a whole. Something like...
ORDER ID PART ID NAME QUANTITY PRICE NET
1000 1 widget 10 10 100
1000 2 gazeeza 5 5 25
125 < summary row
It appears this is the idea behind CUBE or ROLLUP, but as is typical, the
documentation on this is useless. Does anyone have any examples of how to
actually use this and get the output the way you want?
It appears you have to use GROUP BY for this sort of thing, and this brings
up another question. In the examples above, I want the grouping for the
summary to work only on the ORDER ID. However, as far as I can tell, in order
to get any output at all you need to list every column in the GROUP BY. This
kind of defeats the purpose in this case.
Any pointers?
Maury"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:1AFFFE59-A8F4-4BD1-8626-C9757BE6597C@.microsoft.com...
> ORDER ID PART ID NAME QUANTITY PRICE NET
> 1000 1 widget 10 10 100
> 1000 2 gazeeza 5 5 25
> 125 < summary row
>
That is not the result of a query. It's a report. It usually makes more
sense to use tools like reporting services for this kind of thing.
To do it in SQL you won't need CUBE/ROLLUP. UNION is probably more
appropriate:
SELECT order_id, tot, part_id, name, quantity, price, net
FROM
(SELECT 0 AS tot, order_id, part_id, name, quantity, price, net
FROM tbl_orders
UNION ALL
SELECT 1, order_id, NULL, NULL, NULL, NULL, SUM(net)
FROM tbl_orders
GROUP BY order_id) AS T
ORDER BY order_id, tot, part_id ;
Apparently your Order table is very denormalized. I hope and expect that you
are aware of that.
Hope this helps.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

Need suggestion on TSql Query with Joins

Hi All,

Please suggest me is there any performance/other differences between the below two queries.

-query1

select T1.name,T1.Number, T2.Dept, T2.Desig

From T1 Inner Join T2 on T1.EID = T2.EID

-query2

select T1.name,T1.Number, T2.Dept, T2.Desig

From T1 Inner Join (Select Dept, Desig From T2) As T2 on T1.EID = T2.EID

Thanks

Senthil

There is no performance difference for your quires.

Both are executed in same way..

Suppose, if your query2, subquery has any distinct or group by clause then the query1 may perform better than query2.

|||Thanks Sekaran!

Need suggesion

I have number of SQL servers like Server1, Server2… deployed in different
cities
There will be one Main Server which gets updated/sync with the all the city
servers
I'm planning to use SQL Replication technology. Is there any other method to
achieve this. Please guide me.
Thanks in advance
Thanks and Regards,
Giri H RamMohan
Hi,
Could you please provide more information from the application side. Is
it DW or OLTP?
|||Giri,
as it sounds as though the data flow is one way then transactional
replication would be suitable. Other competing technologies include
distributed transactions using linked servers and log shipping. To get a
feel for the differences between log shipping and transactional replication,
please have a look at this article:
http://www.replicationanswers.com/Standby.asp
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||I do not now, but same case i have for 3 years and it works perfect just you
need to your own VPN, then main server has to be publisher while other server
has to subsriber.
"Giri RamMohan" wrote:

> I have number of SQL servers like Server1, Server2… deployed in different
> cities
> There will be one Main Server which gets updated/sync with the all the city
> servers
> I'm planning to use SQL Replication technology. Is there any other method to
> achieve this. Please guide me.
>
> Thanks in advance
> Thanks and Regards,
> Giri H RamMohan
>
|||OLTP
Thanks and Regards,
Giri RamMohan
"Angsql" wrote:

> Hi,
> Could you please provide more information from the application side. Is
> it DW or OLTP?
>

Monday, March 19, 2012

Need script generator for DBCC Indexdefrag

Friends
I want to run DBCC INDEXDEFRAG(Db_name, Tab, Idx) for many of the databases . Number is huge and it is near impossible to go to each server and do a manual run. Can someone provide me a scrip to generate the above syntex for all the tables in a db?
ThanksJust happen to have one already created here. It's a BAT file, so rename the extension to either .BAT or .CMD|||If the number is huge, you'll get old before you get done. Is that what you really want?

-PatP|||Thanks for the above file . It is not really that huge. However databases are very large . in access of 350+ gb and I am planning on running them on Weekend when there is little load. Let you guys know how it works out.

Thanks|||BTW, if you want to test it against Northwind, you need to modify line #16 where there is the following:

+ ', ' + o.name + ', ' +

Change it to:

+ ', [' + o.name + '], ' +

Otherwise it'll bomb on non-standard names.

Also, if you want to keep your job, you need to be cautious about running it unattended against potentially highly fragmented indexes. You should probably perform analysis of tables and identify fragmentation degree using SHOWCONTIG.|||I'd expect the defrags to run on 350 Gb in under a week for most cases. That might be somewhat sub-optimal, career-wise.

As rdjabarov suggested, I'd probably do some analysis and selectively run one defrag at a time, when I could at least periodically monitor its behavior.

-PatP|||Hey, don't get me wrong, once the initial defrag is complete, and the percent of fragmentation that gets introduced on a daily basis is identified, - use the script, it's safe. But for the initial defragmentation effort I wouldn't rely on automation unless I know that defrag would not take weeks as Pat suggested. BOL mentions that depending on the fragmentation degree, rebuilding the index may or may not be faster than defragmenting it.|||Guys

Thanks for all the concern raised . I am not going to dump it on Prod as yet. This is one of the steps I was inetrested in. I am going to use it on one of our Sort of QA/Test servers and will see how much time it really takes doing it.
And yes. initial run will be all manual larger tables one at a time on weekend.

Thanks for all your help

Monday, March 12, 2012

Need Query Help

I'm need a query that takes the number from the identity column, then uses
that for the next routine in a range...something like;
Select IdentityNumber
From TableName
Where LastName = 'Somebody'
(Then it takes that IdentityNumber, say row 100, an uses it to grab the rows
on both sides of 100, say 20 rows in each direction. So the second 1/2
of the operation would look like this.
Select FirstName, Lastname, Address
From TableName
Where identitynumbe(100) minus 20 rows and Idenittynumber(100) plus 20 rows.
Thanks in advance
JeffDefine "direction". Rows are not stored in any particular order. Specify a
criteria to sort the data, pot the DDL and some sample data.
ML|||SELECT b.FirstName, b.LastName, b.Address
FROM TableName a JOIN TableName b
ON b.IdentityNumber
BETWEEN (a.IdentityNumber -20) AND (a.IdentityNumber + 20)
WHERE a.LastName = 'Somebody'|||Try something like the following:
select b.FirstName, b.Lastname, b.Address
from TableName a
join TableName b on b.IdentityNumber between a.IdentityNumber - 20 and
a.IdentityNumber + 20
where a.LastName = 'Somebody'
--Brian
(Please reply to the newsgroups only.)
"Jeff" <Jeff@.discussions.microsoft.com> wrote in message
news:F46D2C51-A7CB-45B7-A29B-3A297DF00F98@.microsoft.com...
> I'm need a query that takes the number from the identity column, then uses
> that for the next routine in a range...something like;
> Select IdentityNumber
> From TableName
> Where LastName = 'Somebody'
> (Then it takes that IdentityNumber, say row 100, an uses it to grab the
> rows
> on both sides of 100, say 20 rows in each direction. So the second 1/2
> of the operation would look like this.
> Select FirstName, Lastname, Address
> From TableName
> Where identitynumbe(100) minus 20 rows and Idenittynumber(100) plus 20
> rows.
>
> Thanks in advance
> Jeff|||create table Names (
IdentityNumber int,
LastName varchar(255),
FirstName varchar (255)
LogTime datetime, service varchar( 255), machine varchar( 255)
)
87, Peters, Henry, 08/17/2005 10:14:00.000
88, Smith, John, 08/17/2005 10:15:00.000
89, Johnson, Sally, 08/17/2005 10:16:00.000
90, Harris, Betty, 08/17/2005 10:17:00.000
91, Thomas, Steve, 08/17/2005 10:17:30.00
So the query would search and find Johnson,
but return say 20 rows before sally Johnson
(rows 68-88) and 20 rows after Sally Johnson
(rows 90-110)
Thanks Again!!
"ML" wrote:

> Define "direction". Rows are not stored in any particular order. Specify a
> criteria to sort the data, pot the DDL and some sample data.
>
> ML|||>> So the query would search and find Johnson, but return say 20 rows before
Generate a rank column based on the whichever column you want to use to
sequence your data and then use it in your WHERE clause. There are several
ways you can write this & here is one with a derived table construct using
the datetime column used for sequencing :
SELECT t1.*
FROM tbl t1, ( SELECT rank - 20, rank + 20
FROM ( SELECT t1.fname, COUNT( * )
FROM tbl t1, tbl t2
WHERE t2.dt <= t1.dt
GROUP BY t1.id, t1.fname, t1.lname, t1.dt
) T ( fname, rank )
WHERE fname = 'Johnson' ) D ( r1, r2 )
WHERE ( SELECT COUNT( * )
FROM tbl t2
WHERE t2.dt <= t1.dt ) BETWEEN r1 AND r2 ;
A view could give you a easier read like:
CREATE VIEW vw ( id, fname, lname, dt, rank ) AS
SELECT t1.id, t1.fname, t1.lname, t1.dt, COUNT( * )
FROM tbl t1, tbl t2
WHERE t2.dt <= t1.dt
GROUP BY t1.id, t1.fname, t1.lname, t1.dt
Now, the query is simpler:
SELECT *
FROM vw v1, vw v2
WHERE v1.rank BETWEEN v2.rank - 2 AND v2.rank + 2
AND v2.fname = 'Johnson' ;
Anith|||On Thu, 18 Aug 2005 08:20:03 -0700, Jeff wrote:

>create table Names (
>IdentityNumber int,
>LastName varchar(255),
>FirstName varchar (255)
>LogTime datetime, service varchar( 255), machine varchar( 255)
> )
>87, Peters, Henry, 08/17/2005 10:14:00.000
>88, Smith, John, 08/17/2005 10:15:00.000
>89, Johnson, Sally, 08/17/2005 10:16:00.000
>90, Harris, Betty, 08/17/2005 10:17:00.000
>91, Thomas, Steve, 08/17/2005 10:17:30.00
>So the query would search and find Johnson,
>but return say 20 rows before sally Johnson
>(rows 68-88) and 20 rows after Sally Johnson
>(rows 90-110)
>Thanks Again!!
Hi Jeff,
Untested (since you didn't post the sample data as INSERT statements):
SELECT n1.IdentityNumber, n1.LastName, n1.FirstName, n1.LogTime
FROM Names AS n1
WHERE EXISTS
(SELECT *
FROM Names AS n2
WHERE n2.LastName = 'Johnson'
AND n1.IdentityNumber BETWEEN n2.IdentityNumber - 20
AND n2.IdentityNumber + 20)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Saturday, February 25, 2012

need help, How to change datatype in order to sort some extracted numbers from string

Hello,

I am trying to extract from some strings like the following strings the number and order them by that number:

Box 1
Box 2
Box 3
Box 20
Box 21
...(and so on)

The problem I am having is that I already extracted the number using

Substring([field],[starting position],[lenght])

but the output seems to be in a string format, so the order is not in an ascending order.

Thanks for any suggestions.

You need to cast the result as a number. It looks like your number is always an integer so the following should do it:

(DT_I4)Substring([field],[starting position],[lenght])

-Jamie

|||I tried it but I am getting an SQL Execution Error message,

I am doing this on the Query Builder using Visual Studio 2005.net

|||

If you're getting an error message its useful to post it up here!

-Jamie

|||Sorry, I am behind a very restrictive firewall at work, doesnt let me get inthere!

Why should I post it somewhere else, anyways?

|||

mendez_edd wrote:

Sorry, I am behind a very restrictive firewall at work, doesnt let me get inthere!

It doesn't let you get to where? Can you replicate the error in BIDS?

mendez_edd wrote:


Why should I post it somewhere else, anyways?

Posting the error message helps people deduce what is causing the error!

-Jamie

|||

Where are you doing this? Jamie’s solution was for a SSIS expression as you might use in the Derived Column Transform. Your did mention a SQL exception, but since this is a SSIS forum, we are kind of thinking you may want a SSIS solution.

To sort like a number, convert the value to a number, so strip off the text as Jamie suggested, or pad the numeric part with spaces ans sort as a string–
Box 1
Box 2
Box 21
Box 22

(Note the extra space for single digit numbers.)

Regardless of your firewall you can post to this forum, so could you not type the error message text you get into a post?