Viewing 15 posts - 7,246 through 7,260 (of 8,731 total)
Oh my, so much code! My laziness wants to write less.
declare @SSDate datetime = '20140109'
declare @CharSSDate char(10)
SELECT CONVERT( char(10), @SSDate, 103), --4-digit year
STUFF( CONVERT( char(10), @SSDate, 103), 7, 2,...
January 9, 2014 at 9:02 am
Thomas Abraham (1/9/2014)
By default, "Options 1, 2 and 4 are equivalent and identical to the original code" is the remaining answer that has not already been proven...
January 9, 2014 at 8:41 am
eli.misael (1/8/2014)
January 9, 2014 at 8:25 am
dwain.c (1/8/2014)
Luis - This is nice! Also out of the box.
select [object_id]
INTO #TableB
from sys.all_objects
WHERE 1=2
That was very common at my first job to avoid writing the definition of...
January 9, 2014 at 8:23 am
I'm sure that this is a running total problem that I would love to try with SQL 2012, but I don't have it at work.
There's another option that works great...
January 8, 2014 at 2:58 pm
Here's an example:
select *
INTO #TableB
from sys.all_objects
WHERE 1=2
select top 1000 *
INTO #TableA
from sys.all_objects
WHILE @@ROWCOUNT > 0
BEGIN
INSERT INTO #TableB
SELECT TOP 100 *
FROM #TableA a
WHERE NOT EXISTS(SELECT * FROM #TableB b...
January 8, 2014 at 2:38 pm
Why would you do that? How can you identify which rows you have inserted and which rows you haven't?
January 8, 2014 at 1:21 pm
Change
FOR XML PATH( '' )), 1, 1, '' )
To
FOR XML PATH(''), TYPE).value('.','varchar(max)'),1,1,'')
January 8, 2014 at 1:20 pm
You could set up a job in the SQL Server Agent.
January 8, 2014 at 12:50 pm
You actually don't need the following line
DECLARE @cmd VARCHAR(MAX)
As said, you would be better deleting the information from the table. You could use TRUNCATE TABLE for performance, but it has...
January 8, 2014 at 12:21 pm
You can't assign the result of a formula directly to a variable. You would need to use dynamic code.
Here's an example:
DECLARE @MYFOR AS NVARCHAR(100), @Result int
SET @MYFOR ='V6*2*3'
SELECT @MYFOR =...
January 8, 2014 at 11:54 am
You have a problem with your nesting. You're opening your cast before the case and closing it in the middle of the case. It has to be either all out...
January 8, 2014 at 10:29 am
What about importing last column as a string and using a derived column to validate and convert value into int?
January 8, 2014 at 10:18 am
Jeff Moden (1/7/2014)
eccentricDBA (1/7/2014)
January 7, 2014 at 2:11 pm
You could truncate your values to 23 positions or you could convert them to datetime2
CREATE TABLE #Test(
chardatevarchar( 50))
INSERT #Test VALUES(
'2013-01-09 11:32:00'),(
'2013-02-14 20:22:37.033000000'),(
'2013-05-05 23:11:15.013000000'),(
'2013-06-14 15:20:36.030000000'),(
'2013-01-09 11:29:00')
SELECT *, CAST(LEFT( chardate, 23)...
January 7, 2014 at 11:06 am
Viewing 15 posts - 7,246 through 7,260 (of 8,731 total)