Viewing 15 posts - 3,406 through 3,420 (of 5,504 total)
You need to add precision and scale when converting to DECIMAL. Otherwise it will use the default values (DECIMAL(18,0)) leading to integer values.
Try
SELECT
ISNULL(CONVERT(DECIMAL(20,2),@val),2) AS [column1]
FOR XML RAW('row'), elements, root('XMLData'),...
May 30, 2010 at 2:52 am
I agree with rwatson and, partially, with futura.
However, we managed to use ServiceBroker to replace a job that repeated every minute to check if new data are available... It took...
May 30, 2010 at 2:47 am
How about using CONVERT?
SELECT RIGHT(CONVERT(CHAR(19),GETDATE(),100),7)
May 30, 2010 at 2:23 am
Why don't you use a Tally (or Numbers) table using a left join, limited to max(SortOrder)? If you don't use a Tally table yet, please have a look at the...
May 30, 2010 at 2:19 am
Please provide ready to use sample data and your requested result based on those data.
Alternatively you could look into bcp for exporting data together with FOR XML (PATH/AUTO/RAW/EXPLICIT) to transform...
May 29, 2010 at 1:13 pm
duplicate post.
A more detailed explanation can be found here.
May 29, 2010 at 12:58 pm
I took your sample file and removed a few lines to demonstrate the concept and to reduce the reply post. Both, XML NAMESPACES and CROSS APPLY are described in more...
May 29, 2010 at 12:47 pm
I think there is a misinterpretation between outsourcing and offshore outsourcing.
Example: IT staff can be outsourced to another company that is located right next door (or even in-house). We...
May 28, 2010 at 3:00 pm
Would you mind telling me why the code I provided a few posts back won't work for you? Still unknown to me...
May 28, 2010 at 11:51 am
Thinking about it, you probably can avoid the dynamic SQL part if you'd replace your variable with the underlying subselect (again, untested):
SELECT
A.LoweredEmail,
D.RoleName
FROM dbo.aspnet_Membership AS A WITH (NOLOCK)
INNER JOIN...
May 27, 2010 at 5:05 pm
AFAIK, the only way to get this to work is to use dynamic SQL (code snippet untested...).
DECLARE @sql NVARCHAR(4000)
SET @sql='
SELECT
A.LoweredEmail,
D.RoleName
FROM dbo.aspnet_Membership AS A WITH (NOLOCK)
INNER JOIN dbo.aspnet_Users AS...
May 27, 2010 at 4:35 pm
raafi.shaafi (5/27/2010)
The only Input I have is Column1.
Then you'd need to use the value of Column2 as a fixed value, since there is no other way to exclude Column0(0). Well,...
May 27, 2010 at 3:28 pm
The following two threads might help you to understand the usage of FOR XML as well as STUFF:
http://www.sqlservercentral.com/Forums/FindPost679589.aspx
and
http://www.sqlservercentral.com/Forums/FindPost873866.aspx
The former has some sample code that should help you understand the...
May 27, 2010 at 3:22 pm
SELECT * FROM YourTable
WHERE Column1 <> 'abc' OR (Column1 = 'abc' AND Column2='U')
or
SELECT * FROM YourTable
EXCEPT
SELECT * FROM YourTable
WHERE Column1 = 'abc' AND Column2<>'U'
May 27, 2010 at 3:13 pm
If you want to get your results in one column rather than pivoted you could use the FOR XML "trick":
SELECT
ID, NAME,
STUFF((SELECT ', ' + Orders FROM YourTable t2 WHERE t2.ID...
May 27, 2010 at 2:07 pm
Viewing 15 posts - 3,406 through 3,420 (of 5,504 total)