Viewing 15 posts - 766 through 780 (of 2,171 total)
You can use ISDATE() function with some careful considerations.
SELECT CASE ISDATE(Col1) WHEN 1 THEN CAST(Col1 AS DATETIME) ELSE '2008-12-31' END
FROM Table1
August 12, 2008 at 2:41 pm
SELECTp.RoutineName,
'EXEC sp_helptext ' + QUOTENAME(p.RoutineName) AS [Exec]
FROM(
SELECTOBJECT_NAME(so.ID) AS RoutineName,
(SELECT TOP 100 PERCENT '' + sc.TEXT FROM SYSCOMMENTS AS sc WHERE sc.ID = so.ID ORDER BY sc.COLID FOR...
August 12, 2008 at 2:06 pm
Choose DESIGN next time instead of EDIT and the designer will rearrange your query in SQL Server 2005.
August 12, 2008 at 11:44 am
DECLARE@dt1 DATETIME,
@dt2 DATETIME
SELECT@dt1 = '20080115',
@dt2 = '20080308'
SELECTDATEADD(MONTH, DATEDIFF(MONTH, '19000101', DATEADD(MONTH, Number, @dt1)), '19000131')
FROMmaster..spt_values
WHEREType = 'P'
AND Number <= DATEDIFF(MONTH, @dt1, @dt2)
August 12, 2008 at 9:52 am
IF is procedural statement.
SELECTCASE TransactionType
WHEN 'REFUND' THEN CAST(-Amount AS MONEY)
WHEN 'CHARGE' THEN CAST(Amount AS MONEY)
ELSE CAST(0 AS MONEY)
END AS [Amount],
TransactionType,
TransactionStatus,
TransactionResult,
...
August 12, 2008 at 6:33 am
Oh... I see now.
You want to have an extra space after weekday name.
And you should be using Style 109 instead of 9 only, if you want century along with date.
August 11, 2008 at 8:23 am
Unless double quote is part of the column information, such as
12" Wrench Stainless steel
August 11, 2008 at 8:22 am
DECLARE@Source INT
SET@Source = 20070101
SELECT CONVERT(CHAR(10), CAST(STR(@Source, 8, 0) AS DATETIME), 111)
August 11, 2008 at 8:20 am
Can't you get rid of double quote characters when using BULK INSERT
by using a format file?
August 11, 2008 at 8:05 am
SELECT CONVERT(CHAR(10), STR(Col1, 8, 0), 111)
FROM Table1
August 11, 2008 at 8:01 am
For alternative solutions, see
-- Prepare sample data
DECLARE@Sample TABLE
(
Descr VARCHAR(20),
Value INT,
PRIMARY KEY CLUSTERED
(
Descr,
Value
),
Seq INT
)
INSERT@Sample
(
Descr,
Value
)
SELECT'Test1', 1 UNION ALL
SELECT'Test1', 2 UNION ALL
SELECT'Test1', 3 UNION ALL
SELECT'Test1', 7 UNION ALL
SELECT'Test1', ...
August 11, 2008 at 7:54 am
Interesting.
This is the resultset from above suggestion.
DescrValueDescrValue
Test11Test12
Test12Test13
Test13NULLNULL
Test17Test18
Test18Test19
Test19NULLNULL
Test112Test113
Test113NULLNULL
Test24Test25
Test25Test26
Test26NULLNULL
Test310Test311
Test311NULLNULLUsing this test codeDECLARE@Sample TABLE (Descr VARCHAR(20), Value INT)
INSERT@Sample
SELECT'Test1', 1 UNION ALL
SELECT'Test1', 2 UNION ALL
SELECT'Test1', 3 UNION ALL
SELECT'Test1', 7 UNION...
August 11, 2008 at 7:50 am
Ddin't
select datename(dw,@date) + ', ' + convert(varchar, @date, 107)
work for you?
August 11, 2008 at 7:43 am
SELECT * FROM Users
WHERE UserName LIKE '%[^a-z0-9 .]%'
August 11, 2008 at 4:07 am
Viewing 15 posts - 766 through 780 (of 2,171 total)