Viewing 15 posts - 301 through 315 (of 395 total)
Do you always want to NULL the second zero, or is it more complicated?
August 28, 2012 at 4:32 am
This will work for adding one at a time:
--------------------------------------------------------------
drop table #test;
create table #test ( id varchar(13) );
--------------------------------------------------------------
declare @id varchar(13), @nextid varchar(13);
select @id = max(id) from #test;
select @nextid = case when...
August 28, 2012 at 3:34 am
RBarryYoung (8/24/2012)
laurie-789651 (8/24/2012)
Out of interest, what do you use the table-wrapper views for?I assume that you meant me?
Yes - should have quoted!
Thanks for the gen. I haven't come across...
August 25, 2012 at 2:40 pm
Out of interest, what do you use the table-wrapper views for?
August 24, 2012 at 1:43 pm
You could waste a lot of time applying for jobs you won't take. OK if you've got the time...
August 24, 2012 at 11:00 am
Cross apply values technique:
insert into #temp1 values (2004,'002445166',28,34,32,94)
insert into #temp1 values (2005,'002445166',19,35,66,75)
SELECT iSchoolYearCode,cStudentID,[Subject],Score
FROM #temp1
CROSS APPLY (
VALUES
('Math', iMathScaleScore)
...
August 24, 2012 at 8:15 am
This is a simple way of doing it:
create table #crime
(
id int,
Category varchar(10),
[Date] DateTime
);
insert #crime values ( 1, 'Murder', '2012-08-11 18:45:55.780' );
insert #crime values ( 2, 'Murder', '2010-07-11 17:45:55.780' );
insert #crime...
August 24, 2012 at 5:37 am
You would normally pass 2 date parameters to a procedure: @StartDate and @EndDate like this (using the syntax recommended above)
CREATE PROCEDURE dbo.xxx
(
@StartDate DateTime,
...
August 24, 2012 at 2:15 am
Is this what you want (using the LEFT(..., 1) function)?
ALTER FUNCTION [dbo].[FnSplit_string]
(
@List nvarchar(max),
@SplitOn nvarchar(max)
)
RETURNS @RtnValue table
(
Id int identity(1,1),
Value nvarchar(max)
)
AS
BEGIN
While (Charindex(@SplitOn,@List)>0)
Begin
Insert Into @RtnValue (value)
Select Value = LEFT(ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1))),1)
Set @List =Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
End
Insert Into @RtnValue...
August 23, 2012 at 11:30 am
You'll upset people by posting the same thing twice!!
Also - it's not really a SQL Server question.
I used to print out data using the barcode font & scan that when...
August 23, 2012 at 11:03 am
If you group by Server & DB, COUNT() is always 1 (as far as I can see).
How about this:
create table XYZ
(
ServerName varchar(10),
dbname varchar(10)
);
insert into XYZ values ( 'server1', 'db1' );
insert...
August 23, 2012 at 8:58 am
Can you clarify your question?
Do you mean (for example) How do you select all DateTimes with the years 2011-2012?
If so, then it's:
WHERE YEAR(DateTime) = 2011 OR YEAR(DateTime) = 2012
This is...
August 23, 2012 at 7:36 am
Lowell (8/23/2012)
laurie-789651 (8/23/2012)
Why is avoiding syntax checking a good idea?
It's a holdover from how my scripts get deployed; trying to avoid GO statements, so everything gets wrapped into dynamic SQL...
August 23, 2012 at 6:22 am
Viewing 15 posts - 301 through 315 (of 395 total)