Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Friday, March 30, 2012

If I write custom Data and Delivery extensions for RS 2000, will they work with RS 2005?

If not, can you give me an idea how extensive the changes will be?
Thanks,
-SteveExisting interfaces for data / delivery extensions have not been changed. A
few optional data extension interfaces got added in RS 2005, but they won't
affect your existing custom data extension. Your RS2000 data extensions
should just work on RS2005 once configured in the config files.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Stephen Walch" <swalch@.online.nospam> wrote in message
news:%23RUMT18DFHA.3416@.TK2MSFTNGP09.phx.gbl...
> If not, can you give me an idea how extensive the changes will be?
> Thanks,
> -Steve
>

Monday, March 26, 2012

if condition within select query sql server 2000

Hi all,

I have to write a select query which need some logic to be implemented.

Query is like

select name,number,active,

if active ="true" then

select @.days=days from tbl_shdsheet

else

@.days=''

end

from tbl_emp

In the above query there will be days row for that employee if active is true else there won't be any data for that emp in the tbl_shdsheet

So how can i write queery for this.

You probably want to implement this using a Left Join:http://www.w3schools.com/sql/sql_join.asp

|||

Hi Thanks for replying.

My Problem has solved.I wrote a user defined function with the if else condition to be checked by sending the value to be checked as parameter to that function

|||

You can use user defined function to achieve this but you can easily do this by using case..when..else..end statement and joins. Below is your modified statement. You need to fill in the column names for mapping both the tables.

select name,number,active,
case
when te.active ='true'then ts.days
else''
end as Days
from tbl_emp teleftjoin tbl_shdsheeton te.[column to map] = ts.[column to map]

If Condition In Select Statement...

Hi,
I need to write an if condition in SELECT statement. Below is the code for the same. But its throwing error. Can some refine the code below.

SELECT tblCustomer.Customer_LegalName,
(IF (tblCustomer.IsNRACustomer = TRUE) SELECT tblCustomer.Customer_PassportNo ELSE
ISNULL(tblCustomer.Customer_TaxId, tblCustomer.Customer_PassportNo)) AS TAXID,

tblCustomer.Customer_DoingBusinessAs, tblSeed_EDDCategory.CategoryName, '2' AS DCS, tblUser_OfficerCode.User_OfficerCode,
tblCustomer.Customer_AreaId, tblCustomer.Customer_BranchId, CONVERT(VARCHAR(11), tblCustomer_EDDCategory.CreateDate)
AS CreateDate, tblSeed_EDDCategory.EDDCategoryId, tblCustomer_EDDCategory.Category_CreateEmpId,
tblCustomer_EDDCategory.CustCatId, tblCustomer.Customer_Id, tblSeed_Area.AreaName, tblSeed_Employee.Name,
tblUser_OfficerCode.User_OfficerName, tblCustomer.Customer_TaxId, tblCustomer.IsNRACustomer,
tblCustomer.Customer_PassportNo
FROM tblCustomer INNER JOIN
blCustomer_EDDCategory ON tblCustomer.Customer_Id = tblCustomer_EDDCategory.CustomerId INNER JOIN
tblSeed_EDDCategory ON tblCustomer_EDDCategory.EDDCategoryId = tblSeed_EDDCategory.EDDCategoryId INNER JOIN
tblSeed_Employee ON tblCustomer.Customer_CreateEmpId = tblSeed_Employee.EmployeeId INNER JOIN
tblUser_OfficerCode ON tblCustomer.Customer_CreateEmpId = tblUser_OfficerCode.EmployeeId INNER JOIN
tblSeed_Area ON tblCustomer.Customer_AreaId = tblSeed_Area.AreaId

Thanks,
Rahul JhaIt might help if you checked for the correct syntax in Books Online...
Use a CASE statement int he SELECT clause:

SELECT tblCustomer.Customer_LegalName,
case tblCustomer.IsNRACustomer
when TRUE then tblCustomer.Customer_PassportNo
else ISNULL(tblCustomer.Customer_TaxId, tblCustomer.Customer_PassportNo)
end AS TAXID,
...

...but you are still going to have to define what "TRUE" is. What datatype is IsNRACustomer?|||Thanks Blindman :-)

IF @@ROWCOUNT > 200 Return Nothing

Hi, I am trying to write a stored proc that will return data for use on a
webpage. I would like the SP to return nothing if the ROWCOUNT > 200. How do
I just return an error and no data?
TIAHi
Look up RAISERROR in SQL Server BOL
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"AlCoast" wrote:

> Hi, I am trying to write a stored proc that will return data for use on a
> webpage. I would like the SP to return nothing if the ROWCOUNT > 200. How
do
> I just return an error and no data?
> TIA|||Ok. Thank you. Will do
"Mike Epprecht (SQL MVP)" wrote:
> Hi
> Look up RAISERROR in SQL Server BOL
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
>
> "AlCoast" wrote:
>|||Try,
...
if (select count(*) from ...) > 200
raiserror('more than 200.', 16, 1)
else
select c1, ..., cn from ...
...
AMB
"AlCoast" wrote:

> Hi, I am trying to write a stored proc that will return data for use on a
> webpage. I would like the SP to return nothing if the ROWCOUNT > 200. How
do
> I just return an error and no data?
> TIA

Wednesday, March 21, 2012

Identity_insert not happening

I am setting insert_identity to on for a table in t-sql.
The table name is passed as a parameter in the tsql procedure.

When i write the following code.
set @.setStr = 'set IDENTITY_INSERT ' + @.toTableName +' ON'
execute (@.setStr)

and then set the insert query and execute it as follows:

set @.insQuery = 'insert into ' + @.toTableName + ' ( ' + @.colString + ') select ' + @.colString + ' from ' + @.fromTableName
execute(@.insQuery)

when i execute the procedure it doesnt insert values into the table and gives the following error though i am setting the identity to on.

Error: cannot insert explicit value for identity column in table 'emp' when IDENTITY_INSERT is set to OFF.

i cant make out why it is not applying identity_insert to the table.
Can anybody help me out.

Thank YouDon't use EXECUTE as it will run in a different thread/process to the rest of your code - so the code which follows the call, doesn't know anything about the fact you have set IDENTITY_INSERT to ON.

Try using sp_executesql instead. (Books Online has more information on how to use this system stored proc)

macka.|||it doesnt work... :(
beacuse i've to use exec to execute the sp_executesql proc.
so it gives the same result..

so i can try to make one string by putting a newline character between the following 2 strings... and then just run one string... i guess it might be possible..

'set IDENTITY_INSERT ' + @.toTableName +' ON'

and

'insert into ' + @.toTableName + ' ( ' + @.colString + ') select ' + @.colString + ' from ' + @.fromTableName

but the problem is that i dont know how to append a newline character in the string \r \n \\r \\n dont work... can somebody suggest something on this...

Originally posted by macka
Don't use EXECUTE as it will run in a different thread/process to the rest of your code - so the code which follows the call, doesn't know anything about the fact you have set IDENTITY_INSERT to ON.

Try using sp_executesql instead. (Books Online has more information on how to use this system stored proc)

macka.|||Why not just build it as a single string with space between the statements ? I've just tested that and it works fine.

macka.|||Thanks for this.. i really appriciate ur help...
space works and actually newline character is char(10).. it works with this too... :)

Originally posted by macka
Why not just build it as a single string with space between the statements ? I've just tested that and it works fine.

macka.