Viewing 15 posts - 241 through 255 (of 369 total)
Your procedure design is completely flawed. Do not build large "UNION ALL", but instead put required data into (temp) tables,
and then use one simple INSERT command that joins your prepared...
March 14, 2012 at 7:23 am
Main problem here is that we do not have something to group on for one sequence of First, Middle, and Final.
To solve that, I introduced a derived column that searches...
March 14, 2012 at 7:04 am
Since you don't know exact number of columns in a result, you need dynamic pivot.
Something like this:
http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx
but use QUOTENAME() function.
If you need working example, post a script that creates data...
March 13, 2012 at 4:51 pm
Security is a science "per se", and there is nothing 100% secure.
But, for your optimal/reasonable security needs probably you can do a few steps:
- upgrade to SQL2008R2 and latest Service...
March 11, 2012 at 6:25 pm
Your query contains no linked server, therefore I conclude it is pure oracle query, nothing to do with sql server, at least for now.
You could try to use a hint,...
March 11, 2012 at 5:59 pm
If you have multiple records with the same value of number, cashdate and cashamt
in your arcashha table, you will sum only one of that rows.
I believe this is not desired...
March 8, 2012 at 6:56 pm
Use FULL JOIN if you want to check both directions at the same time.
March 8, 2012 at 6:48 pm
Look at the CONVERT function in the documentation and various formats, and then take a SUBSTRING after conversion to varchar.
Other approach would be without conversion to varchar, staying in the...
March 8, 2012 at 6:46 pm
You can use something like this:
RAISERROR('This is a test', 16, 1)
Third parameter is any number you choose, from 0 to 255.
Second parameter:
>=16 then is error.
<=10 and below - informational message.
You...
March 7, 2012 at 8:01 am
You can do that like this:
-- Input: @DistrictId or @RegionId, @startDate, @endDate
SELECT o.RegionId, o.ItemId, SUM(o.Quantity)
FROM dbo.Orders o
JOIN dbo.Items i ON i.ItemId=o.ItemId
JOIN dbo.RegionDistricts rd ON rd.RegionId = o.RegionId
WHERE o.RequestedDate BETWEEN @startDate...
March 7, 2012 at 7:30 am
You can user ROW_NUMBER() OVER() trick:
--=== Prepare data
IF OBJECT_ID('tempdb..#history') IS NOT NULL drop table #history
CREATE TABLE #history
(HistoryId int IDENTITY PRIMARY KEY,
ItemId int NOT NULL, -- FOREIGN KEY to item this...
March 7, 2012 at 7:15 am
You can use XDetails Addin to see included columns and other details:

March 7, 2012 at 6:49 am
Problem is that dynamic queries (exec, sp_execute) or any procedure call are not allowed in functions.
You could build your xml without "for xml" - directly as string, then convert the...
March 2, 2012 at 6:45 am
Instead of:
<category t1="Rifle Parts" />
<category t2="Sights" />
<category t3="Front Sights" />
This would probably make more sense:
<category t1="Rifle Parts" t2="Sights" t3="Front Sights" />
You can achieve this by PIVOT-ing data and then converting...
March 2, 2012 at 2:19 am
Syntax is almost the same as for SELECT.
So, if you have a select:
--update t1 set t1.id=t2.somecolumn
--select *
from table1 t1
join table2 t2 on t1.id=t2.id
where t2.desc='solution'
Just uncomment the line with "select",...
March 2, 2012 at 2:16 am
Viewing 15 posts - 241 through 255 (of 369 total)