Thursday, March 29, 2012
comparing time
2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
AM# and the comparison fields are starttime = #05:00:00 PM# and
endtime=#02:00:00 AM#)?
Thanks,
Mary Fran
WHERE
(LastUpdated >= StartTime AND LastUpdated < EndTime)
...
;
?
"Mary Fran" <MaryFran@.discussions.microsoft.com> wrote in message
news:1169DCB8-7C42-4156-8F27-9733F65F846E@.microsoft.com...
> How do I determine if the time value of a datetime field (in SQL) is
> between
> 2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
> AM# and the comparison fields are starttime = #05:00:00 PM# and
> endtime=#02:00:00 AM#)?
> Thanks,
> Mary Fran
|||> How do I determine if the time value of a datetime field (in SQL) is
> between
> 2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
> AM# and the comparison fields are starttime = #05:00:00 PM# and
> endtime=#02:00:00 AM#)?
If I understand correctly, you want to ignore the date part of the database
column. Furthermore, when the specified start time is greater than the end
time, you want to reverse the criteria.
There may be more elegant methods but I believe the example below will
accomplish the task. Be advised that this technique will require a scan
because of the non-sargable expression. A more efficient approach is to
store time with a base date like January 1, 1900 to facilitate searches on
time only.
SELECT LastUpdated
FROM dbo.MyTable
WHERE
(@.TimeOnlyStart < @.TimeOnlyEnd AND
DATEADD(day, DATEDIFF(day, '19000101', LastUpdated)*-1, LastUpdated)
BETWEEN @.TimeOnlyStart AND @.TimeOnlyEnd)
OR
(@.TimeOnlyStart >= @.TimeOnlyEnd AND
(DATEADD(day, DATEDIFF(day, '19000101', LastUpdated)*-1,
LastUpdated) > @.TimeOnlyStart
OR DATEADD(day, DATEDIFF(day, '19000101', LastUpdated)*-1,
LastUpdated) < @.TimeOnlyEnd)
)
Hope this helps.
Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
"Mary Fran" <MaryFran@.discussions.microsoft.com> wrote in message
news:1169DCB8-7C42-4156-8F27-9733F65F846E@.microsoft.com...
> How do I determine if the time value of a datetime field (in SQL) is
> between
> 2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
> AM# and the comparison fields are starttime = #05:00:00 PM# and
> endtime=#02:00:00 AM#)?
> Thanks,
> Mary Fran
|||Sorry, after reading Dan's response, I realize I misunderstood the question.
A slightly different approach (which also accounts for the case where start
and end time are the same, and lastupdated falls on that instant):
CREATE TABLE #foo
(
i INT,
LastUpdated DATETIME,
StartTime SMALLDATETIME,
EndTime SMALLDATETIME
);
SET NOCOUNT ON;
INSERT #foo SELECT 1,'2007-05-29 01:04:32', '05:00 PM', '02:00 AM'; --
should match
INSERT #foo SELECT 2,'2007-05-29 12:04:32', '05:00 PM', '02:00 AM';
INSERT #foo SELECT 3,'2007-05-29 16:04:32', '05:00 PM', '02:00 AM';
INSERT #foo SELECT 4,'2007-05-29 19:04:32', '05:00 PM', '02:00 AM'; --
should match
INSERT #foo SELECT 5,'2007-05-29 16:04:32', '05:00 PM', '11:00 PM';
INSERT #foo SELECT 6,'2007-05-29 16:04:32', '03:00 PM', '07:00 PM'; --
should match
SELECT i,LastUpdated
FROM (
SELECT i,LastUpdated,
delta = DATEDIFF(MINUTE,0,DATEADD(DAY,-DATEDIFF(DAY,0,LastUpdated),
LastUpdated)),
s = DATEDIFF(MINUTE,0,StartTime),
e = DATEDIFF(MINUTE,0,EndTime),
r = ABS(DATEDIFF(MINUTE,StartTime,EndTime))
FROM #foo
) x
WHERE (delta BETWEEN s AND s+r)
OR delta = CASE WHEN s = e THEN delta ELSE -1 END
OR delta <= CASE WHEN e < s THEN e ELSE -1 END;
DROP TABLE #foo;
sqlsql
comparing time
2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
AM# and the comparison fields are starttime = #05:00:00 PM# and
endtime=#02:00:00 AM#)?
Thanks,
Mary FranWHERE
(LastUpdated >= StartTime AND LastUpdated < EndTime)
...
;
?
"Mary Fran" <MaryFran@.discussions.microsoft.com> wrote in message
news:1169DCB8-7C42-4156-8F27-9733F65F846E@.microsoft.com...
> How do I determine if the time value of a datetime field (in SQL) is
> between
> 2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
> AM# and the comparison fields are starttime = #05:00:00 PM# and
> endtime=#02:00:00 AM#)?
> Thanks,
> Mary Fran|||> How do I determine if the time value of a datetime field (in SQL) is
> between
> 2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
> AM# and the comparison fields are starttime = #05:00:00 PM# and
> endtime=#02:00:00 AM#)?
If I understand correctly, you want to ignore the date part of the database
column. Furthermore, when the specified start time is greater than the end
time, you want to reverse the criteria.
There may be more elegant methods but I believe the example below will
accomplish the task. Be advised that this technique will require a scan
because of the non-sargable expression. A more efficient approach is to
store time with a base date like January 1, 1900 to facilitate searches on
time only.
SELECT LastUpdated
FROM dbo.MyTable
WHERE
(@.TimeOnlyStart < @.TimeOnlyEnd AND
DATEADD(day, DATEDIFF(day, '19000101', LastUpdated)*-1, LastUpdated)
BETWEEN @.TimeOnlyStart AND @.TimeOnlyEnd)
OR
(@.TimeOnlyStart >= @.TimeOnlyEnd AND
(DATEADD(day, DATEDIFF(day, '19000101', LastUpdated)*-1,
LastUpdated) > @.TimeOnlyStart
OR DATEADD(day, DATEDIFF(day, '19000101', LastUpdated)*-1,
LastUpdated) < @.TimeOnlyEnd)
)
Hope this helps.
Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
"Mary Fran" <MaryFran@.discussions.microsoft.com> wrote in message
news:1169DCB8-7C42-4156-8F27-9733F65F846E@.microsoft.com...
> How do I determine if the time value of a datetime field (in SQL) is
> between
> 2 other time fields (e.g., I have a LastUpdated field =#5/29/2007 12:04:32
> AM# and the comparison fields are starttime = #05:00:00 PM# and
> endtime=#02:00:00 AM#)?
> Thanks,
> Mary Fran|||Sorry, after reading Dan's response, I realize I misunderstood the question.
A slightly different approach (which also accounts for the case where start
and end time are the same, and lastupdated falls on that instant):
CREATE TABLE #foo
(
i INT,
LastUpdated DATETIME,
StartTime SMALLDATETIME,
EndTime SMALLDATETIME
);
SET NOCOUNT ON;
INSERT #foo SELECT 1,'2007-05-29 01:04:32', '05:00 PM', '02:00 AM'; --
should match
INSERT #foo SELECT 2,'2007-05-29 12:04:32', '05:00 PM', '02:00 AM';
INSERT #foo SELECT 3,'2007-05-29 16:04:32', '05:00 PM', '02:00 AM';
INSERT #foo SELECT 4,'2007-05-29 19:04:32', '05:00 PM', '02:00 AM'; --
should match
INSERT #foo SELECT 5,'2007-05-29 16:04:32', '05:00 PM', '11:00 PM';
INSERT #foo SELECT 6,'2007-05-29 16:04:32', '03:00 PM', '07:00 PM'; --
should match
SELECT i,LastUpdated
FROM (
SELECT i,LastUpdated,
delta = DATEDIFF(MINUTE,0,DATEADD(DAY,-DATEDIFF(DAY,0,LastUpdated),
LastUpdated)),
s = DATEDIFF(MINUTE,0,StartTime),
e = DATEDIFF(MINUTE,0,EndTime),
r = ABS(DATEDIFF(MINUTE,StartTime,EndTime))
FROM #foo
) x
WHERE (delta BETWEEN s AND s+r)
OR delta = CASE WHEN s = e THEN delta ELSE -1 END
OR delta <= CASE WHEN e < s THEN e ELSE -1 END;
DROP TABLE #foo;
Comparing text in WHERE
Hi everyone,
I am compare to text fields like this:
CREATE PROCEDURE dbo.PCAttByVal
(
@.Value text
)
AS
BEGIN
SET NOCOUNT ON
SELECT ID FROM PCAtt WHERE Value=@.Value
END
But the environment (I use VS2005) says that the data type is incompatible with the equal operator. Then I tried:
CREATE PROCEDURE dbo.PCAttByVal
(
@.Value text
)
AS
BEGIN
SET NOCOUNT ON
SELECT ID FROM PCAtt WHERE Value IN '('+@.Value+')'
END
But nada (nothing). Any ideas? I can't change the data type since this field will hold values of different sizes.
Thank you for your input in advance!
hi,
text/ntext datatype does not support this kind of operation/comparison... you can find the "available" methods against these datatypes in http://msdn2.microsoft.com/en-us/library/ms187993.aspx..
these datatype are not good candidates for "filtering" operations as well.. consider that text can hold up to 2gb of data, and it's not worth the problem to support such heavy features..
so you can end up with "workarounds" if they fit your needs, similar to
SET NOCOUNT ON; USE tempdb; GO CREATE TABLE dbo.TestTB ( Id int NOT NULL PRIMARY KEY, Value text NULL ); GO INSERT INTO dbo.TestTB VALUES ( 1 , 'some text' ); INSERT INTO dbo.TestTB VALUES ( 2 , 'some other text' ); GO DECLARE @.key varchar(10); SET @.key = 'some text'; SELECT * FROM dbo.TestTB WHERE SUBSTRING( Value, 1, DATALENGTH(@.key)) = @.key; GO DROP TABLE dbo.TestTB; --<- Id Value -- 1 some textbut consider the other methods as well..
if you are using SQL Server 2005, consider moving the text/ntext datatypes to varchar(MAX)/nvarchar(MAX), as text datatype has been deprecated and, more usefull, varchar(MAX) supports all the traditional "string" operations...
regards
sqlsqlSunday, March 25, 2012
Comparing Money
I have a field in database money. When I enter value for it the amount entered is for example 20.000. How can I compare this value with noraml vaules i.e. like 20 in my search engine. Will I need to convert it to varchar and then compare it or is there some other way. Also if I need to convert it to varchar, how can I do it?
Thanks in advance,
UdayIt seems to me that you don't need to do any conversion. This code works as expected for me:
DECLARE @.myMoney Money
SELECT @.myMoney = 20.000-- this returns Found
SELECT CASE WHEN @.myMoney = 20 THEN 'Found' ELSE 'Not Found' END-- this returns Not Found
SELECT @.myMoney = 20.500
SELECT CASE WHEN @.myMoney = 20 THEN 'Found' ELSE 'Not Found' END-- this returns Not Found
SELECT @.myMoney = 2.000
SELECT CASE WHEN @.myMoney = 20 THEN 'Found' ELSE 'Not Found' END
Or are you saying that in my second example you need to return Found?
Terri|||Hi,
What I want to do is if someone enter 20 and searches, all the value in money datatype with 20.000 should come out as a result.
Thanks in advance,
Uday.|||Maybe you should show us the code for this that you have that is not working the way you need. This way we can focus on your exact issue.
Terri|||Hi,
The code is as below:
select * from test where price='26' in which price is of datatype money and the value in the database is 26.0000. Hope you will be able to understand my problem.
Thanks in advance,
Uday|||If price is datatype money then you should not enclose 26 in single quotes. With the single quotes the database is forced to try to do an implicit conversion from varchar to money for the comparison, which it will not do. Remove the single quotes and you should have better luck.
select * from test where price=26
Terri|||Hi,
I tried that, it's working.
Thanks
Uday.
Comparing fields within a select
Is it possible for a query to return all the records in a table which have the same value in a given column?
SELECT * FROM table1 WHERE field1 = 2
..would return all the records from table1 which have a field1 value of 2 but I don't want to specify the value - just that all the records have the same value.
Cheers,
WT.I'm not sure I understand what you're trying to do. Are you trying to return all records where the values in field1 are repeated? Can you provide an example to clarify?|||I think I understand what you are asking for. You're looking for all records where there are duplicates in field1.
Kind of the opposite of a DISTINCT query.
If you do a self join you can get what you want.
Here's the generic form...
SELECT * FROM table1 WHERE field1 IN (SELECT DISTINCT T1.field1 FROM table1.T1, table1.T2 WHERE T1.field1=T2.field1 AND T1.Field2<>T2.field2)
Here's an example using the Customers table from NorthWind that will return all the customers in cities where there is more than one customer in that city...
SELECT DISTINCT C1.CITY FROM Customers C1, Customers C2 WHERE C1.City = C2.City and C1.CustomerID <> C2.CustomerID|||An easier way to do this (if I understand your question):
SELECT CompanyID, COUNT(*)
Companies
GROUP BY CompanyID
HAVING COUNT(*) > 1
comparing encrypted strings
I have a table called test table which has a column called password. The fields in that column were encrypted using the pwdencrypt() function. I need to be able to compare those encrypted fields to regular nvarchar strings. Right now I am using the pwdcompare() function to compare the values but I'm not getting the desired results.
This is what I am doing
select *
from testtable
where pwdcompare(pwdencrypt('pass_tempx'),testtable.pass word) = 1Check this one:
create table users(
id int identity,
username nvarchar(128) not null unique,
userpassword nvarchar(128) not null
)
insert users(username,userpassword)
select 'tom',pwdencrypt('tom2')
insert users(username,userpassword)
select 'brett',pwdencrypt('brett2')
select Id from users
where pwdcompare('tom2',userpassword)=1
and username='tom'
Id
----
1
(1 row(s) affected)
select Id from users
where pwdcompare('brett3',userpassword)=1
and username='brett'
Id
----|||Thanks for the feedback but it still isn't working for me. I've got my table set up just like yours but my username and userpassword fields are set up as nvarchar(15). Does this make a difference? Is there any other way to compare the 2 strings?
Originally posted by snail
Check this one:
create table users(
id int identity,
username nvarchar(128) not null unique,
userpassword nvarchar(128) not null
)
insert users(username,userpassword)
select 'tom',pwdencrypt('tom2')
insert users(username,userpassword)
select 'brett',pwdencrypt('brett2')
select Id from users
where pwdcompare('tom2',userpassword)=1
and username='tom'
Id
----
1
(1 row(s) affected)
select Id from users
where pwdcompare('brett3',userpassword)=1
and username='brett'
Id
----|||Originally posted by grualo1
Thanks for the feedback but it still isn't working for me. I've got my table set up just like yours but my username and userpassword fields are set up as nvarchar(15). Does this make a difference? Is there any other way to compare the 2 strings?
MS is using nvarchar(128) for keeping a passwors and I guess functions pwdcompare and pwdencrypt are working only for this length of string.|||Changing the length to 128 did the trick thank you so much!
Gary
Originally posted by snail
MS is using nvarchar(128) for keeping a passwors and I guess functions pwdcompare and pwdencrypt are working only for this length of string.
Tuesday, March 20, 2012
Comparing a Date Value in SQL against Todays Date
Any ideas would be great.
Thanks
Orbital
you can use the t-sql function: getdate() in your query
sqlsqlComparing 2 different Group's aggregate Values
In my report, i've 3 groups and i want to hide a group footer by
comparing a textbox value in group1 and a textbox value in group2, for
eg., i've Sum(Fields!Amount.Value,"table1_group1") in one of group1
footer's textbox and Sum(Fields!Amount.Value,"table1_group2") in one of
group2 footer's textbox, if both these values are same i want to hide
group1 footer, but i am getting "The value expression for the textbox
has a scope parameter that is not valid for an aggregate function. The
scope parameter must be set to a string constant that is equal to
either the name of a containing group, the name of a containing data
region, or the name of a data set.", any workaround methods for this?.
Your help is highly appreciated.
Thanks in advance
SenTextboxes are ReportItems. To hide a footer base on the value of two
textboxes set the Visible(Hidden) property to:
1. =ReportItems!textbox1.Value + ReportItems!textbox2.Value = 10 or
=IIF(ReportItems!textbox1.Value + ReportItems!textbox2.Value = 10,
False, True)
"Sen" wrote:
> Hi All,
> In my report, i've 3 groups and i want to hide a group footer by
> comparing a textbox value in group1 and a textbox value in group2, for
> eg., i've Sum(Fields!Amount.Value,"table1_group1") in one of group1
> footer's textbox and Sum(Fields!Amount.Value,"table1_group2") in one of
> group2 footer's textbox, if both these values are same i want to hide
> group1 footer, but i am getting "The value expression for the textbox
> has a scope parameter that is not valid for an aggregate function. The
> scope parameter must be set to a string constant that is equal to
> either the name of a containing group, the name of a containing data
> region, or the name of a data set.", any workaround methods for this?.
> Your help is highly appreciated.
> Thanks in advance
> Sen
>|||Hi,
Thanks for your suggestion.
I tried your option also, but i'm getting the following error,
"Report item expressions can only refer to other report items within the
same grouping scope or a containing grouping scope". The problem here is i'm
trying to compare 2 different group's textboxes. So i'm getting this error.
Any help is highly appreciated. I tried with other options of hidden
expressions and all, but it didn't help me. I cannot modify the Stored Procs
used for this report.
Thanks and Regards,
Sen
"OriginalStealth" wrote:
> Textboxes are ReportItems. To hide a footer base on the value of two
> textboxes set the Visible(Hidden) property to:
> 1. =ReportItems!textbox1.Value + ReportItems!textbox2.Value = 10 or
> =IIF(ReportItems!textbox1.Value + ReportItems!textbox2.Value = 10,
> False, True)
>
> "Sen" wrote:
> > Hi All,
> >
> > In my report, i've 3 groups and i want to hide a group footer by
> > comparing a textbox value in group1 and a textbox value in group2, for
> > eg., i've Sum(Fields!Amount.Value,"table1_group1") in one of group1
> > footer's textbox and Sum(Fields!Amount.Value,"table1_group2") in one of
> > group2 footer's textbox, if both these values are same i want to hide
> > group1 footer, but i am getting "The value expression for the textbox
> > has a scope parameter that is not valid for an aggregate function. The
> > scope parameter must be set to a string constant that is equal to
> > either the name of a containing group, the name of a containing data
> > region, or the name of a data set.", any workaround methods for this?.
> > Your help is highly appreciated.
> >
> > Thanks in advance
> > Sen
> >
> >sqlsql
compare values within subreport to main report
compare it to a value iwthin the main report. We are trying to see if
the value in the subreport is greater than the value returned in the
main report. We want to make the value test red if it is greater than.
I know how to compare these values if they were in the same report, but
when it comes to subreports I am lost. Any ideas? Thanks in advance.
One way to do this would be to pass hidden parameters to the subreport.
Here is one example of parameters passed.
http://www.simple-talk.com/sql/learn-sql-server/beginning-sql-server-2005-reporting-services-part-2/
|||I figured out the solution. You have to send the value you want as a parameter over to the subreport.
Right click on the subreport go to properties > Parameters tab and pass in the field you want off the main report
Then go to your subreport and add the extra parameter under Report Parameters
Now you have access to the value from the SubReport in Main Report
Thanks for your help!
compare values within subreport to main report
compare it to a value iwthin the main report. We are trying to see if
the value in the subreport is greater than the value returned in the
main report. We want to make the value test red if it is greater than.
I know how to compare these values if they were in the same report, but
when it comes to subreports I am lost. Any ideas? Thanks in advance.
MissyDid you ever find an answer to this? I'm having the same issue.
"aggiechick717" wrote:
> I was wondering if anyone knew how to take a value from a subreport and
> compare it to a value iwthin the main report. We are trying to see if
> the value in the subreport is greater than the value returned in the
> main report. We want to make the value test red if it is greater than.
> I know how to compare these values if they were in the same report, but
> when it comes to subreports I am lost. Any ideas? Thanks in advance.
>
> Missy
>|||Nevermind. I was trying to access the total in a subreport for use on my
main report, but I just setup a second datasource on my main report with the
total. That worked.
"daw" wrote:
> Did you ever find an answer to this? I'm having the same issue.
> "aggiechick717" wrote:
> > I was wondering if anyone knew how to take a value from a subreport and
> > compare it to a value iwthin the main report. We are trying to see if
> > the value in the subreport is greater than the value returned in the
> > main report. We want to make the value test red if it is greater than.
> > I know how to compare these values if they were in the same report, but
> > when it comes to subreports I am lost. Any ideas? Thanks in advance.
> >
> >
> > Missy
> >
> >
Compare value
I just start ti study SQL, Pls advice the solution for the case below :
I have 2 table : order_detail and ship_detail
Order_id Ship_id
Designation Designation
qty qty
I'd like to write the SQL command that show me the status of each order and the item is complete or non complete shipped
Thanks & Best regards
CitronWhat field ties the order detail to the ship detail (is ship_id the same as order_id ) ? What does the designation field store - how do you know when an item has been shipped or not ?
Monday, March 19, 2012
compare two different date format column?
Hi guys,
I want to compare two date fields, which are located on different tables. One field contains a date value in this format: ###/###-#### and the other field on the other table contains (###-###-#### and some ##########)
So I want to compare this two different format. May be changing both the formats to a common format and make the comparison, something like that.
Any idea is appreciate.
Hi Amde
Just for clarity, would you be able to provide real examples (from your tables) of a date in each format?
Thanks
Chris
oh yeah,
Table 1.
Phone no.
847/678-2828
Table 2.
Phone no.
333-777-5555
252 321 3333
2223334444
(123)456-789
...
|||For phone numbers, I would consider creating a Function that strips out all but the numbers -and then saving and comparing only numbers. (Leave the formating for the client application.)
Comparing DATE fields will be somewhat different -however formating is not an issue if the datatype is (small)datetime. If Date data is stored as (var)char -that is a whole different can of worms.
|||Well that changes things slightly - you originally said that these were date fields...
Another couple of questions - how many rows of data are you looking to compare? Are there any other formats that we should know about?
Thanks
Chris
I've just put together the function below that will strip any non-numerical characters from an input string.
Don't expect fantastic performance from the function when comparing thousands of rows. It would be far better, as Arnie highlighted, to store an unformatted string and leave the formatting to the client.
Chris
CREATE FUNCTION dbo.CleanString(@.InputString VARCHAR(8000))
RETURNS VARCHAR(8000)
WITH RETURNS NULL ON NULL INPUT
AS
BEGIN
DECLARE @.NewString VARCHAR(8000)
SET @.NewString = ''
DECLARE @.ValidChars CHAR(10)
SET @.ValidChars = '0123456789'
DECLARE @.Loop INT
SET @.Loop = 1
WHILE @.Loop <= LEN(@.InputString)
BEGIN
IF CHARINDEX(SUBSTRING(@.InputString, @.Loop, 1), @.ValidChars) > 0
SET @.NewString = @.NewString + SUBSTRING(@.InputString, @.Loop, 1)
SET @.Loop = @.Loop + 1
END
RETURN @.NewString
END
GO
SELECT dbo.CleanString('1329842DCXLXMC2QPWXMQWX09SWDM09324')
--Returns: 132984220909324
SELECT CASE WHEN dbo.CleanString('1M&&2-FL3FCM4+=5M#6khn7wmx8KE9AAS0')
= dbo.CleanString('cxmn1dUI2QWWJHB3NCU4PWCK5IVN67DBW8XW9K 0')
THEN 'These strings are the same when cleansed.'
END,
dbo.CleanString('1M&&2-FL3FCM4+=5M#6khn7wmx8KE9AAS0'),
dbo.CleanString('cxmn1dUI2QWWJHB3NCU4PWCK5IVN67DBW8XW9K 0')
--Returns: 'These strings are the same when cleansed.', 1234567890, 1234567890
|||
Oh!my bad, I am really sorry.
- I want to say a phone number (which is varchar data type)
- The first table contain about 40,000 records and the second table contains about 60, 000 records. So I want to get the difference.
- Those are the common formats. I hope if I find a solution for one of the format, I can apply similar logic.
Sorry for the confusion.
|||For a large amount of data, avoiding the loop may increase performance.
By using a 'Numbers' table, this method avoids looping.
-- Prepare Numbers Table
SET NOCOUNT ON
CREATE TABLE Numbers ( n int )
GO
DECLARE @.n int
SET @.n = 1
WHILE @.n < 100
BEGIN
INSERT INTO Numbers VALUES ( @.n )
SET @.n = ( @.n + 1 )
END
-- End Numbers Table
CREATE FUNCTION dbo.NumbersOnly
( @.Text varchar(100) )
RETURNS varchar(100)
AS
BEGIN
DECLARE @.Output varchar(100)
SELECT @.Output = ''
SELECT @.Output = @.Output + CASE
WHEN RealNum LIKE '[0-9]'
THEN RealNum
ELSE ''
END
FROM (SELECT substring( @.Text, n, 1 ) RealNum
FROM Numbers
) d
RETURN @.Output
END
GO
SELECT dbo.NumbersOnly( '(555) 987-4321' )
--
5559874321
You should clean the data and store it in a normalized manner. This is the best way to handle. Solutions using UDFs are fine but they will be slow and you will have to keep changing them if you find newer formats or rules. For example, how do you handle phone numbers like 1-800-96MSFAX? What about phone numbers from other countries etc? There are so many cases where hard-coded solutions break and you will end up with more problems than necessary. I have built data warehouses in the past (in my previous company for data mining/analytics purpose) and we used public geography data, address book scrubbing software etc. So it is better to invest in a solution or package that is specialized for the type of data you are dealing with and focus on your business problem. Once you normalize the phone numbers then it is very easy to compare them - you can easily restrict phone numbers based on country code for example or compare different formats easily.
|||I agree with you. Having a normalized database is the best thing. However, I want to do this task only for the time being. Here is the thing, I received an excel sheet which contains thousands of records. On the other hand we have a table in our database. So my goal is to get the difference and insert the new data to my table. So what I did is I created an SSIS package to migrate the excel sheet data into SQL Server table, so that it will be easy to write a query to get the differential data. Inserting the data is not an issue. All I need is to compare these two tables and get the different. The only unique field I have to do the comparison is the PHONE column. And the PHONE column has a different format, as I tried to explain before.
Thx.
|||Thanks guys, I really appreciate your help. I'm good now.
Compare Triggers Values
How to create a trigger before insert that if a new row is giong to be
inserted in a table the trigger compares a value of a column from the
table with the value of a column in the record to be inserted...
Regards
Muhammad Bilal
<bilal_4x@.hotmail.com>
*** Sent via Developersdex http://www.examnotes.net ***Use of inserted table and deleted table in the trigger can help you.
According to BOL
two special tables are used in trigger statements: the deleted table
and the inserted table. SQL Server 2000 automatically creates and
manages these tables. You can use these temporary, memory-resident
tables to test the effects of certain data modifications and to set
conditions for trigger actions;
Look at books online for more details and samples.
Or
Post your table with DDL and data and describe your problem.
Regards
Amish
Compare the data in the 1st row with data in the 2nd row
I need to be able to compare the value of a column in row 1 of table with the value of the same column in row 2 and then row 2 with row 3 and row 3 with row 4 and so on and so. I have to be able to do this with a sql query not in a stored proc or function, etc. Any ideas?
I am using SQL Enterprise Manager Version: 8.0
How to dynamically number rows in a SELECT Transact-SQL statement
http://support.microsoft.com/default.aspx?scid=kb;en-us;186133
Also, check IDENTITY property in BOL.
create table #t1(c1 int not null identity unique, c2 int)
insert into #t1(c2)
select c2
from your_table
order by c2
select a.c1, b.c1, a.c2, b.c2
from #t1 as a inner join #t1 as b on a.c1 = b.c1 - 1
AMB
|||Here one more approach,
Code Snippet
Create Table #mytable (
[Data1] int ,
[Data2] Char
);
Insert Into #mytable Values('10','A');
Insert Into #mytable Values('2','B');
Insert Into #mytable Values('3','A');
Insert Into #mytable Values('45','Z');
Insert Into #mytable Values('18','B');
Insert Into #mytable Values('29','K');
--use into to store the data into Temp table
Select * into #temp from #mytable Order By data1;
--Add the Identity Column
Alter table #temp Add RowId int identity(1,1);
--Join with RowId
select
Up.*,
Down.*
from
#temp Up
Inner Join #temp Down
on Up.RowId = Down.RowId-1
|||
Hi Manivannan,
The script is ok, but it is not deterministic. You can have different result using same data, because you are inserting into #mytable with no order.
AMB
|||Yeap.. I missed it.. Thanks for pointing that.. Fixed now..
compare string to hash value
Ok, here is what i'm trying to do and its driving me nuts.
ok,
1) I have a proc that runs and needs to validate the user prior to running - this proc is called from an hand held device
2) the id and password are being passed as "clear text" but the password is stored in the database table hashed.
Is there anything on the db side that can get the hash value from the password column of the aspnet_membership table and compare it to the password being passed in to this proc? I have suggested several options to the handheld developer but nothing. This has to be done on the database side.
so,
username and password are passed to proc from handheld.
proc needs to validate ther user in the aspnet_membership table
if user id and password are valid execute the stored procedure
is this possible? if so can ANYONE point me to some examples of this being done?
You should post in the SQL Server Compact forum as not all features available in SQL Server Standard and higher are also available in Compact.
Thanks
Laurentiu
|||This isn't related to SQL compact. I need to do this on the main database since the user is connecting to that to run this stored procedure. This isn't a hand held, SQL compact related question. Its a SQL in general related question.
|||I see, I assumed this was related to the scenario you posted about earlier, where you mentioned the database as being SQL Server Compact Edition.
If you want to do a hash computation, you can look at using the HashBytes builtin function. It supports SHA1.
Thanks
Laurentiu
Sunday, March 11, 2012
compare row with previous row value in RDL
I have a table, which displays the rows binded, now I need to compare a
textbox value in the table with the previous value and if matches then I need
to display the text box values with paranthesis [value].
How do I compare values in the RDL
Thanks in advance
Balaji
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-reporting/200509/1Not sure if this works in your case, but if you just need to get the
previous value in a table detail row, you could use the Previous(...)
aggregate function.
E.g. =iif(Fields!A.Value = Previous(Fields!A.Value), "(" & Fields!A.Value &
")", Fields!A.Value)
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"BALAJI K via SQLMonster.com" <u5178@.uwe> wrote in message
news:54f11b486df84@.uwe...
> Hi All,
> I have a table, which displays the rows binded, now I need to compare a
> textbox value in the table with the previous value and if matches then I
> need
> to display the text box values with paranthesis [value].
> How do I compare values in the RDL
> Thanks in advance
> Balaji
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-reporting/200509/1
Compare Date Values!
In the following query i want to compare only the date value portions of the
'attempt_dt' columns in the where clause.
All time related information information is to be ignored!!!!
SELECT
a.attempt_dt,
(SELECT
Count(asmt_v2_employee_id)
FROM
asmt_v2_attempts a2
INNER JOIN
asmt_v2_question_results r
ON
a2.asmt_v2_attempt_id = r.asmt_v2_attempt_id
WHERE
r.asmt_v2_question_id = 170
AND
a2.attempt_dt = a.attempt_dt //compare date portions of values
)
FROM
asmt_v2_attempts a
What is the best way to do this? Using some sort of date functionality?
Examples & help appreciated!!!
Cheers,
AdamAdam
> In the following query i want to compare only the date value portions of
> the 'attempt_dt' columns in the where clause.
SELECT CAST(CONVERT(VARCHAR(10),GETDATE(),112)A
S DATETIME)
Note: By using above tecnique you may face a perfomance problem , the
optimizer will not be able to use an index on this column
"Adam Knight" <adam@.pertrain.com.au> wrote in message
news:ugUp21vyFHA.2556@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> In the following query i want to compare only the date value portions of
> the 'attempt_dt' columns in the where clause.
> All time related information information is to be ignored!!!!
> SELECT
> a.attempt_dt,
> (SELECT
> Count(asmt_v2_employee_id)
> FROM
> asmt_v2_attempts a2
> INNER JOIN
> asmt_v2_question_results r
> ON
> a2.asmt_v2_attempt_id = r.asmt_v2_attempt_id
> WHERE
> r.asmt_v2_question_id = 170
> AND
> a2.attempt_dt = a.attempt_dt //compare date portions of values
> )
> FROM
> asmt_v2_attempts a
> What is the best way to do this? Using some sort of date functionality?
> Examples & help appreciated!!!
> Cheers,
> Adam
>|||Adam
try this .
But remeber it works only when u r using(=) NOT >< etc. It still uses
indexes.
DAY(a2.attempt_dt) = DAY(a.attempt_dt ) AND MONTH(a2.attempt_dt) =
MONTH(a.attempt_dt ) AND YEAR(a2.attempt_dt) AND YEAR(a.attempt_dt )
Regards
R.D
--Knowledge gets doubled when shared
"Uri Dimant" wrote:
> Adam
> SELECT CAST(CONVERT(VARCHAR(10),GETDATE(),112)A
S DATETIME)
> Note: By using above tecnique you may face a perfomance problem , the
> optimizer will not be able to use an index on this column
>
> "Adam Knight" <adam@.pertrain.com.au> wrote in message
> news:ugUp21vyFHA.2556@.TK2MSFTNGP10.phx.gbl...
>
>|||OOPS
try this
(DAY(a2.attempt_dt) = DAY(a.attempt_dt )) AND (MONTH(a2.attempt_dt) =
MONTH(a.attempt_dt ) ) AND (YEAR(a2.attempt_dt) = YEAR(a.attempt_dt ) )
--
Regards
R.D
--Knowledge gets doubled when shared
"R.D" wrote:
> Adam
> try this .
> But remeber it works only when u r using(=) NOT >< etc. It still uses
> indexes.
> DAY(a2.attempt_dt) = DAY(a.attempt_dt ) AND MONTH(a2.attempt_dt) =
> MONTH(a.attempt_dt ) AND YEAR(a2.attempt_dt) AND YEAR(a.attempt_dt )
> --
> Regards
> R.D
> --Knowledge gets doubled when shared
>
> "Uri Dimant" wrote:
>|||SQL Server cannot do an index s
all. How could it? The
value need to be calculated before the value is known...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"R.D" <RD@.discussions.microsoft.com> wrote in message
news:FFAD2A23-83BC-4F0D-81FB-EB92D7CD4B1F@.microsoft.com...
> Adam
> try this .
> But remeber it works only when u r using(=) NOT >< etc. It still uses
> indexes.
> DAY(a2.attempt_dt) = DAY(a.attempt_dt ) AND MONTH(a2.attempt_dt) =
> MONTH(a.attempt_dt ) AND YEAR(a2.attempt_dt) AND YEAR(a.attempt_dt )
> --
> Regards
> R.D
> --Knowledge gets doubled when shared
>
> "Uri Dimant" wrote:
>|||Thanks Tibor, My intention was
try this .
But remeber it works only when u r using(=) NOT >< etc. It still DONT use
indexes.
DAY(a2.attempt_dt) = DAY(a.attempt_dt ) AND MONTH(a2.attempt_dt) =
MONTH(a.attempt_dt ) AND YEAR(a2.attempt_dt) AND YEAR(a.attempt_dt )
Regards
R.D
--Knowledge gets doubled when shared
"Tibor Karaszi" wrote:
> SQL Server cannot do an index s
call. How could it? The
> value need to be calculated before the value is known...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "R.D" <RD@.discussions.microsoft.com> wrote in message
> news:FFAD2A23-83BC-4F0D-81FB-EB92D7CD4B1F@.microsoft.com...
>
>|||R.D.,
I'm sorry, but I don't understand what you are saying here. Indexes can be u
sed for equal, greater
than, less than, ranges etc. If possible in the first place, of course (i.e.
, if you don't have the
column inside a function all or don't do calculations on the column side).
Perhaps I just misread you? Can you post some examples of WHERE clauses and
say in which case an
index can be used (s
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"R.D" <RD@.discussions.microsoft.com> wrote in message
news:9767E0FD-015E-402F-9D6B-0B8B7BA3847A@.microsoft.com...
> Thanks Tibor, My intention was
> try this .
> But remeber it works only when u r using(=) NOT >< etc. It still DONT use
> indexes.
> DAY(a2.attempt_dt) = DAY(a.attempt_dt ) AND MONTH(a2.attempt_dt) =
> MONTH(a.attempt_dt ) AND YEAR(a2.attempt_dt) AND YEAR(a.attempt_dt )
>
> --
> Regards
> R.D
> --Knowledge gets doubled when shared
>
> "Tibor Karaszi" wrote:
>|||Tibor.
Thank you for your post. Sorry for the confusion.
> Perhaps I just misread you? Can you post some examples of WHERE clauses an
d say in which case an
> index can be used (s
I was just telling that I missed 'DOES'NT' and Paranthesis in my first
post.In my first post I was referring to Uris where in he said that his
approach does not use indexes as columns are in functions. So I was also
explaining him that even my approach does not use indexes.
These are two sentences
First one says you can't compare dates with day/month/year function using
</> because they return integers. I mean 01/01/2005 >02/02/2004
but month(firstdate) < month(seconddate). but when we use = there is no
problem comparing because we are comaring obsolute int of two dates.
I was just telling that It was a typographi error to miss DOES NOT in my
first post.
Regards
R.D
--Knowledge gets doubled when shared
"Tibor Karaszi" wrote:
> R.D.,
> I'm sorry, but I don't understand what you are saying here. Indexes can be
used for equal, greater
> than, less than, ranges etc. If possible in the first place, of course (i.
e., if you don't have the
> column inside a function all or don't do calculations on the column side).
> Perhaps I just misread you? Can you post some examples of WHERE clauses an
d say in which case an
> index can be used (s
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "R.D" <RD@.discussions.microsoft.com> wrote in message
> news:9767E0FD-015E-402F-9D6B-0B8B7BA3847A@.microsoft.com...
>
>
Thursday, March 8, 2012
compare clustered and unclustered index space
all of tables have following design:
time_fld 8 byte,date-fld 5 byte,value float(8 byte).
in each hour 60 records add to each table.
so at end of each day 24*60*23*350 byte will be added to db size.
(23 length of record in each table)
there is a unclustered index on date-fld and time-fld on each table
(so there are 350 unclustered index in db)
after 120 days my db size is 30 GB!
but 120*24*60*23*350=1.39 GB
can be the size of all unclustered index be 28.6 GB!
we need reports on tables so index is necessary.
please help me as soon as possible.
thanks of all
Message posted via http://www.droptable.comHi
Sounds like you have very fragmented database. You can use DBCC SHOWCONTIG
to check fragmentation.You need to either run regular jobs to remove the
fragmentation. (You can use either DBCC INDEXDEFRAG and DBCC DBREINDEX to do
this, see BOL for details).
Another option, if you do not have the window to regularly rebuild or
reindex. You could change the clustered indexes to non-clustered. You can
find that tables with non-clustered indexes can perform better than highly
fragmented tables with a clustered index.
Hope this helps
John
"sepideh iranpour via droptable.com" wrote:
> there are 350 table in database.
> all of tables have following design:
> time_fld 8 byte,date-fld 5 byte,value float(8 byte).
> in each hour 60 records add to each table.
> so at end of each day 24*60*23*350 byte will be added to db size.
> (23 length of record in each table)
> there is a unclustered index on date-fld and time-fld on each table
> (so there are 350 unclustered index in db)
> after 120 days my db size is 30 GB!
> but 120*24*60*23*350=1.39 GB
> can be the size of all unclustered index be 28.6 GB!
> we need reports on tables so index is necessary.
> please help me as soon as possible.
> thanks of all
> --
> Message posted via http://www.droptable.com
>|||No. They said they are unclustered. If you clustered them, they would
store the data and you would not be hit with the additional index space
overhead as the data would be stored with and be apart of the key.
But I agree that there is some sever fragmentation and/or splitting going
on. Sounds like you have a lot of free space in the data pages.
If the row length is truely only 23, the split pages shouldn't be that bad.
Take a look at sysindexes for row lengths and potentials as well as the
current consumption of data pages.
SELECT objname = OBJECT_NAME(id), *
FROM sysindexes
WHERE indid IN(0, 1)
This will be the actual data pages of the heap (indid 0) or clustered index
(indid 1).
Sincerely,
Anthony Thomas
"John Bandettini" <JohnBandettini@.discussions.microsoft.com> wrote in
message news:4089C340-7BF1-4798-BFD8-58B1393ABD6F@.microsoft.com...
Hi
Sounds like you have very fragmented database. You can use DBCC SHOWCONTIG
to check fragmentation.You need to either run regular jobs to remove the
fragmentation. (You can use either DBCC INDEXDEFRAG and DBCC DBREINDEX to do
this, see BOL for details).
Another option, if you do not have the window to regularly rebuild or
reindex. You could change the clustered indexes to non-clustered. You can
find that tables with non-clustered indexes can perform better than highly
fragmented tables with a clustered index.
Hope this helps
John
"sepideh iranpour via droptable.com" wrote:
> there are 350 table in database.
> all of tables have following design:
> time_fld 8 byte,date-fld 5 byte,value float(8 byte).
> in each hour 60 records add to each table.
> so at end of each day 24*60*23*350 byte will be added to db size.
> (23 length of record in each table)
> there is a unclustered index on date-fld and time-fld on each table
> (so there are 350 unclustered index in db)
> after 120 days my db size is 30 GB!
> but 120*24*60*23*350=1.39 GB
> can be the size of all unclustered index be 28.6 GB!
> we need reports on tables so index is necessary.
> please help me as soon as possible.
> thanks of all
> --
> Message posted via http://www.droptable.com
>
compare clustered and unclustered index space
all of tables have following design:
time_fld 8 byte,date-fld 5 byte,value float(8 byte).
in each hour 60 records add to each table.
so at end of each day 24*60*23*350 byte will be added to db size.
(23 length of record in each table)
there is a unclustered index on date-fld and time-fld on each table
(so there are 350 unclustered index in db)
after 120 days my db size is 30 GB!
but 120*24*60*23*350=1.39 GB
can be the size of all unclustered index be 28.6 GB!
we need reports on tables so index is necessary.
please help me as soon as possible.
thanks of all
Message posted via http://www.sqlmonster.com
Hi
Sounds like you have very fragmented database. You can use DBCC SHOWCONTIG
to check fragmentation.You need to either run regular jobs to remove the
fragmentation. (You can use either DBCC INDEXDEFRAG and DBCC DBREINDEX to do
this, see BOL for details).
Another option, if you do not have the window to regularly rebuild or
reindex. You could change the clustered indexes to non-clustered. You can
find that tables with non-clustered indexes can perform better than highly
fragmented tables with a clustered index.
Hope this helps
John
"sepideh iranpour via SQLMonster.com" wrote:
> there are 350 table in database.
> all of tables have following design:
> time_fld 8 byte,date-fld 5 byte,value float(8 byte).
> in each hour 60 records add to each table.
> so at end of each day 24*60*23*350 byte will be added to db size.
> (23 length of record in each table)
> there is a unclustered index on date-fld and time-fld on each table
> (so there are 350 unclustered index in db)
> after 120 days my db size is 30 GB!
> but 120*24*60*23*350=1.39 GB
> can be the size of all unclustered index be 28.6 GB!
> we need reports on tables so index is necessary.
> please help me as soon as possible.
> thanks of all
> --
> Message posted via http://www.sqlmonster.com
>
|||No. They said they are unclustered. If you clustered them, they would
store the data and you would not be hit with the additional index space
overhead as the data would be stored with and be apart of the key.
But I agree that there is some sever fragmentation and/or splitting going
on. Sounds like you have a lot of free space in the data pages.
If the row length is truely only 23, the split pages shouldn't be that bad.
Take a look at sysindexes for row lengths and potentials as well as the
current consumption of data pages.
SELECT objname = OBJECT_NAME(id), *
FROM sysindexes
WHERE indid IN(0, 1)
This will be the actual data pages of the heap (indid 0) or clustered index
(indid 1).
Sincerely,
Anthony Thomas
"John Bandettini" <JohnBandettini@.discussions.microsoft.com> wrote in
message news:4089C340-7BF1-4798-BFD8-58B1393ABD6F@.microsoft.com...
Hi
Sounds like you have very fragmented database. You can use DBCC SHOWCONTIG
to check fragmentation.You need to either run regular jobs to remove the
fragmentation. (You can use either DBCC INDEXDEFRAG and DBCC DBREINDEX to do
this, see BOL for details).
Another option, if you do not have the window to regularly rebuild or
reindex. You could change the clustered indexes to non-clustered. You can
find that tables with non-clustered indexes can perform better than highly
fragmented tables with a clustered index.
Hope this helps
John
"sepideh iranpour via SQLMonster.com" wrote:
> there are 350 table in database.
> all of tables have following design:
> time_fld 8 byte,date-fld 5 byte,value float(8 byte).
> in each hour 60 records add to each table.
> so at end of each day 24*60*23*350 byte will be added to db size.
> (23 length of record in each table)
> there is a unclustered index on date-fld and time-fld on each table
> (so there are 350 unclustered index in db)
> after 120 days my db size is 30 GB!
> but 120*24*60*23*350=1.39 GB
> can be the size of all unclustered index be 28.6 GB!
> we need reports on tables so index is necessary.
> please help me as soon as possible.
> thanks of all
> --
> Message posted via http://www.sqlmonster.com
>
Wednesday, March 7, 2012
Compare 2 records in the same group
I have a staff Turnover report with table that has a group for
"Status". The value of this group is either Active or Terminated, so
here's a very simple description of how the table looks when
previewed:
_________________________________
TURNOVER REPORT
Active (5 associates)
Luke Skywalker
Leah Organa
Han Lolo
Chewbacca
Yoda
Terminated (2 associates)
Obi Wan Kenobi
Anakin Skywalker
_________________________________
As you can see I have a "Count" function that gets the number of
associates with each status (5 active, 2 terminated). I need a
function to divide those two values (2/5) to get the turnover percent,
but try as I may I cannot seem to get it to perform a calculation on
members of the same group. I have tried various methods to get around
this with no success. Does anyone have any suggestions?
I'd really like this to be calculated from within the report instead
of adding another dataset to return these numbers (i already have 5
datasets - most are used to populate data for the report parameters).
I appreciate your help!
MichellePut the values for count (2 and 5) in separate textboxes. For example lets
name these textboxes as tbCountActive and tbCountTerm.
Now in another textbox use following expression to display percent:
= ReportItems!tbCountTerm.Value / ReportItems!tbCountActive.Value
Cheers
AJ
"Michelle" <Michelle@.bwalk.com> wrote in message
news:92c953bf.0501251305.2a45486f@.posting.google.com...
> Hi all!
> I have a staff Turnover report with table that has a group for
> "Status". The value of this group is either Active or Terminated, so
> here's a very simple description of how the table looks when
> previewed:
> _________________________________
> TURNOVER REPORT
> Active (5 associates)
> Luke Skywalker
> Leah Organa
> Han Lolo
> Chewbacca
> Yoda
> Terminated (2 associates)
> Obi Wan Kenobi
> Anakin Skywalker
> _________________________________
> As you can see I have a "Count" function that gets the number of
> associates with each status (5 active, 2 terminated). I need a
> function to divide those two values (2/5) to get the turnover percent,
> but try as I may I cannot seem to get it to perform a calculation on
> members of the same group. I have tried various methods to get around
> this with no success. Does anyone have any suggestions?
> I'd really like this to be calculated from within the report instead
> of adding another dataset to return these numbers (i already have 5
> datasets - most are used to populate data for the report parameters).
>
> I appreciate your help!
> Michelle|||Hi AJ,
How to put them in seperate textboxes? The count is a single field in
a group - and it needs to remian in the group in order to get the
correct numbers.
Thanks!
Michelle|||Try
=Sum( iif(Fields!Status.Value = "Terminated", 1, 0), "DataSet1") / Sum(
iif(Fields!Status.Value = "Active", 1, 0), "DataSet1")
Where DataSet1 is the dataset bound to the table.
"Michelle@.bwalk.com" wrote:
> Hi AJ,
> How to put them in seperate textboxes? The count is a single field in
> a group - and it needs to remian in the group in order to get the
> correct numbers.
> Thanks!
> Michelle
>|||Hi Michelle,
Actually I assuming that you have combined the text and value in one textbox
like,
="Active (" & count(whatever) & "associates)"
Instead place the value of count in a single textbox like,
= count(whatever)
and then just for convenience sake give some meningful name to this textbox,
i.e. tbCountActive...
Then do the calculation based on the value contained in the textbox. You
can refer to a specific textbox by using ReportItems!textboxname.
I haven't seen this feature in Crystal Reports and this is something cool
with Reporting Services.
Hope this helps...
AJ
<Michelle@.bwalk.com> wrote in message
news:1106692227.587559.227350@.c13g2000cwb.googlegroups.com...
> Hi AJ,
> How to put them in seperate textboxes? The count is a single field in
> a group - and it needs to remian in the group in order to get the
> correct numbers.
> Thanks!
> Michelle
>|||This works beautifully - thank you!|||This may or may not work depending on where the output is desired due to the
scope limitations.
"AJ" wrote:
> Hi Michelle,
> Actually I assuming that you have combined the text and value in one textbox
> like,
> ="Active (" & count(whatever) & "associates)"
> Instead place the value of count in a single textbox like,
> = count(whatever)
> and then just for convenience sake give some meningful name to this textbox,
> i.e. tbCountActive...
> Then do the calculation based on the value contained in the textbox. You
> can refer to a specific textbox by using ReportItems!textboxname.
> I haven't seen this feature in Crystal Reports and this is something cool
> with Reporting Services.
> Hope this helps...
> AJ
>
> <Michelle@.bwalk.com> wrote in message
> news:1106692227.587559.227350@.c13g2000cwb.googlegroups.com...
> > Hi AJ,
> >
> > How to put them in seperate textboxes? The count is a single field in
> > a group - and it needs to remian in the group in order to get the
> > correct numbers.
> >
> > Thanks!
> > Michelle
> >
>
>