Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Friday, May 27, 2011

Separate Strings in SQL Server

Während meiner Entwicklung fand ich eine Situation, wo ich zu trennen Saite haben '|'Grundlage für die Erreichung dieses schrieb ich folgenden kleinen Abfrage


select
  SUBSTRING (('KHI | 108'), 0, CHARINDEX ('|',(' KHI | 108 '))) City,
  REVERSE (SUBSTRING (REVERSE (KHI | 108 '), 0, CHARINDEX ('|', REVERSE(KHI | 108')))) CityCode

Wednesday, September 22, 2010

Calling Functions from Stored Procedure SQL

during my development work i stuck in a problem that sole by calling function (an inline Function) in my stored procedure .
In each procedures I used to Convert Rupees to Dollar so I make a function named Dollar converter here is the example

Create procedure My_SP(@from_Date datetime, @to_Date datetime )
As
Begin
Select carmodel,carName,CarPrice/DollarRate(Day)

End

Create Function DollarRate
(@date date)
return numeric(7,2)
(
Select ForexRate from ForexExchange where ForexRateDate = @date
)