Showing posts with label converting. Show all posts
Showing posts with label converting. Show all posts

Wednesday, March 28, 2012

new to mssql problem with query conversion

im managing most queries without any problems (im converting from access to mssql) but this one is causing me grief - how do i put this into mssql ?

SELECT dbo_Personal.ID, dbo_Personal.Surname1, dbo_Lead.SourceOfLead, dbo_Lead.DateOfLead, dbo_Mortgage.MortgageAppSubmitted, dbo_Mortgage.MortgageOfferedAccepted, dbo_Mortgage.MortgageDrawndown, dbo_Mortgage.MortgageApplicationClosed,
[dbo_Mortgage.MortgageCommissionAnticipated]+[dbo_Life.LifeCommissionAnticipated]+[dbo_BuildingsAndContents.BandCCommissionAnticipated]+[dbo_OtherBusiness.OtherBusinessCommissionAnticipated] AS Expr1,

[dbo_commissions.MortgageCommissionReceived]+[dbo_commissions.LifeCommissionReceived]+[dbo_commissions.BandCCommissionReceived]+[dbo_commissions.OtherBusinessCommissionReceived] AS Expr2

, IIf([Expr1]<1000,[Expr1]*0.3,IIf([Expr1]<2000,[Expr1]*0.4,[Expr1]*0.5)) AS Expr3
, IIf([Expr2]<1000,[Expr2]*0.3,IIf([Expr2]<2000,[Expr1]*0.4,[Expr2]*0.5)) AS Expr4

FROM (((((dbo_Personal INNER JOIN dbo_Lead ON dbo_Personal.ID = dbo_Lead.ID) LEFT JOIN dbo_Mortgage ON dbo_Personal.ID = dbo_Mortgage.ID) LEFT JOIN dbo_OtherBusiness ON dbo_Personal.ID = dbo_OtherBusiness.ID) LEFT JOIN dbo_BuildingsAndContents ON dbo_Personal.ID = dbo_BuildingsAndContents.ID) LEFT JOIN dbo_Commissions ON dbo_Personal.ID = dbo_Commissions.ID) LEFT JOIN dbo_Life ON dbo_Personal.ID = dbo_Life.ID
WHERE (((dbo_Lead.SourceOfLead) Like "Solutions*"));

Instead of this,
IIf([Expr1]<1000,[Expr1]*0.3,IIf([Expr1]<2000,[Expr1]*0.4,[Expr1]*0.5)) AS Expr3

Use


case
when [Expr1]<1000 then [Expr1]*0.3
when [Expr1]<2000 then [Expr1]*0.4
else [Expr1]*0.5
end as Expr3

similar syntax for Expr4 too.

Hope that helps.|||ill give it a go thanks!|||ive got as far as this :-

CREATE PROCEDURE solnorth AS

SELECT dbo.Personal.ID, dbo.Personal.Surname1, dbo.Lead.SourceOfLead, dbo.Lead.DateOfLead, dbo.Mortgage.MortgageAppSubmitted, dbo.Mortgage.MortgageOfferedAccepted, dbo.Mortgage.MortgageDrawndown, dbo.Mortgage.MortgageApplicationClosed,
dbo.Mortgage.MortgageCommissionAnticipated+dbo.Life.LifeCommissionAnticipated+dbo.BuildingsAndContents.BandCCommissionAnticipated+dbo.OtherBusiness.OtherBusinessCommissionAnticipated AS Expr1,
dbo.commissions.MortgageCommissionReceived+dbo.commissions.LifeCommissionReceived+dbo.commissions.BandCCommissionReceived+dbo.commissions.OtherBusinessCommissionReceived AS Expr2,

case
when Expr1<1000 then Expr1*0.3
when Expr1<2000 then Expr1*0.4
else Expr1*0.5
end as Expr3,

case
when Expr2<1000 then Expr2*0.3
when Expr2<2000 then Expr2*0.4
else Expr2*0.5
end as Expr4

FROM (((((dbo.Personal LEFT JOIN dbo.Lead ON dbo.Personal.ID = dbo.Lead.ID) LEFT JOIN dbo.Mortgage ON dbo.Personal.ID = dbo.Mortgage.ID) LEFT JOIN dbo.OtherBusiness ON dbo.Personal.ID = dbo.OtherBusiness.ID)
LEFT JOIN dbo.BuildingsAndContents ON dbo.Personal.ID = dbo.BuildingsAndContents.ID) LEFT JOIN dbo.Commissions ON dbo.Personal.ID = dbo.Commissions.ID)
LEFT JOIN dbo.Life ON dbo.Personal.ID = dbo.Life.ID
WHERE (((dbo.Lead.SourceOfLead) Like 'Solutions*'));
GO

but im getting invalid column name for Expr1 and Expr2 ?
where am i going wrong ?

thanks

mark|||You cannot use Expr1 and Expr2 (an alias) in the case. Just replace Expr1 and Expr2 with the same expressions you use to create Expr1 and Expr2.|||You will have to replace
Expr1
with
dbo.Mortgage.MortgageCommissionAnticipated+dbo.Life.LifeCommissionAnticipated+dbo.BuildingsAndContents.BandCCommissionAnticipated+dbo.OtherBusiness.OtherBusinessCommissionAnticipated

and

Expr2
dbo.commissions.MortgageCommissionReceived+dbo.commissions.LifeCommissionReceived+dbo.commissions.BandCCommissionReceived+dbo.commissions.OtherBusinessCommissionReceived|||great thanks that worked - well theres no errors now - just some errors with the datagrid but i should be able to sort that - thanks for the help everyone!|||quick (question how do i create Expr1 ?
eg

[dbo_Mortgage.MortgageCommissionAnticipated]+[dbo_Life.LifeCommissionAnticipated]+[dbo_BuildingsAndContents.BandCCommissionAnticipated]+[dbo_OtherBusiness.OtherBusinessCommissionAnticipated] AS Expr1

id still like to show expr1 on a datagrid if i could (eg add the columns together)

thanks

mark|||Umm, you create it by placing what you have in the select list. Am I missing something?|||heh my bad (im still learning!)
all works great now thanks for all the help

Friday, March 23, 2012

New sql server setup

Hello all,
I am new to MSSQL, our compnay is going to be converting our current
pervasive database to mssql. It is my resposibility to setup the new
hardware.
I heard mention that for performance it is best to split up the drives that
all the data is on. We willl be purchasing a new HP MSA30 disk shelf that
holds 14 drives and I was wondering how it would be best to setup the disks
that will be going in the msa30.
We will also be putting this on a clustered server.
On which Operating system you are planning to build cluster?
you will require shared disk for clustering, read more from below links: -
http://www.microsoft.com/technet/pro...a05ac9cb4.mspx
http://sql-server-performance.com/sq...stall_main.asp
http://sql-server-performance.com/clustering_intro1.asp
"Romualdt" wrote:

> Hello all,
> I am new to MSSQL, our compnay is going to be converting our current
> pervasive database to mssql. It is my resposibility to setup the new
> hardware.
> I heard mention that for performance it is best to split up the drives that
> all the data is on. We willl be purchasing a new HP MSA30 disk shelf that
> holds 14 drives and I was wondering how it would be best to setup the disks
> that will be going in the msa30.
> We will also be putting this on a clustered server.

New sql server setup

Hello all,
I am new to MSSQL, our compnay is going to be converting our current
pervasive database to mssql. It is my resposibility to setup the new
hardware.
I heard mention that for performance it is best to split up the drives that
all the data is on. We willl be purchasing a new HP MSA30 disk shelf that
holds 14 drives and I was wondering how it would be best to setup the disks
that will be going in the msa30.
We will also be putting this on a clustered server.On which Operating system you are planning to build cluster?
you will require shared disk for clustering, read more from below links: -
http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/ServerHelp/f5abf1f9-1d84-4088-ae54-06da05ac9cb4.mspx
http://sql-server-performance.com/sqlserver2000_clustering_install_main.asp
http://sql-server-performance.com/clustering_intro1.asp
"Romualdt" wrote:
> Hello all,
> I am new to MSSQL, our compnay is going to be converting our current
> pervasive database to mssql. It is my resposibility to setup the new
> hardware.
> I heard mention that for performance it is best to split up the drives that
> all the data is on. We willl be purchasing a new HP MSA30 disk shelf that
> holds 14 drives and I was wondering how it would be best to setup the disks
> that will be going in the msa30.
> We will also be putting this on a clustered server.sql

New sql server setup

Hello all,
I am new to MSSQL, our compnay is going to be converting our current
pervasive database to mssql. It is my resposibility to setup the new
hardware.
I heard mention that for performance it is best to split up the drives that
all the data is on. We willl be purchasing a new HP MSA30 disk shelf that
holds 14 drives and I was wondering how it would be best to setup the disks
that will be going in the msa30.
We will also be putting this on a clustered server.On which Operating system you are planning to build cluster?
you will require shared disk for clustering, read more from below links: -
f5abf1f9-1d84-4088-ae54-06da05ac9cb4.mspx" target="_blank">http://www.microsoft.com/technet/pr...da05ac9cb4.mspx
http://sql-server-performance.com/s...nstall_main.asp
http://sql-server-performance.com/clustering_intro1.asp
"Romualdt" wrote:

> Hello all,
> I am new to MSSQL, our compnay is going to be converting our current
> pervasive database to mssql. It is my resposibility to setup the new
> hardware.
> I heard mention that for performance it is best to split up the drives tha
t
> all the data is on. We willl be purchasing a new HP MSA30 disk shelf that
> holds 14 drives and I was wondering how it would be best to setup the disk
s
> that will be going in the msa30.
> We will also be putting this on a clustered server.