Hi.
I have distributed databases in different language versions, I am creating a stored procedure, and this problably in future is going to be migrated to other SQL Server database. the query that I have inside the stored procedure is this:
Insert Into Prueba Values(14,'31/07/1999') ---> format date of this query is in Hispanic version (this works fine)
But, If this query is migrated to other SQL Server and it's version would be in English, that query wouldn't work, the principal reason is the format date.
Solution that I have on mind is creating a stored procedure that receives three parameters the month,day and year. I want to identify the localization of that SQL Server database and use "IF" conditions and inside of these concatenate month,day and year obviously depending of the date format identified through "IF" conditions.
If somebody has an idea to solve this or somebody knows how to identify the locatization in an SQL Server database I would be thankful.
Thank you again and best regards.
Christian
Hello my friend,
You do not need to do this. Instead, change the way string dates are interpreted in your stored procedure by using the SET DATEFORMAT command in the procedure before parsing the date. Run the following to see what I mean: -
DECLARE @.datevar varchar(50)
SET @.datevar = '2007/08/04'
SET DATEFORMAT ymd
SELECT MONTH(@.datevar)
SET DATEFORMAT ydm
SELECT MONTH(@.datevar)
Kind regards
Scotty
|||
Thank you so much...
I know it's going to work fine.
Thank you so much again !!
No comments:
Post a Comment