Viewing 15 posts - 46 through 60 (of 94 total)
This will get the number of days between today and the date in the DtContactDate column:
DATEDIFF(dd, DtContactDate, GetDate()) AS NumberOfDays
Greg
February 16, 2009 at 7:42 am
Norman,
Try this:
SELECT DISTINCT S.Computername
FROM dbo.tblSoftware S
WHERE S.softwareName = 'App1' AND NOT EXISTS
(SELECT * FROM dbo.tblRegistry R
WHERE R.Regkey IN('RegKey1', 'Regkey2') AND R.Computername = S.Computername)
Greg
February 13, 2009 at 2:03 pm
I don't think you would want to go with if statements. There are 12 different potential variables in this case, which equals a whole lot of possibilities! I've seen...
February 12, 2009 at 12:33 pm
I just realized that INT or BIGINT are not large enough to hold a 24 digit number. Maybe DECIMAL(24, 0)?
February 12, 2009 at 9:55 am
Couldn't you use SUBSTRING to isolate each individual day, then convert it to an integer. If it's not zero, then the day has availability?
Greg
February 12, 2009 at 9:49 am
You could also pass in an XML string and parse it into a temp table or table variable.
Greg
February 11, 2009 at 9:53 am
You have ([Severity] = @Severity OR [Severity] <> '')
It should be ([Severity] = @Severity OR @Severity = '')
If the value that is passed in is an empty string, it will...
February 11, 2009 at 9:40 am
Hmm... This looks an awful lot like homework. Why don't you post what you think the design should look like and maybe someone will critique it?
Greg
February 11, 2009 at 9:17 am
I always avoid using dynamic SQL. Your WHERE clause could look like this instead:
WHERE (Username = @Username OR @Username = '')
Basically it will use the username if it's supplied...
February 11, 2009 at 8:57 am
I would do something like this:
Here I'm setting variables and adding comma before and after the input strings
DECLARE @State VARCHAR(100), @Region VARCHAR(100)
SELECT @State = '1, 2, 3, 4, 5, 6,...
February 11, 2009 at 6:59 am
You shouldn't need to use dynamic SQL at all. If @Region and @State are some sort of comma delimited string, I would parse them into table variables and join...
February 11, 2009 at 6:23 am
Try this:
SELECT SUBSTRING(ColumnName, CHARINDEX('\', ColumnName) + 1, 100)
FROM TableName
Greg
February 10, 2009 at 9:55 am
It's probably the * in Count(*). Instead, select a column from the table that has the records that you are counting.
Greg
February 10, 2009 at 7:01 am
I would use a LEFT OUTER JOIN so that all results are returned regardless if they match or not. And then use ISNULL(COUNT(*), 0) AS 'Count' so that zeros...
February 10, 2009 at 6:53 am
Viewing 15 posts - 46 through 60 (of 94 total)