Viewing 15 posts - 46 through 60 (of 86 total)
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
Oops! I posted to both! I thought that they were the same post and assumed that I accidentally closed the window the first time without posting.
Greg
February 9, 2009 at 2:46 pm
I would use NOT EXISTS instead of NOT IN for better performance like this:
SELECT DISTINCT a.InvoiceID
FROM TestTable a
WHERE NOT EXISTS
(SELECT * FROM TestTable b
WHERE...
February 9, 2009 at 2:42 pm
I would use NOT EXISTS instead of NOT IN like this:
SELECT DISTINCT a.InvoiceID
FROM TestTable a
WHERE NOT EXISTS
(SELECT * FROM TestTable b
WHERE a.InvoiceID = b.InvoiceID...
February 9, 2009 at 2:34 pm
Try this:
SELECT CONVERT(VARCHAR, GetDate(), 101) + ' ' +
CONVERT(VARCHAR, DATEPART(hh, GetDate())) + ':' +
RIGHT('0' + CONVERT(VARCHAR, DATEPART(mi, GetDate())), 2) AS Date
Greg
February 9, 2009 at 2:03 pm
February 9, 2009 at 8:22 am
SQL won't sort it that way by default because '{{{' comes before 'www' alphabetically. You could sort by ASCII code like you suggest, although I can't guarantee that it...
February 6, 2009 at 1:02 pm
When ordering a string, it uses alphabetical order.
NULLs are the lowest value,
then special characters,
then numbers,
then letters.
Greg
February 6, 2009 at 12:24 pm
Viewing 15 posts - 46 through 60 (of 86 total)