Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
april24
Starting Member
5 Posts |
Posted - 2015-03-06 : 03:30:22
|
Hi,Can you please help to covert below 4 lines of code from PLSQL ( Oracle 11g) to T-SQL (SQL server 2012).1-SELECT SYSDATE INTO date_col FROM dual;2-dDate:= to_date(sDate,'MON-YYYY');3-dOrigin:=to_date(sOrigin,'DD-MON-YYYY HH24:MI:SS');4-EXECUTE IMMEDIATE 'insert into Table1 (REPORTNAME,REPORTCODE,DATE,WEEK,MONTH,YEAR,' || ColumnNames || ') values ('''||ReportName||''','''||ReportCode||''','''||InputDate||''','''||WeekNumber||''','''||Month||''','''||Year||''','''||Name||''','''||Description||''','||Fail||','||Pass||','||Passing||','''||Enabled||''')';Thanks. |
|
april24
Starting Member
5 Posts |
Posted - 2015-03-11 : 10:39:22
|
Some more info -The data types on the SQL side of the variables are -@sDate varchar(25), @dDate datetime2(0), Please help to convert this statement from oracle 11g to T-SQL (sql server 2012)dDate:= to_date(sDate,'MON-YYYY');Thanks. |
|
|
ScottPletcher
Aged Yak Warrior
550 Posts |
Posted - 2015-03-11 : 11:44:44
|
In SQL Server, you can use CONVERT to convert a character string into a date:DECLARE @sDate varchar(25)DECLARE @dDate datetime2(0)SET @sDate = 'Jan-2015'SELECT @dDate = CONVERT(datetime2(0), '01-' + @sDate, 106)PRINT @dDate |
|
|
|
|
|
|
|