SQL Server queries with datetime [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have old program with access database. I want rewrite it to MS ACCESS. In queries u have text value mm/yyyy in query how to convert it to datetime from string?

DECLARE #a nvarchar(100)
SET #a = '12052013'
SELECT CONVERT(DATETIME,LEFT(#a,2) + '/' +
SUBSTRING(#a,3,2) + '/' + RIGHT(#a,4),101)
outputs this
--2013-12-05 00:00:00.000

Related

ORA-03291: Invalid truncate option - missing STORAGE keyword [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
i have to execute two statements in a sequence. My Statement is as below. I get the above error when i run this.
TRUNCATE TABLE MANUAL_LIST_BACKUP
INSERT INTO MANUAL_LIST_BACKUP AS SELECT * FROM MANUAL_TRANSACTIONS
Separate the two statements with a ;

How to be a command in SQL using LIKE? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to select records where a field (varchar (45)) contains one and only one letter x and the field length is greater than 20
In MySQL you can do:
SELECT * FROM tablename WHERE fieldname REGEXP '^[x]{20,}$'

How to convert money to decimal in SQL Server stored procedure [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have stored procedure where want convert money type to decimal type.
#money = 513.9010 type money
I want to convert it to decimal - how to do that?
select convert(decimal(7,4),#money)

How to concat values which retrieved from database [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am executing this query in SQL Server 2008
SELECT (CONVERT(DATE, GETDATE()))
and it shows the result 2013-07-22.
I need to print this result as 22713, where 22 is the date 7 is the month 13 is the year.
How could I do this?
SELECT CAST(DATEPART(dd,GETDATE()) as varchar(10))
+CAST(DATEPART(mm,GETDATE()) as varchar(10))
+RIGHT(CAST(DATEPART(YY,GETDATE()) as varchar(10)),2)
SQLFiddle demo
1) It bad practice use SQL for string operation. More right external tools
2) I use other RDBMS. Below query work with it:
select (extract(day from ua.stamp))||(extract(month from
ua.stamp))||(extract(year from ua.stamp)) from useractions ua
Furthemote, this link can help you:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/55d23bb0-6e1e-4a03-9bed-94e7c755ec4d/get-the-day-from-date-value-in-sql-server
You could read the string, go over it with a tokenizer, split it and put it back together the way you want it to be. What language are you using?

Generating SQL SP checksum [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
does anyone know of a way to generate some kind of checksum for each Stored Procedure on a server, in order to be able to compare them to other SP's on different servers?
Regards,
Jeroen
You could;
SELECT
ROUTINE_NAME,
HASHBYTES('SHA1', ROUTINE_DEFINITION)
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
AND OBJECTPROPERTY(OBJECT_ID(ROUTINE_NAME), 'IsMSShipped') = 0