Viewing 15 posts - 2,116 through 2,130 (of 2,458 total)
rightontarget (9/25/2013)
Here is what I need to run, but the output is truncated:
drop table A;
CREATE TABLE A(
[col_1] [nvarchar](30) NOT NULL,
[col_2] [varchar](256) NULL,
[col_3] [varchar](max) NULL,
[col_4] [varchar](max)...
-- Itzik Ben-Gan 2001
September 25, 2013 at 1:52 pm
In SSMS you can right-click on the job, select "Script Job as" > "Create to" > ("Query Window" or "File"). This will produce the DDL to create each job. I...
-- Itzik Ben-Gan 2001
September 25, 2013 at 1:46 pm
FYI, the sample ddl you provided had an error
I think insert into A (col_1, col_2, col_3)
should really be insert into A (col_1, col_2, col_3, col4)
All that said, No truncation, simple...
-- Itzik Ben-Gan 2001
September 25, 2013 at 1:25 pm
This is the way that I would do it.
--Your Data
WITH your_table AS
(SELECT * FROM
(VALUES
(12402223,171906,'Quality And Reliability Engineering',1,4),
(12402223,171906,'Quality And Reliability Engineering',2,10),
(12402223,171906,'Quality And Reliability Engineering',3,11),
(12402223,171906,'Quality And Reliability Engineering',4,5),
(12402223,171906,'Quality And...
-- Itzik Ben-Gan 2001
September 25, 2013 at 1:13 pm
OPTION 1
The down and dirty way (not recommended) would be to set the column visibility based on an expression like so:
=User!UserID <> "Manager #1" AND User!UserID <> "Manager #2"
OPTION 2
1)...
-- Itzik Ben-Gan 2001
September 19, 2013 at 1:33 pm
Am I going to be reduced to coding up something to list each column, its datatype, FK relationships, etc, then running it against the current and previous DB and eyeballing...
-- Itzik Ben-Gan 2001
September 19, 2013 at 10:40 am
If not for the un-closed <OrderID> tag you would have a well-formed fragment that you could query via XPath. What Scott and Sean included will be better for your requirement....
-- Itzik Ben-Gan 2001
September 18, 2013 at 10:38 am
I would add that it is good that you are on SQL Server Central. Use this site; it's a great resource! Ask questions, read through the forums and the articles....
-- Itzik Ben-Gan 2001
September 17, 2013 at 11:28 am
Well done Magoo; I knew there was a much better way but drew a blank.
Jeff Moden (9/16/2013)
-- Itzik Ben-Gan 2001
September 17, 2013 at 8:56 am
This could still be optimized but will perform a little better than my previous query:
--OUTPUT
SELECT e.MSKEY AS NUMBER,
ISNULL(fn.AVALUE,'') AS FNAME,
ISNULL(mn.AVALUE,'') AS MNAME,
ISNULL(ln.AVALUE,'') AS LNAME,
ISNULL(em.AVALUE,'') AS EMAIL
FROM Entries e
LEFT JOIN Entries...
-- Itzik Ben-Gan 2001
September 16, 2013 at 4:54 pm
Below is some DDL and a solution:
--DDL
USE tempdb
IF OBJECT_ID('tempdb..Entries') IS NOT NULL DROP TABLE Entries;
CREATE TABLE Entries (MSKEY int, ATTRNAME varchar(20), AVALUE varchar(20), primary key (MSKEY, ATTRNAME));
INSERT Entries (MSKEY,...
-- Itzik Ben-Gan 2001
September 16, 2013 at 4:05 pm
Sean Lange (9/12/2013)
select SUM(Case when MyType = 2 then -1 * MyHours else MyHours end) as TotalHours
from #SomeTable
If I understand the original OP correctly (" If something has been credited,...
-- Itzik Ben-Gan 2001
September 12, 2013 at 9:57 am
Using the sample code above, I believe this will do the trick:
WITH billed_credited AS
(
SELECT CaseNum, MyHours, COUNT(MyHours) AS bc
FROM #SomeTable
GROUP by CaseNum, MyHours
)
SELECT SUM(x.Myhours) TotalHours
FROM #sometable st
CROSS APPLY...
-- Itzik Ben-Gan 2001
September 12, 2013 at 9:34 am
This is hard without DDL but assuming you cannot have this:
Case | Hours | Type
xxx | 3 | 1
xxx | 3 | 1
Or this:
Case | Hours | Type
xxx | 3...
-- Itzik Ben-Gan 2001
September 12, 2013 at 8:38 am
You should still be able to use UNION ALL in that scenario. Below is some code to create sample data similar to what I think you are dealing with. ...
-- Itzik Ben-Gan 2001
September 10, 2013 at 4:40 pm
Viewing 15 posts - 2,116 through 2,130 (of 2,458 total)