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

Thursday, March 29, 2012

Adding a script in Reporting Services

Hi.
I need to display a date with his serial week number of the year (from 1-52
weeks).
I wrote a class method that will receive this date and will return the
corresponding week number, and made a dll file out of it.
I added this dll as a reference to my report using Report->Report
Properties->Add Reference.
Now to the tricky part, how do I embed this code in my report?
I found some documented material that I need to uncomment the
<customAssembies> in the rsconfig file. I looked into my config file but no
such <customAssembies> exists.
Does anyone have an example of how to use external dll and to successfully
embed them in the report?
I will highly appreciate any word of wisdom...
Thanks,
GuyGuy,
I didn't figure out your dll question but I believe this will solve
your date problem.
=DatePart(DateInterval.WeekOfYear,Today)
or
=DatePart("ww",Today)
Hope this helps.
Here's a link to the Visual Basic Run-time Library Members
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaoriVBRuntimeLibraryKeywords.asp
Steve|||Steve, thanks a lot.
You have been very helpful.
I also realized how to create GetWeekOfYear( ) in VB.Net and to embed this
function in my report as Code.GetWeekOfYear( ).
I would to rephrase my request for assistance:
1. I created a class in C# and the class method as GetWeekOfYear( ) and
create a dll file of this class.
2. I added this reference to an existing report using the Report->Add
reference command from the Menu toolbar.
3. According to MSDN documentation I need to uncomment the
<CustomAssemblies> in the RSReportingServer.config
However, I didn't find any <CustomAssemblies> in the
RSReportingServer.config, therefore I can't refer to my dll file which
contains the GetWeekOfYear( ) method.
I will appreciate any help in adding and using dll in the Reporting Services
(which is not written in VB.Net which is the natural language in this
environment).
Thanks,
Guy
"sjeffrey@.gmail.com" wrote:
> Guy,
> I didn't figure out your dll question but I believe this will solve
> your date problem.
> =DatePart(DateInterval.WeekOfYear,Today)
> or
> =DatePart("ww",Today)
> Hope this helps.
> Here's a link to the Visual Basic Run-time Library Members
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaoriVBRuntimeLibraryKeywords.asp
> Steve
>|||Why not simply have a reference date table that contains a record for every
date and the week numbers in the record? Then you solve the problem with a
join at the data source. This reference date table has plenty of benefits
as mentioned in other recent posts.
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"GuyR" <GuyR@.discussions.microsoft.com> wrote in message
news:4B1CFD27-5D6C-44BA-A07B-D2F186EC4876@.microsoft.com...
> Hi.
> I need to display a date with his serial week number of the year (from
> 1-52
> weeks).
> I wrote a class method that will receive this date and will return the
> corresponding week number, and made a dll file out of it.
> I added this dll as a reference to my report using Report->Report
> Properties->Add Reference.
> Now to the tricky part, how do I embed this code in my report?
> I found some documented material that I need to uncomment the
> <customAssembies> in the rsconfig file. I looked into my config file but
> no
> such <customAssembies> exists.
> Does anyone have an example of how to use external dll and to successfully
> embed them in the report?
> I will highly appreciate any word of wisdom...
> Thanks,
> Guy
>sql

Tuesday, March 27, 2012

Adding A Multivalue Parameter

I've got a simple report built that retrieves data based on a serial
number assign to each record. The user has to type the serial number
into the box to run the report. Now I would like to add another
parameter in which they can run the report based on either a date/time
stamp (Start - End) and/or a multivalue parameter from another field
in each record. Do I need to create a new dataset to add these
features to the report ? I've tried adding the multivalue parameter
but either get an error or the drop down is empty.
Thank-you
JeffOn Feb 5, 4:04 pm, jsvi...@.gmail.com wrote:
> I've got a simple report built that retrieves data based on a serial
> number assign to each record. The user has to type the serial number
> into the box to run the report. Now I would like to add another
> parameter in which they can run the report based on either a date/time
> stamp (Start - End) and/or a multivalue parameter from another field
> in each record. Do I need to create a new dataset to add these
> features to the report ? I've tried adding the multivalue parameter
> but either get an error or the drop down is empty.
> Thank-you
> Jeff
If the original dataset is based on a serial number parameter/etc that
always has a value/default value, you should be ok. Of course, you
will want to have this multivalue parameter as the second parameter in
the list (behind the parameter it is dependent on). If this does not
work, then you might want to try adding an additional dataset as you
mentioned. Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant|||On Feb 5, 8:41=A0pm, EMartinez <emartinez...@.gmail.com> wrote:
> On Feb 5, 4:04 pm, jsvi...@.gmail.com wrote:
> > I've got a simple report built that retrieves data based on a serial
> > number assign to each record. The user has to type the serial number
> > into the box to run the report. Now I would like to add another
> > parameter in which they can run the report based on either a date/time
> > stamp (Start - End) and/or a multivalue parameter from another field
> > in each record. Do I need to create a new dataset to add these
> > features to the report ? I've tried adding the multivalue parameter
> > but either get an error or the drop down is empty.
> > Thank-you
> > Jeff
> If the original dataset is based on a serial number parameter/etc that
> always has a value/default value, you should be ok. Of course, you
> will want to have this multivalue parameter as the second parameter in
> the list (behind the parameter it is dependent on). If this does not
> work, then you might want to try adding an additional dataset as you
> mentioned. Hope this helps.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
I would like to be able to use each parameter independently or
together if possible. Here is the report query that I started with:
SELECT SpindleName AS Tool, Timestamp AS [Date-Time], Accept,
FinalAngle AS Angle, PartId AS CSN, CycleStatus AS Status, PeakTorque
AS Torque
FROM Readings
WHERE (PartId =3D @.PartId)
ORDER BY CSN DESC
The user types the CSN number in a gets a report showing the data for
every tool. I'd like to allow them to run the report based on
selecting one or more specific tools with or without a dependancy on
the CSN number. Is this possible ?
Thanks
Jeff

Sunday, March 25, 2012

Adding a line number to SQL Output

Guess I am going brain dead at the momnet!

I want to add a line number to a simple SQL query so the output would look something like:

1 Output of the select statement
2 Output of the select statement
3 Output of the select statement

My current statement is basically:

Select field1, field2, field3, field4
From table1
where field1 = somevalue

Like I typed, very simple. I am just not finding how I should add a line number to the output.

Any help would be appreciated!Originally posted by jhimes

Select field1, field2, field3, field4
From table1
where field1 = somevalue


Try adding rownum to your select statement.

[code]

Select field1, field2, field3, field4, rownum as count
From table1
where field1 = somevalue

Oh - yea an update to this - I assume you are on Oracle - if its another database, that probably wont work.|||Thank you, that is just what I needed!|||And yes I am on Oracle & just learning real SQL (from Microsoft Access SQL).|||Originally posted by jhimes
And yes I am on Oracle & just learning real SQL (from Microsoft Access SQL).

You're welcome - Oracle is the place to be! Good luck and check back with questions because I am still always learning something new myself.

Tuesday, March 20, 2012

Added /3GB to boot.ini and OS will not start

Here is a new one for me. I added the /3GB switch to the boot.ini, restarted the server and now receive a number of messages when the OS tries to load.

Explorer.exe - Application Error

The application failed to initialize properly.

If I click OK the server sits on a blue screen with no information on the screen.

The other messages are the result of me trying to do anything within Task Manager, with the exception of rebooting the server. These messages make sense since Explorer.exe had a problem.

The server has the following configuration.

HP DL580

Windows Server 2003 Enterprise Edition - SP2

SQL Server 2000 Enterprise Edition - SP3a

14GB Memory

(4) dual core procs

PAE is enabled in the boot.ini

If I remove the /3GB the OS starts without a problem. Any suggestions?

Thanks, Dave

Hey Dave,

I don't recommend adding the 3GB switch for this server. You're running 14GB of memory, with PAE enabled.

This means Windows has got to use a lot more phsyical memory to house the PAE memory mappings, and when you set 3GB you're dropping the amount of memory Windows can use from 2GB down to 1GB, and from the sound of it it's just not enough for Windows.

Microsoft actually say not use 3GB with PAE in a server which has 16GB or greater RAM. But I've found anything more than 12 - 14GB and it's best not to use 3GB.

Hope that helps.

Cheers, Reece.

AddcurrentRange ?

Report.ParameterFields(4).AddCurrentRange "000", "999", 3
In this line of code, what does number 3 stands for ? 000 is start and 999 is end range I presume, but number 3 is a mistery 2 me.According to info I found :

"Use this bitwise value to indicate whether the upper and/or lower bound of the range should be included".

I'm not sure which value indicates what, though.

Hope this helps.|||http://support.businessobjects.com/library/kbase/articles/c2007345.asp :

'crRangeNotIncludeUpperLowerBound 0
'crRangeIncludeLowerBound 2
'crRangeIncludeUpperBound 1
'crRangeNoLowerBound 8
'crRangeNoUpperBound 4

I would guess the value 3 probably means include both upper and lower?

Add YTD for number of cubes?

Hello,

We have number of cubes sharing one Time dimension; we need add YTD, QTD, and MTD to each cube, is there a easy way to add YTD, QTD to Time dimension one time instead of add them to the cube one by one?

Thanks in advance for the advice.


Yes - you can add the member holders for YTD, MTD, QTD etc to the corresponding attribute of the Time dimension, and add all the MDX formulas to the dedicated column in the dimension table, and the use CustomFormulaColumn property on the attribute to point to that column. After that, every cube which includes this dimension will have all these formulas automatically.|||Thank you very much Mosha for the help.

1. add YTD column to the Time dimension
2, add all the MDX formulas to the YTD column
(
[All Periods].[YTD].[Year to Date],
[All Periods].[Year].[Year].Members,
[All Periods].[PK Date].Members
) =

Aggregate(
{ [All Periods].[YTD].DefaultMember } *
PeriodsToDate(
[All Periods].[Year - Quarter - Month].[Year],
[All Periods].[Year - Quarter - Month].CurrentMember
)
);

You mean all these code add into column?
3, use CustomFormulaColumn property on the attribute.
where can I find 'CustomFormulaColumn' property?
I checked BI Studio, and could not find that.

Thanks.
|||

You can only put the MDX expression, not the MDX statement into this column Sad So in your case it would be the right hand side of the assignment.

The real name of the attribute's property is CustomRollupColumn.

|||I put MDX expression in YTD column, and point CustomRollupColumn property to All_Periods.YTD. After processing, YTD just show the text which are the 'MDX expression' I put in and measure.order became '#VALUE'.

What else I am missing?

Thanks.
|||I did Google search for CustomRollupColumn Property, some people said that it's work in SSAS 2000, but not in SSAS 2005. Is it true?

|||CustomRollupColumn property works fine in SSAS 2005. Probably it is the best for you to look at example to understand how it should be set up. In the Adventure Works sample, take a look at Accounts dimension, Accounts attribute - it has custom rollups defined.

Add YTD for number of cubes?

Hello,

We have number of cubes sharing one Time dimension; we need add YTD, QTD, and MTD to each cube, is there a easy way to add YTD, QTD to Time dimension one time instead of add them to the cube one by one?

Thanks in advance for the advice.


Yes - you can add the member holders for YTD, MTD, QTD etc to the corresponding attribute of the Time dimension, and add all the MDX formulas to the dedicated column in the dimension table, and the use CustomFormulaColumn property on the attribute to point to that column. After that, every cube which includes this dimension will have all these formulas automatically.|||Thank you very much Mosha for the help.

1. add YTD column to the Time dimension
2, add all the MDX formulas to the YTD column
(
[All Periods].[YTD].[Year to Date],
[All Periods].[Year].[Year].Members,
[All Periods].[PK Date].Members
) =

Aggregate(
{ [All Periods].[YTD].DefaultMember } *
PeriodsToDate(
[All Periods].[Year - Quarter - Month].[Year],
[All Periods].[Year - Quarter - Month].CurrentMember
)
);

You mean all these code add into column?
3, use CustomFormulaColumn property on the attribute.
where can I find 'CustomFormulaColumn' property?
I checked BI Studio, and could not find that.

Thanks.
|||

You can only put the MDX expression, not the MDX statement into this column Sad So in your case it would be the right hand side of the assignment.

The real name of the attribute's property is CustomRollupColumn.

|||I put MDX expression in YTD column, and point CustomRollupColumn property to All_Periods.YTD. After processing, YTD just show the text which are the 'MDX expression' I put in and measure.order became '#VALUE'.

What else I am missing?

Thanks.
|||I did Google search for CustomRollupColumn Property, some people said that it's work in SSAS 2000, but not in SSAS 2005. Is it true?

|||CustomRollupColumn property works fine in SSAS 2005. Probably it is the best for you to look at example to understand how it should be set up. In the Adventure Works sample, take a look at Accounts dimension, Accounts attribute - it has custom rollups defined.sql

Monday, March 19, 2012

Add values of distinct rows

Hello All,

I have a scenario wherein I wanted to add the values of distinct transaction number, how do I do that. i.e.

Financial organisation (GROUP (Company))

12/31/2003 606.60 approved 123 (Transaction Number) (1st Row)

5643577(Wok Report) (2nd Row)

01/05/2004 1000.00 approved 124 (Transaction Number) (to Satisfy $1000 three work reports were raised)

5643500(Wok Report)

5643501(Wok Report)

5643502(Wok Report)

02/05/2004 2000.00 approved 125 (Transaction Number) (to Satisfy $2000 three work reports were raised)

5643300(Wok Report)

5643301(Wok Report)

5643302(Wok Report)

Total 3606.60 (Total per Company group)

I want to add the visible row values only. Because the 1000.00 and 2000.00 was repeating for 01/05/2004 and 02/05/04 I am hinding the repeated values.

Please help me completing the above task.

Thanks,

Deepak Vodethela

Deekpak,

Unfortunatley, from my experiences, this is not possible as of SSRS 2005. I tried to do the same thing recently and I ended up changing my SQL to give me what I wanted.

|||

Thanks for the reply Todd. Can't we write a custom function to do the needful i.e. which has to check for the distict Transaction number and pick up the value and do the sum by group. I am not an expert at SSRS but just curious.

To change my query it will be a very big task. Right now I am joining 11 tables to get the required fields and if I want to add the sum on a group then it'll be a laborious task.

Any help would be appriciated.

Add two digits to the front?

Hi all,
I have a number like so 778625 and want to make
this a more meaningful date (UK) so how difficult is it to
add two digits in this case 19 to the front of this number?
Many thanks
SamThis is a date? I'm not sure I understand how 1977 is any more meaningful
than 77, when the rest of the number is 8625. But okay, I suppose you could
do this:
DECLARE @.i INT
SET @.i = 778625
SELECT '19'+CAST(@.i AS VARCHAR)
And if you have to do it conditionally, say if the first two digits are less
than 30 you assume it's 20xx, then
DECLARE @.i INT, @.ivc VARCHAR(12)
SELECT @.i = 778625, @.ivc = CAST(@.i AS VARCHAR(32))
SELECT CASE WHEN CONVERT(TINYINT, LEFT(@.ivc, 2))>=30 THEN '19' ELSE '20' END
+ @.ivc
"Sam" <sgpgpjr@.yahoo.ie> wrote in message
news:082a01c3462b$f1924960$a001280a@.phx.gbl...
> Hi all,
> I have a number like so 778625 and want to make
> this a more meaningful date (UK) so how difficult is it to
> add two digits in this case 19 to the front of this number?
> Many thanks
> Sam
>

add to data

Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
SteveHi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.

add to data

Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
Steve
Hi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.

add to data

Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
SteveHi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.

Sunday, March 11, 2012

Add static and dynamic columns to a matrix

I

have received a request for a report that has a variable number of

columns that can be generated with a matrix, and then two columns that

are fixed, i.e. one per group. Here is what I mean:

Sect 1 Sect 2 Sect 3 Score Time
-- -
Person 1 X X 50% 8 Days
Person 2 X 12% 3 Days

Another

page-level group could have 2 Sections or 8 Sections. There should only

be one Score and Elapsed Time column. How can I add these fixed columns

to a matrix?

Thanks for any help.
Having dynamic and static columns side-by-side is not currently supported in a matrix. We are working on adding this for a future release. For now, as a workaround, you can add a table that contains two columns (for score and time) to the right side of the matrix, and add a table group on person so that the matrix and the table are grouped the same way on the row.

Add sequence number to data

Hi all, I need some your help.

I want to add sequence number to data flow below:

Cust_Name | Month
=======================
Chonnathan | 5
Chonnathan | 4
Chonnathan | 7
Derec | 3
Derec | 9

and the result i need is:

SEQ_nbr | Cust_Name | Month
================================
1 | Chonnathan | 4
2 | Chonnathan | 5
3 | Chonnathan | 7
1 | Derec | 3
2 | Derec | 9

How can I do it in Integration Service to show like the above?

Thank you for your respones,
Chonnathan

The following are links to show how to generate a row number (i.e. similar to identity but user controlled). You would have to find logic that you are comftorable with to use these in driving the sequence number instead.

http://www.sqljunkies.com/WebLog/sqlbi/archive/2005/05/30/15684.aspx
http://www.ssistalk.com/2007/02/20/generating-surrogate-keys/

You could, of course, just use a store procedure / max(SEQ_nbr) where cust_name = ?, although this would be MUCH slower...

Tuesday, March 6, 2012

Add n numbers of days to a date

Hi,

I have a textbox with date selected from calendar... Now i put in another textbox to enters number of day(30 or 120 or other), this number may vary...

so my qns is how to add the n numbers of days entered to the date selected? i stored date as smalldatetime

Help is appreciated

There is a function DATEADD you can use:

DATEADD(dd, yourFirstDate, 30)-- add 30 days to your first date.

you can use this in your insert or update statement. Let me know if you need more help.

|||

U r having the function Dateadd. U use the function

DATEADD(datepart,number,date)

DatepartAbbreviationsYearyy, yyyyquarterqq, qMonthmm, mdayofyeardy, yDaydd, dWeekwk, wwHourhhminutemi, nsecondss, smillisecondms

Thanks

Baba

Please remember to click "Mark as Answer" on this post if it helped you.

|||

Hi all,

Thank for replying.. Oh y under this section... Anyway i dun quite understand how to implement it in my codes...

Cos my Textbox for user to enter number of days to due date may vary... Like as i say in abv example

Step1: User select the firstdate from a calendar and display in TextBox1.Text (12/11/2007)

Step2: User enter the number of days to due date in TextBox2.Text (example, 30) <-- can be any number...no specific

Step3: On click a button it display the 12/12/2007 in a label maybe...

Step4: this label date is save to sql for future use...

So i need know how to implement it... as most example i googled has a specific days declare... As for step4 is easy so i only need to know step2 and 3

Any details example of how to do it?

Ur help is appreciated

Edit: I have try this codes... it works but how can i not specific the number of days... i wan the user to specific any number of days they want in TextBox2

Dim nowAsNew DateTime

now = tb_dop.Text

Dim lAsNew DateTime

l = now.AddDays(30)

TextBox1.Text = l

|||

OK

Thanks for the helps... I have figure it out as followed

Dim nowAsNew DateTime

now = tb_dop.Text

Dim iAsInteger

i = TextBox1.Text

Dim lAsNew DateTime

l = now.AddDays(i)

TextBox1.Text = l

Saturday, February 25, 2012

Add in auto number in the query result

How can I add in the auto-increment field in my query result?
E.g
Select * from tmp1
The result from this transact sql is
VendorName VendorPhone
Ven1 123456
Ven2 789654
How can I modified my query to return result as below:( auto number in front
)
VendorID VendorName VendorPhone
1 Ven1 123456
2 Ven2 789654
Thanks lot if anyone can provide me the solutions cos I am using temporary
table in VBA. I am wondering whether I can do it in sql itself or not.
ThanksOne way is to declare a Table Variable to hold the PKs of the rows that will
be in the Final Output.. but when you declar ethe table, also include a
Identity column...
Declare @.OutPKs Table
(RowID Integer Identity Primary Key Not Null,
PkID Integer Not Null)
Then insert all the PKS into this table based on the exact same where clause
and Order By that you would use in your previous query...
Insert @.OutPKs (PkID)
Select PKID
From <Real Data Tables>
Where <Filter conditions>
Order By <Sort Conditions>
Then, finally, output the data you actually want by joining the real data
tables to this @.OutPks Table, and include the RowID in the output...
Select RowID, PkID, <Other Columns>
From @.OutPks P Join <Other Tables>
Order By RowID
"Sql Fren" wrote:

> How can I add in the auto-increment field in my query result?
> E.g
> Select * from tmp1
> The result from this transact sql is
> VendorName VendorPhone
> Ven1 123456
> Ven2 789654
> How can I modified my query to return result as below:( auto number in fro
nt)
> VendorID VendorName VendorPhone
> 1 Ven1 123456
> 2 Ven2 789654
>
> Thanks lot if anyone can provide me the solutions cos I am using temporary
> table in VBA. I am wondering whether I can do it in sql itself or not.
> Thanks
>|||Another way is to include an additional column which is the output of a
correlated subquery, which counts the number of records in the same set whic
h
have a columnvalue less than or equal to the columnvalue in the row the
subquery is running on... The columnvalue must be the column the output is
sorting on, and the columnvalues must be unique..
Say the column you're using is OrderDate...
Select (Select Count(*) From Table
Where OrderDate <= O.OrderDate) as RowNum,
<Other Columns>
From Table O
Order By OrderDate
If the outer query has a where clause, filtering the rows which will be
produced, the subquery must include the same where clause, or the count will
be wrong...
"Sql Fren" wrote:

> How can I add in the auto-increment field in my query result?
> E.g
> Select * from tmp1
> The result from this transact sql is
> VendorName VendorPhone
> Ven1 123456
> Ven2 789654
> How can I modified my query to return result as below:( auto number in fro
nt)
> VendorID VendorName VendorPhone
> 1 Ven1 123456
> 2 Ven2 789654
>
> Thanks lot if anyone can provide me the solutions cos I am using temporary
> table in VBA. I am wondering whether I can do it in sql itself or not.
> Thanks
>|||Much better to add this fake "rank" number in VBA since, presumably, you are
going to be looping through each row anyway, and VBA is pretty good at
simple math (rowNum = rowNum + 1). It is not very efficient at all to do
this at the database level, but of course, there are kludges.
http://www.aspfaq.com/2427
On 3/16/05 8:39 PM, in article
39D05AEC-CB60-40A3-A140-583EBDC58EA9@.microsoft.com, "Sql Fren"
<SqlFren@.discussions.microsoft.com> wrote:

> How can I add in the auto-increment field in my query result?
> E.g
> Select * from tmp1
> The result from this transact sql is
> VendorName VendorPhone
> Ven1 123456
> Ven2 789654
> How can I modified my query to return result as below:( auto number in fro
nt)
> VendorID VendorName VendorPhone
> 1 Ven1 123456
> 2 Ven2 789654
>
> Thanks lot if anyone can provide me the solutions cos I am using temporary
> table in VBA. I am wondering whether I can do it in sql itself or not.
> Thanks
>

Friday, February 24, 2012

add digits to the front

Hi all,
I have a number like so 778625 and want to make this a more meaningful
date (UK) so how difficult is it to add two digits in this case 19 to
the front of this number?

Many thanks
Sam

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!actually i don't need it to be a date i just need to add 19 to the front
of the number.
Thanks again
Sam

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||You can do:

SELECT CAST(CAST(19 AS VARCHAR) + CAST(778625 AS VARCHAR) AS INT)

Another option is to do:

SELECT 19 * POWER(10, LEN(778625)) + 778625

--
- Anith
( Please reply to newsgroups only )|||Not really sure what you mean but something like

select convert(int,'19'+convert(varchar(10),fld))

--
Posted via http://dbforums.com

Add column with fixed number of values (text) to the select statement

Hello,

I have such a problem. Need to add additional column to my query. The column should consist of set of fixed number (same as number of query rows) values (text). At start thought it's simple but now Im lost. Is there any chance to do it. Apreciate any help. I need to tell that I have only access to select on this database so no use of operation on tables.

I found on the net something to start with

Adding Columns in SQL SELECT statements by Andy Kramek http://weblogs.foxite.com/andykramek/archive/2005/09/18/921.aspx

SELECT *, CAST( 0 AS INT) AS newint FROM sample

but it just add a column with value 0 to the set of results.

|||

What is the version you are using... (2000/2005) Give some sample data & required output..

|||

I'm using ver. 2005. The select is very simple concerns the tables with historical rates for curves.

So there are four columns:

1) Date

2) Name of the curve

3) DF

4) Implied rate

there are 17 rows of data

and I need to add column with fixed tenors

O/N

T/N

S/N

1W

2W

1M

2M

3M

4M

5M

6M

7M

8M

9M

10M

11M

1Y

|||

Ok.. do you want the result as bellow,

1) Date

2) Name of the curve

3) DF

4) Implied rate

5)O/N

6)T/N

7)S/N

8)1W

9)2W

10)1M

..

..

17)IY

if yes what data you want to display on this 17 columns

|||

Your questions not clear properly. But I think this will help you,

USE PUBS
Go

SELECT COUNT(*) row_num, A.au_lname
FROM authors A, authors B
WHERE A.au_lname > B.au_lname
GROUP BY A.au_lname
ORDER BY COUNT(*)

|||

I want results to look like this:

Tenor / Date / Name of the curve/ DF / Implied rate

O/N 1/08/07 EUR_CURVE 0.9999987 4.020000

T/N 1/08/07 EUR_CURVE . .

S/N 1/08/07 EUR_CURVE . .

1W 1/08/07 EUR_CURVE . .

2W 1/08/07 EUR_CURVE . .

1M 1/08/07 EUR_CURVE . .

.

.

.

1Y 1/08/07 EUR_CURVE . .

tks

Sunday, February 19, 2012

Add blank rows to table

Hello,
I need to create a report with a fixed number of table rows. For example:
the table is fixed at 20 rows per page regardless of data retrieved. If say
10 rows are filled with data then the rest are blanks. If 25 rows of data is
retrieved then the first page is filled and next page has 5 rows filled with
the rest blank. I also need a running row number in the first column. I've
managed that with "RowNumber(Nothing)" but I am not sure if it will work with
blank rows too. Is there any way to accomplish this? Through report
designer or custom code?
Thanks,
RodneyI would add rows to the source dataset. If the data is coming from a stored
procedure, append a dummy column to the end of the dataset and put a 1 in it
if the row contained data and a 2 if it did not (this way you have something
to sort on so that the blank rows are at the end of the report. Use a
count() in the stored procedure to determine how many rows to append to the
end of the dataset.
"Rodney" wrote:
> Hello,
> I need to create a report with a fixed number of table rows. For example:
> the table is fixed at 20 rows per page regardless of data retrieved. If say
> 10 rows are filled with data then the rest are blanks. If 25 rows of data is
> retrieved then the first page is filled and next page has 5 rows filled with
> the rest blank. I also need a running row number in the first column. I've
> managed that with "RowNumber(Nothing)" but I am not sure if it will work with
> blank rows too. Is there any way to accomplish this? Through report
> designer or custom code?
> Thanks,
> Rodney|||How would I append blank rows to a select query? Are you suggesting a
temporary table where the data and blank rows are dumped into? Would this be
a problem in a multiuser app?
"Kebler" wrote:
> I would add rows to the source dataset. If the data is coming from a stored
> procedure, append a dummy column to the end of the dataset and put a 1 in it
> if the row contained data and a 2 if it did not (this way you have something
> to sort on so that the blank rows are at the end of the report. Use a
> count() in the stored procedure to determine how many rows to append to the
> end of the dataset.
> "Rodney" wrote:
> > Hello,
> >
> > I need to create a report with a fixed number of table rows. For example:
> > the table is fixed at 20 rows per page regardless of data retrieved. If say
> > 10 rows are filled with data then the rest are blanks. If 25 rows of data is
> > retrieved then the first page is filled and next page has 5 rows filled with
> > the rest blank. I also need a running row number in the first column. I've
> > managed that with "RowNumber(Nothing)" but I am not sure if it will work with
> > blank rows too. Is there any way to accomplish this? Through report
> > designer or custom code?
> >
> > Thanks,
> >
> > Rodney

Add auto number field to view

I have a simple view something like "SELECT * from <table_name> order
by field1,field2,field3
I have a program that needs to read these values in by the order I have
ordered them in the database however it needs an incremental numeric
value to do so. Is there any way to add to the view, a field that after
the order by is done, that places a numeric incremental value in
another virtual or real column?
Thanks.
JRhttp://www.aspfaq.com/2427
"JR" <jriker1@.yahoo.com> wrote in message
news:1149872089.709215.141860@.i39g2000cwa.googlegroups.com...
>I have a simple view something like "SELECT * from <table_name> order
> by field1,field2,field3
> I have a program that needs to read these values in by the order I have
> ordered them in the database however it needs an incremental numeric
> value to do so. Is there any way to add to the view, a field that after
> the order by is done, that places a numeric incremental value in
> another virtual or real column?
> Thanks.
> JR
>|||JR wrote:
> I have a simple view something like "SELECT * from <table_name> order
> by field1,field2,field3
> I have a program that needs to read these values in by the order I have
> ordered them in the database however it needs an incremental numeric
> value to do so. Is there any way to add to the view, a field that after
> the order by is done, that places a numeric incremental value in
> another virtual or real column?
> Thanks.
> JR
on 2005, use row_number()|||Using SQL Server 2000.
Alexander Kuznetsov wrote:
> JR wrote:
> on 2005, use row_number()|||I was looking at the rank option however with that it seems to want you
to define each and every column in your view in the group by clause.
Aaron Bertrand [SQL Server MVP] wrote:
> http://www.aspfaq.com/2427
>
>
> "JR" <jriker1@.yahoo.com> wrote in message
> news:1149872089.709215.141860@.i39g2000cwa.googlegroups.com...|||>I was looking at the rank option however with that it seems to want you
> to define each and every column in your view in the group by clause.
Which you should be doing anyway; don't be lazy, it doesn't pay off in the
long run!
http://www.aspfaq.com/2096|||OK, I'll give it a try however I have over 50 columns so kind of a
pain.
Aaron Bertrand [SQL Server MVP] wrote:
> Which you should be doing anyway; don't be lazy, it doesn't pay off in the
> long run!
> http://www.aspfaq.com/2096|||> OK, I'll give it a try however I have over 50 columns so kind of a
> pain.
CREATE VIEW tmp_vw_foo
AS
SELECT * FROM SomeTable
GO
SELECT COLUMN_NAME+',' FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tmp_vw_foo'
ORDER BY ORDINAL_POSITION
The most work you're going to do, aside from copy and paste, is deleting the
last comma.
Yep, that's a real pain. :-)|||Sweet. Thanks for that Aaron.
Aaron Bertrand [SQL Server MVP] wrote:
> CREATE VIEW tmp_vw_foo
> AS
> SELECT * FROM SomeTable
> GO
> SELECT COLUMN_NAME+',' FROM INFORMATION_SCHEMA.COLUMNS
> WHERE TABLE_NAME = 'tmp_vw_foo'
> ORDER BY ORDINAL_POSITION
> The most work you're going to do, aside from copy and paste, is deleting t
he
> last comma.
> Yep, that's a real pain. :-)