Viewing 15 posts - 9,421 through 9,435 (of 10,143 total)
Jeff Moden (11/14/2008)
SELECT COUNT(*) FROM Master.dbo.SysColumns
If it doesn't work, there are one of two problems... either you don't have the privs to read from the master database (very...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 17, 2008 at 3:09 am
You don't really need dynamic SQL for this. Try the following as your WHERE clause:
WHERE M.DateTransactionDue >= '01/01/1900' AND M.DateTransactionDue <= @AllocationEndDate) AND M.TransactionTypeID = 1
AND M.SalesOrderID = CASE WHEN...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 14, 2008 at 9:08 am
Or ISNULL:
CREATE TABLE #Orders (orderid INT, shipto VARCHAR(3), locationid VARCHAR(3))
INSERT INTO #Orders (orderid, shipto, locationid)
SELECT 1, 'acf', 'fcd' UNION ALL
SELECT 2, NULL, 'acf' UNION ALL
SELECT 3, 'dre', 'acf'
CREATE TABLE...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 14, 2008 at 9:01 am
So what happens if there are several pairs of brackets, some with numbers in?
This picks the string between the first pair of brackets and grabs the numbers from it, but...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 14, 2008 at 8:37 am
Dooza (11/14/2008)
I prefer Chris's solution, it returns the decimal just like I needed 😀
Seth's is almost identical identical apart from the datatype of the return value. He did what you...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 14, 2008 at 8:01 am
Garadin, that's uncanny! I was working on this earlier and came up with the following:
CREATE FUNCTION [dbo].[uftGetNumbersInBrackets]
(
@String VARCHAR(50)
)
RETURNS DECIMAL (10,2)
AS
BEGIN
DECLARE @NewString VARCHAR(50)
SET...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 14, 2008 at 7:44 am
asaacks (11/13/2008)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 13, 2008 at 4:14 am
A LEFT JOIN is often faster than a NOT IN...
[font="Courier New"]SELECT p.PartNum,
p.PartDescription,
b.BinNum,
b.OnHandQty,
c.Cost,
b.OnHandQty * c.Cost AS ExtCost
FROM @Part p
INNER JOIN @Cost c ON p.PartNum=c.PartNum
INNER JOIN @Bin b ON...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 12, 2008 at 9:48 am
meichner (11/10/2008)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 10, 2008 at 7:25 am
Johann Montfort (11/10/2008)
working excellently nowbut in the where clause why just
WHERE p.Deleted = 0
If you have branches.deleted = 0 in the WHERE clause, then your output will have exactly...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 10, 2008 at 4:57 am
Hi Johann
Your problem was almost certainly caused by including the deleted filters in your where clause. Put them into the join conditions instead:
[font="Courier New"]SELECT TOP (100) PERCENT
ISNULL(p.productID, 0)...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 10, 2008 at 4:38 am
Hello
Try using proper join syntax, it will help to understand what's going on and will also give you a better insight into your data:
-- this will return all rows from...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 10, 2008 at 3:40 am
smunson (11/6/2008)
You might want to make mention that your function relies on a "tally table" called "Numbers", as the OP here may or may not be familiar with that or...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 6, 2008 at 9:39 am
Use a function to return the list as a table variable:
[font="Courier New"]CREATE FUNCTION [dbo].[uftSplitString]
(
@String VARCHAR(8000),
@Delimiter VARCHAR(255)
)
RETURNS
@Results TABLE
(
SeqNo INT IDENTITY(1, 1),
Item VARCHAR(8000)...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 6, 2008 at 9:17 am
Try this...
EXEC (@cSQL)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 5, 2008 at 8:50 am
Viewing 15 posts - 9,421 through 9,435 (of 10,143 total)