Viewing 15 posts - 4,966 through 4,980 (of 8,731 total)
Sergiy (5/4/2015)
I'm trying to create a function, not a new table.
- mistake #1
hardcoding data in a routine code - mistake #2
Implementing relations between entities (title and gender) in conditional...
May 5, 2015 at 8:52 am
You could do something like this:
CREATE FUNCTION dbo.Gender
(
@titleofcourtesy AS VARCHAR(10)
)
RETURNS TABLE
AS
RETURN
SELECT
CASE
WHEN @titleofcourtesy IN('Ms.', 'Mrs.') THEN 'Female'
...
May 4, 2015 at 9:34 pm
Perhaps if you use it twice with a little tweak. 😉
SELECT
S.ID
,LTRIM(ISNULL(Y.Item, X.Item)) AS OUT_STRING
FROM @SAMPLE S
CROSS APPLY dbo.DelimitedSplit8K(S.STRING,CHAR(39)) AS X
OUTER APPLY (SELECT...
May 4, 2015 at 9:27 pm
I usually use this to open large flat files.
http://www.portablefreeware.com/?id=693
You should look at the errors to find your problem. Those will help you identify the row that's missing.
Are you sure that...
May 4, 2015 at 1:56 pm
Quick questions:
1. Why are you using Dynamic SQL when a normal query would be enough?
2. Why aren't you parametrizing your Dynamic SQL leaving it open to SQL Injection?
3. Why are...
May 4, 2015 at 1:45 pm
Your code should be simpler and it shouldn't combine EXISTS and IN.
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name
FROM sys.tables AS t
WHERE not exists (SELECT 1
...
May 4, 2015 at 1:21 pm
Kelley Fitz (5/4/2015)
The ? is the table nameEXEC MSFOREACHTABLE 'SELECT COUNT(*) AS ''?'' FROM ?'
TABLENAME
COUNT
Do you realize that you posted almost the same answer one year ago...
May 4, 2015 at 12:43 pm
Thank you for the feedback. I'm glad it helped.
But please, make sure to understand what the code is doing. If you have any questions, feel free to ask.
Also remember to...
May 4, 2015 at 12:36 pm
Lowell (5/4/2015)
duplicates are typically removed by using a GROUP BY...
May 4, 2015 at 12:30 pm
The "Tally table" is simply a table with consecutive numbers. It could start at 0 or 1 or any number you need. It could even be a view, a function,...
May 4, 2015 at 12:14 pm
Jeff Moden (5/1/2015)
May 1, 2015 at 2:18 pm
SQLBill (4/30/2015)
ISNULL(NO_OF_SAMPLE_DAYS,'NO Backup Job Ran'), '',
td = ISNULL(BackupSizeMB,'NO Data Found'), '',
td = ISNULL(TotalDBSpaceMB,'NO Data Found'), '',
td = ISNULL(DataGrowth,'NO Data Found'), '',
td = ISNULL(LogGrowth,'NO Data Found'), '',
Take...
April 30, 2015 at 2:26 pm
You're comparing a nvarchar(max) to a decimal.
For 20%, I assume that you need 0.2
April 30, 2015 at 2:23 pm
Maybe the DelimitedSplit8k will be faster as there's no really a need for wildcards.
http://www.sqlservercentral.com/articles/Tally+Table/72993/
SELECT SUBSTRING( Item, 3, CHARINDEX( '#', Item, 3) - 3) AS keyword,
'[' + LEFT( Item, CHARINDEX(...
April 30, 2015 at 12:57 pm
Viewing 15 posts - 4,966 through 4,980 (of 8,731 total)