Showing posts with label language. Show all posts
Showing posts with label language. Show all posts

Monday, March 19, 2012

[SQL] Format function - need help

I have this piece of SQL code coming from Access:

Format([Jobnumber2],"00000") AS [Job Number]

What is the translation in SQL server language? I can't find the equivalent of the Format function!

Otherwise, is there a way to use ASP code to format the number in the way I'd like to?

Cheers,

C

anybody knows?|||RIGHT('00000'+CAST(JobNumber2 AS varchar),5) AS [Job Number]|||Thanks very much for your help Motley!

Monday, February 13, 2012

[6.5] Server language English but date format is Dutch

I have a Sql 6.5 database-server. When I open a query window and ask for getDate() it returns Tuesday, Sep 30 2003 12:00 AM.

So far so good.

However, when I connect through an ASP page on my webserver (through ODBC) and ask for getDate, I get a Dutch format: 30-09-2003.

My Sql Server is set to default (English US)
My Database user is set to English Us
My DB server's regional settings are set to US
My ODBC is set to use English as a language
My Webserver's regional settings are set to US (d/M/y)

I'm at wit's end. I have no clue as to why I am getting Dutch dates. I know I could just convert(varchar,...) but that is not an option right now.

Thanks in advance,

KristofDoes sound like a puzzle. What are the Web Clients settngs? Don;t know why that would matter unless you are runing code on the client side, but it's the only thing you don't have listed.|||The client side is as English (US) as it gets. Regional settings are English etc.

Glad to see you're puzzled as well ... Little comfort, but comfort :)|||As a test, try changing each of the servers' settings, one at a time, to a third setting (no idea off the top of my head what this would be) to see if and when a change occurs.

This could help give you a new angle (?!).|||Solved.

Apparently, you can have multiple regional settings on a server (NT4) and NT decides which one it picks. So I forced US to be the default system locale, booted the (live *glubs*) database server and all was well.

Thanks a lot for thinking with me!

Saturday, February 11, 2012

@NumericVal IS NOT NULL seems not to return a boolean.

I'm trying to ensure that only of the parameters is passed to my stored procedure.

BOL says that the IS [NOT] NULL operator (language construct?) will return a boolean. An IF statement takes an expression which results in a boolean so I was surprised to find that the below code doesn't parse.

CREATE PROC sp_OneParm(
@.NumericVal float = null,
@.StringVal nvarchar(200) = null,
@.DateVal datetime = null,
@.BitVal bit = null)
AS
DECLARE @.ValCount tinyint
SET @.ValCount = 0

-- Ensure we've only got one update value specified
IF @.NumericVal IS NOT NULL @.ValCount = @.ValCount + 1
IF @.StringVal IS NOT NULL @.ValCount = @.ValCount + 1
IF @.DateVal IS NOT NULL @.ValCount = @.ValCount + 1
IF @.BitVal IS NOT NULL @.ValCount = @.ValCount + 1
IF @.ValCount > 1 RAISERROR ('Only one @.*Val paramater may be specified when calling sp_OneParm()', 16, 1)

-- Other Stuff
GO

Am I missing something simple or do I need to restructure my code to achieve the logic I want?Sure :)

IF @.NumericVal IS NOT NULL SET @.ValCount = @.ValCount + 1|||Bugger. :o
Thank-you roac.