Viewing 15 posts - 4,306 through 4,320 (of 8,731 total)
chindilog (8/28/2015)
August 28, 2015 at 1:41 pm
Ed Wagner (8/28/2015)
DonlSimpson (8/28/2015)
SQLRNNR (8/28/2015)
'tater saladRon White
White Potatoes
black beans
August 28, 2015 at 12:14 pm
Of course, you need some tweaking to make it numeric.
CREATE TABLE #SampleData( num varchar(100));
INSERT INTO #SampleData VALUES
('1000:001'),
('1001:001'),
('1002:001'),
('999:001'),
('998:001'),
('99:001'),
('1:001'),
('2:001'),
('3:001');
--This won't work correctly
SELECT * FROM #SampleData ORDER BY num
--This...
August 28, 2015 at 10:31 am
Actually, serverproperty('ProductVersion') returns the version in the form of 'major.minor.build.revision'.
Here are some changes to your code which might follow a better logic.
- I changed the @ver to an integer...
August 28, 2015 at 9:57 am
mar.ko (8/28/2015)
I put a semicolon after the last paren of the CTE and that throws a syntax error.
Something strange is happening...
August 28, 2015 at 8:40 am
Are you ending your statements with semicolons?
Other than that, I would need to see some sample code to be sure what are you talking about.
August 28, 2015 at 8:33 am
I included some comments on your code.
DECLARE @ver nvarchar(128);
DECLARE @UserName nvarchar(50);
DECLARE @UserD nvarchar(80);
DECLARE @LoginD nvarchar(80);
-- Initialize the variable.
SET @ver = CAST(serverproperty('ProductVersion') AS nvarchar)
SET @ver = SUBSTRING(@ver, 1, CHARINDEX('.', @ver) -...
August 28, 2015 at 8:24 am
Read the article on your signature on how to post performance questions.
August 28, 2015 at 8:16 am
No need to loop, the code that I posted will traverse the entire table and create the complete statement.
Here's a slightly different example:
CREATE TABLE ScriptTable(
groupID Nvarchar(10),
...
August 28, 2015 at 8:03 am
First you were truncating the date because you inserted the string value into a date variable and were expecting an 8 character string, so the variable converted again from date...
August 28, 2015 at 7:53 am
Something like this could work if you always return the same columns.
DECLARE @sql nvarchar(max) ;
SELECT @sql = ISNULL( @sql + CHAR(10) + 'UNION ALL ' + CHAR(10), '')
+ SQLStatement
FROM...
August 27, 2015 at 2:19 pm
ScottPletcher (8/27/2015)
August 27, 2015 at 1:47 pm
patrickmcginnis59 10839 (8/27/2015)
drew.allen (5/30/2012)
dwain.c (5/29/2012)
SELECT DATEADD(month, 1, '2012-02-29')
Depending on your point of view, the results this returns looks wrong, or maybe...
August 27, 2015 at 12:21 pm
Of course, you can do it without a cursor and a bit of dynamic sql.
Create procedure call_procedure(
@multiple_weeks varchar(8000)
)
AS
----Sample Data
--DECLARE @multiple_weeks varchar(8000) =...
August 27, 2015 at 11:58 am
Another possibility.
SELECT *
FROM #temp
ORDER BY CASE WHEN Section NOT LIKE '%[^0-9]%' THEN CAST( Section AS int) * -1
...
August 27, 2015 at 8:36 am
Viewing 15 posts - 4,306 through 4,320 (of 8,731 total)