Showing posts with label system. Show all posts
Showing posts with label system. Show all posts

Tuesday, March 27, 2012

External_access/unsafe - system call

Hi,
i need to make a system call from within the sqlserver (run an .exe file).
i do not want to define the db as trustworthy.
i've created a strong name key and related it to the code. i then created
asymetric key, granted access to the login and created the assembly but
failed.
what am i doing worng?Hello ????,
Here's folow I've solved this in the past:
http://www.sqljunkies.com/WebLog/kt...op.com/ktegels/|||Hi,
Tried it and it didn't help (p.s - we exchanged some mails last week )
"Kent Tegels" wrote:

> Hello ????,
> Here's folow I've solved this in the past:
> http://www.sqljunkies.com/WebLog/kt...op.com/ktegels/
>
>|||Hello ????,
Right, I'm retrying it on my machine today and so far it is.
Have you tried the process as described in the the July 2006 BOL update. See
:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/denet9/html/a2bc503d-b6b2-4963-8beb-c1
1c323f18e0.htm
Thanks,
Kent Tegels, DevelopMentor
http://staff.develop.com/ktegels/|||couldn't reach the url can you send a valid one?
Galit.
"Kent Tegels" wrote:

> Hello ????,
> Right, I'm retrying it on my machine today and so far it is.
> Have you tried the process as described in the the July 2006 BOL update. S
ee:
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/denet9/html/a2bc503d-b6b2-4963-8beb-
c11c323f18e0.htm
> Thanks,
> Kent Tegels, DevelopMentor
> http://staff.develop.com/ktegels/
>
>|||Hi Kent,
managed to do it - thanks (not according to your note).
Thanks,
Galit.
"????" wrote:
[vbcol=seagreen]
> couldn't reach the url can you send a valid one?
> Galit.
> "Kent Tegels" wrote:
>sql

Wednesday, March 21, 2012

extended stored procedures: is there a 256 character limit on

Bert,
For some system extended stored procedures, the parameters
are defined as varchar(256). For those, there is no way around
unless you rewrite the xp (not a good idea I think). For xp's you
write yourself, I'm not aware of any limit. Are you having a
particular problem you need help with?
Steve Kass
Drew University
Bert Szoghy wrote:

>Hello,
>On SQL Server 2000 (SP3), for extended stored procedures: is there a
>256 character limit on INPUT parameters?
>And if so, is there a way around that?
>Thanks,
>Bert
>Bert,
The thread you posted indicates there is a 256-character limit
for DBLib, not the SQL Server xp architecture. According to John
Kane in that thread:
Anil,
ESP or (Extended Stored Procs) can use the OLE-DB API and if you are using
the DBLib API you are cutting your own code's future as it is most likely
(un-confirmed) that Microsoft will drop, i.e.. remove the DB-Library API
from future SQL Server versions, such as SQL Server 2005 (Yukon).
See SQL Server 2000 BOL titles "Running Stored Procedures (OLE DB)",
"Extended Stored Procedure Architecture", "Programming Extended Stored
Procedures" and "Samples" and specifically the sample app xp-ODBC for more
info.
This is not a SQL Server limitation, but a limitation of the old DBLib
interface
only. Rewriting the xp to use a more modern interface, as John suggested,
is probably what you need to do.
SK
Bert Szoghy wrote:

>Steve Kass <skass@.drew.edu> wrote in message news:<OJxPTgSSFHA.3716@.TK2MSFT
NGP14.phx.gbl>...
>
>Hello,
>Thank you for your responses.
>I have an extended stored proc DLL with C++ code which just looks fine
>to me, which it refuses to give me more than 256 characters.
>I found the following reference before posting here which made me
>suspect it was a SQL Server limitation:
>http://groups.google.ca/groups?hl=e...K2MSFTNGP15.phx
.gbl%26rnum%3D1
>I am using a varchar(8000) in the trigger calling the extended stored
>proc.
>I'm about to try stepping through the DLL but the code is a bit nasty
>and it would be nice if a SQL Server guru would point out a detail to
>tweak.
>Thanks guys!
>Thanks again,
>Bert
>

Monday, March 12, 2012

Extend MSDE to Enterprise

I have a system that came with the MSDE database, because of the 2G limit I
am trying to point it to the enterprise version of SQL 2000. All connection
strings have been changed to the enterprise (With vendor help). The connec
tion is established and acc
ording to a trace from Profiler, all queries are running and inserting the d
ata in the right table. But there is no data in the tables! No errors eith
er.
One of my tests was to point it to another MSDE and it worked fine. What is
different between these two versions that will cause data not to be written
to the tables.
ThanksHi,
Can you insert few records in to the tables manually and see what is
happening. I feel that application is
still pointing towards a different database.
Thanks
Hari
MCDBA
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:4937BB3E-CD2B-4DA1-9C83-2C03E8470989@.microsoft.com...
> I have a system that came with the MSDE database, because of the 2G limit
I am trying to point it to the enterprise version of SQL 2000. All
connection strings have been changed to the enterprise (With vendor help).
The connection is established and according to a trace from Profiler, all
queries are running and inserting the data in the right table. But there is
no data in the tables! No errors either.
> One of my tests was to point it to another MSDE and it worked fine. What
is different between these two versions that will cause data not to be
written to the tables.
> Thanks|||It is pointing to the right DB because at first I pointed it to a DB that ha
d records and from the front end the viewer showed the Data (but did not ins
ert any) then, I pointed it to an empty DB and the viewer showed empty rows
and still wouldn't insert a
ny records. Are there any differences between MSDE and SQL to cause such th
ing?
Thanks
"Hari Prasad" wrote:

> Hi,
> Can you insert few records in to the tables manually and see what is
> happening. I feel that application is
> still pointing towards a different database.
>
> Thanks
> Hari
> MCDBA
> "Niles" <Niles@.discussions.microsoft.com> wrote in message
> news:4937BB3E-CD2B-4DA1-9C83-2C03E8470989@.microsoft.com...
> I am trying to point it to the enterprise version of SQL 2000. All
> connection strings have been changed to the enterprise (With vendor help).
> The connection is established and according to a trace from Profiler, all
> queries are running and inserting the data in the right table. But there
is
> no data in the tables! No errors either.
> is different between these two versions that will cause data not to be
> written to the tables.
>
>

Extend MSDE to Enterprise

I have a system that came with the MSDE database, because of the 2G limit I am trying to point it to the enterprise version of SQL 2000. All connection strings have been changed to the enterprise (With vendor help). The connection is established and acc
ording to a trace from Profiler, all queries are running and inserting the data in the right table. But there is no data in the tables! No errors either.
One of my tests was to point it to another MSDE and it worked fine. What is different between these two versions that will cause data not to be written to the tables.
Thanks
Hi,
Can you insert few records in to the tables manually and see what is
happening. I feel that application is
still pointing towards a different database.
Thanks
Hari
MCDBA
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:4937BB3E-CD2B-4DA1-9C83-2C03E8470989@.microsoft.com...
> I have a system that came with the MSDE database, because of the 2G limit
I am trying to point it to the enterprise version of SQL 2000. All
connection strings have been changed to the enterprise (With vendor help).
The connection is established and according to a trace from Profiler, all
queries are running and inserting the data in the right table. But there is
no data in the tables! No errors either.
> One of my tests was to point it to another MSDE and it worked fine. What
is different between these two versions that will cause data not to be
written to the tables.
> Thanks
|||It is pointing to the right DB because at first I pointed it to a DB that had records and from the front end the viewer showed the Data (but did not insert any) then, I pointed it to an empty DB and the viewer showed empty rows and still wouldn't insert a
ny records. Are there any differences between MSDE and SQL to cause such thing?
Thanks
"Hari Prasad" wrote:

> Hi,
> Can you insert few records in to the tables manually and see what is
> happening. I feel that application is
> still pointing towards a different database.
>
> Thanks
> Hari
> MCDBA
> "Niles" <Niles@.discussions.microsoft.com> wrote in message
> news:4937BB3E-CD2B-4DA1-9C83-2C03E8470989@.microsoft.com...
> I am trying to point it to the enterprise version of SQL 2000. All
> connection strings have been changed to the enterprise (With vendor help).
> The connection is established and according to a trace from Profiler, all
> queries are running and inserting the data in the right table. But there is
> no data in the tables! No errors either.
> is different between these two versions that will cause data not to be
> written to the tables.
>
>

Extend MSDE to Enterprise

I have a system that came with the MSDE database, because of the 2G limit I am trying to point it to the enterprise version of SQL 2000. All connection strings have been changed to the enterprise (With vendor help). The connection is established and according to a trace from Profiler, all queries are running and inserting the data in the right table. But there is no data in the tables! No errors either.
One of my tests was to point it to another MSDE and it worked fine. What is different between these two versions that will cause data not to be written to the tables.
ThanksHi,
Can you insert few records in to the tables manually and see what is
happening. I feel that application is
still pointing towards a different database.
Thanks
Hari
MCDBA
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:4937BB3E-CD2B-4DA1-9C83-2C03E8470989@.microsoft.com...
> I have a system that came with the MSDE database, because of the 2G limit
I am trying to point it to the enterprise version of SQL 2000. All
connection strings have been changed to the enterprise (With vendor help).
The connection is established and according to a trace from Profiler, all
queries are running and inserting the data in the right table. But there is
no data in the tables! No errors either.
> One of my tests was to point it to another MSDE and it worked fine. What
is different between these two versions that will cause data not to be
written to the tables.
> Thanks

Wednesday, March 7, 2012

Expression for calculating the different between two dates

i am currently doing a system where user can submit their suggestions to us
and part of my system is using Reporting Services and i need some guide on my
problem.
When user submit their suggestions, the date of submission will be auto
input into SQL Server database and if the suggestions is being evaluated by a
evaluator, the date of evaluation will also be input into the SQL Server
database and all this part i had done it all in aspx.
So now when user want to view their suggestions, they will go to a page
which i had generate using Reporting Services. In this page, there is a
column call Turnaround Time(the datediff from the day of submission to now
till the suggestions is being evaluated). That means In this column i wan to
display the datediff from the date of submission till the date today if it
still had not been evaluated(that means the SQL Server database that contains
the field "Date of Evaluation" is still null). And if the suggestions had
been evaluated(that means the SQL Server database that contains the field
"Date of Evaluation" contains a date value now), it will display the datediff
from the date of submission to the date of evaluation.
For now i can only display the datediff from the date of submission to now
using the following expression : =DateDiff(DateInterval.Day,
Fields!DateSubmitted.Value, Now()) and thus i need help on how to display the
datediff from the date of submission to now if the suggestions had not been
evaluated and display the datediff from the date of submission to the date of
evaluation if the suggestions had been evaluated.
I appreciate for the help and guide. ThanksYou can try this :
IIF(Fields!EvaluationDate.Value Is Nothing , Now()-Fields!
SubmissionDate.Value,Fields!EvaluationDate.Value-Fields!
SubmissionDate.Value)
>--Original Message--
>i am currently doing a system where user can submit their
suggestions to us
>and part of my system is using Reporting Services and i
need some guide on my
>problem.
>When user submit their suggestions, the date of
submission will be auto
>input into SQL Server database and if the suggestions is
being evaluated by a
>evaluator, the date of evaluation will also be input into
the SQL Server
>database and all this part i had done it all in aspx.
>So now when user want to view their suggestions, they
will go to a page
>which i had generate using Reporting Services. In this
page, there is a
>column call Turnaround Time(the datediff from the day of
submission to now
>till the suggestions is being evaluated). That means In
this column i wan to
>display the datediff from the date of submission till the
date today if it
>still had not been evaluated(that means the SQL Server
database that contains
>the field "Date of Evaluation" is still null). And if the
suggestions had
>been evaluated(that means the SQL Server database that
contains the field
>"Date of Evaluation" contains a date value now), it will
display the datediff
>from the date of submission to the date of evaluation.
>For now i can only display the datediff from the date of
submission to now
>using the following expression : =DateDiff
(DateInterval.Day,
>Fields!DateSubmitted.Value, Now()) and thus i need help
on how to display the
>datediff from the date of submission to now if the
suggestions had not been
>evaluated and display the datediff from the date of
submission to the date of
>evaluation if the suggestions had been evaluated.
>I appreciate for the help and guide. Thanks
>.
>|||you can directly get the Turnaround Time from database.
In your query get this column...
DateDiff(Day,Table.DateSubmitted,IsNull(Table.DateEvaluated,GetDate())) as
TurnaroundTime
and use Fields!TurnaroundTime.Value in your report.
hth
"JiaN" <JiaN@.discussions.microsoft.com> wrote in message
news:37BA72F4-FCF1-4659-ACA3-9366AE53A518@.microsoft.com...
>i am currently doing a system where user can submit their suggestions to us
> and part of my system is using Reporting Services and i need some guide on
> my
> problem.
> When user submit their suggestions, the date of submission will be auto
> input into SQL Server database and if the suggestions is being evaluated
> by a
> evaluator, the date of evaluation will also be input into the SQL Server
> database and all this part i had done it all in aspx.
> So now when user want to view their suggestions, they will go to a page
> which i had generate using Reporting Services. In this page, there is a
> column call Turnaround Time(the datediff from the day of submission to now
> till the suggestions is being evaluated). That means In this column i wan
> to
> display the datediff from the date of submission till the date today if it
> still had not been evaluated(that means the SQL Server database that
> contains
> the field "Date of Evaluation" is still null). And if the suggestions had
> been evaluated(that means the SQL Server database that contains the field
> "Date of Evaluation" contains a date value now), it will display the
> datediff
> from the date of submission to the date of evaluation.
> For now i can only display the datediff from the date of submission to now
> using the following expression : =DateDiff(DateInterval.Day,
> Fields!DateSubmitted.Value, Now()) and thus i need help on how to display
> the
> datediff from the date of submission to now if the suggestions had not
> been
> evaluated and display the datediff from the date of submission to the date
> of
> evaluation if the suggestions had been evaluated.
> I appreciate for the help and guide. Thanks|||ok thanks for your help ravi but my datatype for EvaluationDate and
SubmissionDate is Date/Time and it shows a error when i preview using the
expression you had given me.
The error is : "The value expression for the textbox 'Turnaround Time'
contains and error: [BC30452] Operator '-' is not defined for types 'Date'
and Microsoft.ReportingServices.ReportProcessing.ReportObjectModel.Fields"
"Ravi" wrote:
> You can try this :
> IIF(Fields!EvaluationDate.Value Is Nothing , Now()-Fields!
> SubmissionDate.Value,Fields!EvaluationDate.Value-Fields!
> SubmissionDate.Value)
>
> >--Original Message--
> >i am currently doing a system where user can submit their
> suggestions to us
> >and part of my system is using Reporting Services and i
> need some guide on my
> >problem.
> >
> >When user submit their suggestions, the date of
> submission will be auto
> >input into SQL Server database and if the suggestions is
> being evaluated by a
> >evaluator, the date of evaluation will also be input into
> the SQL Server
> >database and all this part i had done it all in aspx.
> >So now when user want to view their suggestions, they
> will go to a page
> >which i had generate using Reporting Services. In this
> page, there is a
> >column call Turnaround Time(the datediff from the day of
> submission to now
> >till the suggestions is being evaluated). That means In
> this column i wan to
> >display the datediff from the date of submission till the
> date today if it
> >still had not been evaluated(that means the SQL Server
> database that contains
> >the field "Date of Evaluation" is still null). And if the
> suggestions had
> >been evaluated(that means the SQL Server database that
> contains the field
> >"Date of Evaluation" contains a date value now), it will
> display the datediff
> >from the date of submission to the date of evaluation.
> >
> >For now i can only display the datediff from the date of
> submission to now
> >using the following expression : =DateDiff
> (DateInterval.Day,
> >Fields!DateSubmitted.Value, Now()) and thus i need help
> on how to display the
> >datediff from the date of submission to now if the
> suggestions had not been
> >evaluated and display the datediff from the date of
> submission to the date of
> >evaluation if the suggestions had been evaluated.
> >
> >I appreciate for the help and guide. Thanks
> >.
> >
>|||Its working!! Thanks avnrao!!
Ravi, thanks too! for spending the time in helping me. =)
"avnrao" wrote:
> you can directly get the Turnaround Time from database.
> In your query get this column...
> DateDiff(Day,Table.DateSubmitted,IsNull(Table.DateEvaluated,GetDate())) as
> TurnaroundTime
> and use Fields!TurnaroundTime.Value in your report.
> hth
> "JiaN" <JiaN@.discussions.microsoft.com> wrote in message
> news:37BA72F4-FCF1-4659-ACA3-9366AE53A518@.microsoft.com...
> >i am currently doing a system where user can submit their suggestions to us
> > and part of my system is using Reporting Services and i need some guide on
> > my
> > problem.
> >
> > When user submit their suggestions, the date of submission will be auto
> > input into SQL Server database and if the suggestions is being evaluated
> > by a
> > evaluator, the date of evaluation will also be input into the SQL Server
> > database and all this part i had done it all in aspx.
> > So now when user want to view their suggestions, they will go to a page
> > which i had generate using Reporting Services. In this page, there is a
> > column call Turnaround Time(the datediff from the day of submission to now
> > till the suggestions is being evaluated). That means In this column i wan
> > to
> > display the datediff from the date of submission till the date today if it
> > still had not been evaluated(that means the SQL Server database that
> > contains
> > the field "Date of Evaluation" is still null). And if the suggestions had
> > been evaluated(that means the SQL Server database that contains the field
> > "Date of Evaluation" contains a date value now), it will display the
> > datediff
> > from the date of submission to the date of evaluation.
> >
> > For now i can only display the datediff from the date of submission to now
> > using the following expression : =DateDiff(DateInterval.Day,
> > Fields!DateSubmitted.Value, Now()) and thus i need help on how to display
> > the
> > datediff from the date of submission to now if the suggestions had not
> > been
> > evaluated and display the datediff from the date of submission to the date
> > of
> > evaluation if the suggestions had been evaluated.
> >
> > I appreciate for the help and guide. Thanks
>
>

Expression Builder question

Hi all of you,

When you're making expressions with your own variables and system variables and so on. How could I see the contents for each variable?

When you have an expression like this:

"Cargas de Hacienda. " + SUBSTRING( @.[System:Stick out tongueackageName], 7,20) + " "

You can perfectly click above "Evaluated value" and see the resutl but I mean, individually over each variable on the variables listview is not possible.

Thanks for any input or advice,

Enric

There is a Variable window. To access the Variables Window, select from main menu View->Other Windows->Variables or right-click in the design pane and select Variables.

|||

Hi,

Thanks for your answer. I've already knew it. Issue comes when you have at the same time Expression Builder window: you can conmute between them.

|||2 ideas: a)make Variables Window floating and adjust Value column width or b)open same

solution in separate Visual Studio window.

|||

Thanks man.

Expressing a One to Many Relationship in a Single Row

I've two tables.

Table Charge

Table Payments

Charge has a one to many relationship with payments.

I have to transform the data from this new system of normalized tables over to a text file so that it may be read into an old mainframe computer. For each record I need to include the charge details and up to 10 payment details all on the same row.

Like this:

Charge1, ChargeDate, ChargeAmount, Payment1Amount, Payment2Amount, Payment3Amount

Charge2, ChargeDate, ChargeAmount, Payment1Amount, Payment2Amount, Payment3Amount

etc.

If their are less than 10 payments, the row has to be padded.

All of this is going to be DTS'd to a text file.

Is there a query that can handle this?

Simple answer yes:

Without seeing the table structures I can write some code based on these assumptions:

1) when you say Charge1, Charge2 that this is an ID field so I named it ChargeID

2) The Payments table carries the fieldname Payment.

3) Payments table carries the ChargeID as well for reference.

4) Payments carries the payment# represented here as paymentnum

Code Snippet

select distinct chargeID, ChargeDate, ChargeAmount

, pay1.payment [Payment1Amount]

, pay2.payment [Payment2Amount]

, pay3.payment [Payment3Amount]

, pay4.payment [Payment4Amount]

, pay5.payment [Payment5Amount]

, pay6.payment [Payment6Amount]

, pay7.payment [Payment7Amount]

, pay8.payment [Payment8Amount]

, pay9.payment [Payment9Amount]

, pay10.payment [Payment10Amount]

from charge

left join payments [pay1] on pay1.ChargeID = charge.ChargeID and pay1.paymentnum = 1

left join payments [pay2] on pay2.ChargeID = charge.ChargeID and pay2.paymentnum = 2

left join payments [pay3] on pay3.ChargeID = charge.ChargeID and pay3.paymentnum = 3

left join payments [pay4] on pay4.ChargeID = charge.ChargeID and pay4.paymentnum = 4

left join payments [pay5] on pay5.ChargeID = charge.ChargeID and pay5.paymentnum = 5

left join payments [pay6] on pay6.ChargeID = charge.ChargeID and pay6.paymentnum = 6

left join payments [pay7] on pay7.ChargeID = charge.ChargeID and pay7.paymentnum = 7

left join payments [pay8] on pay8.ChargeID = charge.ChargeID and pay8.paymentnum = 8

left join payments [pay9] on pay9.ChargeID = charge.ChargeID and pay9.paymentnum = 9

left join payments [pay10] on pay10.ChargeID = charge.ChargeID and pay10.paymentnum = 10

You can modify this to match your field names. If you don't have a simple paymentnum field, and they need to order by date or something, then I'll or somebody else will have to think a little longer.

right now the empty rows will come out NULL.

However you can represent them as blank or 'no payment' by this:

Code Snippet

case when pay10.payment is null then 'no payment' else pay10.payment end [Payment10Amount]

|||

You could use CTE + row_number() function for with task:

Code Snippet

createtable Charge

(

Id int,

ChargeDate datetime,

ChargeAmount decimal

)

createtable Payments

(

ChargeID int,

PaymentAmount decimal

)

insertinto Charge values(1,'2007-01-01', 1000)

insertinto Payments values(1,10)

insertinto Payments values(1,1)

insertinto Payments values(1,13)

insertinto Payments values(1,12)

insertinto Payments values(1,14)

insertinto Payments values(1,15)

insertinto Payments values(1,17)

insertinto Payments values(1,18)

insertinto Payments values(1,19)

insertinto Charge values(2,'2007-02-01', 100)

insertinto Payments values(2,37)

insertinto Payments values(2,38)

insertinto Payments values(2,49)

with CTE

as

(

--Numerate Payments for each ChargeID

select ChargeID , p.PaymentAmount,

row_number()over(Partitionby ChargeID Orderby ChargeID )as num

from Payments p

)

select

Id, ChargeDate, ChargeAmount

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=1)as PaymentAmount1

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=2)as PaymentAmount2

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=3)as PaymentAmount3

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=4)as PaymentAmount4

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=5)as PaymentAmount5

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=6)as PaymentAmount6

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=7)as PaymentAmount7

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=8)as PaymentAmount8

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=8)as PaymentAmount9

,(selecttop 1 PaymentAmount from CTE where CTE.ChargeID=ID and num=10)as PaymentAmount10

from Charge

Also check output of following query for understanding:

Code Snippet

select ChargeID , p.PaymentAmount,

row_number()over(Partitionby ChargeID Orderby ChargeID )as num

from Payments p

|||

Robert,

Thanks for trying, but the payment table could return up to 10 separate rows.

I've found that the answer seems to be temporary tables and cursors.

Once I get an answer, I'll post it here.

|||

I'm not sure what you mean here I realize that in the Payment table there will be 10 seperate rows. Hence the joining 10 different times the same table.

The structure that we are nomalizing is this correct?

Charge

charge1 amount, payment

Then in the payment table:

Charge1 payment1 $20

Charge1 payment2 $20

Charge1 payment3 $30

... and so on up to 10 times...

the above code will work for this... It is in fact built to handle up to 10 rows in the payment table for one charge.

BTW I was editing when you replied, I added on the section below about changing nulls to 'no payment' and other things you can do with the fields returned.

|||

You can use the following query and simply export it as text file,

Code Snippet

Create Table #charge (

[cid] int ,

[cname] Varchar(100) ,

[cdate] datetime

);

Insert Into #charge Values('1','Charge1','1/1/2007');

Insert Into #charge Values('2','Charge2','1/2/2007');

Insert Into #charge Values('3','Charge3','1/3/2007');

Create Table #payment (

[pid] int ,

[cid] int ,

[pamount] money

);

Insert Into #payment Values('1','1','1000');

Insert Into #payment Values('2','1','10000');

Insert Into #payment Values('3','1','100');

Insert Into #payment Values('4','1','6000');

Insert Into #payment Values('5','1','9000');

Insert Into #payment Values('6','1','100');

Insert Into #payment Values('7','1','100000');

Insert Into #payment Values('8','1','10098');

Insert Into #payment Values('9','1','1000');

Insert Into #payment Values('10','1','1029');

Insert Into #payment Values('16','1','34533');

Insert Into #payment Values('11','2','1000000');

Insert Into #payment Values('12','2','1928');

Insert Into #payment Values('13','2','100');

Insert Into #payment Values('14','2','10000');

Insert Into #payment Values('15','3','100');

Code Snippet

--SQL Server 2000

Select C.Cid,Cname,cdate,pamount into #Temp from #charge C Join #payment P on C.Cid=P.Cid

--Adding the Row Number, Grouped Row Number

Alter table #Temp Add RowId Int Identity(1,1), GroupId int, RowGroup Int

--Finding the Grouped Row Number

Update #Temp

Set

GroupId = RowId - (Select Min(RowID)-1 From #Temp Sub Where #Temp.Cid = Sub.Cid);

--Finding the Row Group

Update #Temp

Set RowGroup = (GroupId-1)/10

--Refine the Grouped Row Number

Update #Temp

Set GroupId = GroupId - (Select Min(GroupId)-1 From #Temp Sub Where #Temp.Cid = Sub.Cid And #Temp.RowGroup = Sub.RowGroup)

--Display the Conetent

Select

RowGroup+1 RowNumber

,CName

,Cdate

,Isnull(Cast(Max(Case When GroupId=1 Then pamount End) as Varchar),'') Payement1Amount

,Isnull(Cast(Max(Case When GroupId=2 Then pamount End) as Varchar),'') Payement2Amount

,Isnull(Cast(Max(Case When GroupId=3 Then pamount End) as Varchar),'') Payement3Amount

,Isnull(Cast(Max(Case When GroupId=4 Then pamount End) as Varchar),'') Payement4Amount

,Isnull(Cast(Max(Case When GroupId=5 Then pamount End) as Varchar),'') Payement5Amount

,Isnull(Cast(Max(Case When GroupId=6 Then pamount End) as Varchar),'') Payement6Amount

,Isnull(Cast(Max(Case When GroupId=7 Then pamount End) as Varchar),'') Payement7Amount

,Isnull(Cast(Max(Case When GroupId=8 Then pamount End) as Varchar),'') Payement8Amount

,Isnull(Cast(Max(Case When GroupId=9 Then pamount End) as Varchar),'') Payement9Amount

,Isnull(Cast(Max(Case When GroupId=10 Then pamount End) as Varchar),'') Payement10Amount

from

#Temp

Group By

CId

,CName

,Cdate

,RowGroup

Code Snippet

-SQL Server 2005

;With Ordered

as

(

Select C.Cid,Cname,cdate,pamount,Row_Number() OVER (Partition By C.Cid Order By C.Cid) GroupRowId from #charge C Join #payment P on C.Cid=P.Cid

)

, Grouped

as

(

Select Cid,Cname,Cdate,pamount,(GroupRowId-1)/10 RowGroup From Ordered

)

, ReGrouped

as

(

Select Cid,Cname,Cdate,pamount,RowGroup,Row_Number() Over(Partition By RowGroup Order By RowGroup) GroupRowId From Grouped

)

Select

RowGroup + 1 RowNumber

,CName

,CDate

,Isnull(Cast([1] as Varchar),'') Payment1Amount

,Isnull(Cast([2] as Varchar),'') Payment2Amount

,Isnull(Cast([3] as Varchar),'') Payment3Amount

,Isnull(Cast([4] as Varchar),'') Payment4Amount

,Isnull(Cast([5] as Varchar),'') Payment5Amount

,Isnull(Cast([6] as Varchar),'') Payment6Amount

,Isnull(Cast([7] as Varchar),'') Payment7Amount

,Isnull(Cast([8] as Varchar),'') Payment8Amount

,Isnull(Cast([9] as Varchar),'') Payment9Amount

,Isnull(Cast([10] as Varchar),'') Payment10Amount

From

ReGrouped

PIVOT

(

Max(pamount) For GroupRowId In ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10])

) as Pvt

|||

WOW.

Thanks for the options guys.

I'll be looking into each one of these.

Sunday, February 26, 2012

Express Installation

Hi,

I have tried to install the SQL 2005 Server Express and get the following message:

Your operating system does not meet service pack level requiements for this SQL server release. Install the service pack.

Can anyone tell me what service pack it will be and where I can get it.

hi,

please have a look at http://www.microsoft.com/sql/editions/express/sysreqs.mspx

regards

|||

What is the service pack of Windows where you are trying to install the SQLExpress?

Service packs can be obtained from MS download site.