Viewing 15 posts - 5,851 through 5,865 (of 6,036 total)
It's recommended to open BOL time to time (press F1)
This example uses two SELECT statements to demonstrate the difference between rounding and truncation. The first statement...
November 8, 2005 at 1:55 pm
declare @Andy nvarchar(50)
select @Andy = 'andy' + char(13) + ' '
SELECT charindex(' ', @Andy)
result: 6
Gives an idea?
November 8, 2005 at 1:51 pm
Add Versions to select:
INNER JOIN (select StoreId, CompanyId, MAX(Active) as Active, MIN(Version) as Version from Karts group by StoreId, CompanyId) Karts ON Stores.StoreID = Karts.StoreID AND Stores.CompanyID = Karts.CompanyID
By "wrong table"...
November 7, 2005 at 6:36 pm
Seems your status column is placed into wrong table.
But anyway try to replace
INNER JOIN Karts ON Stores.StoreID = Karts.StoreID AND Stores.CompanyID = Karts.CompanyID
with
INNER JOIN (select distinct StoreId, CompanyId, Active...
November 7, 2005 at 5:29 pm
Say you have 2 tables in both databases:
Create table thing (
Id int IDENTITY(1,1),
Name nvarchar(50) NOT NULL,
typeId int NOT NULL)
Create Table ThingType (
Id int Identity (1,1),
Name...
November 7, 2005 at 4:53 pm
If Version id itd datatype, use this:
ORDER BY Karts.Active * Version
Is version is varchar,
ORDER BY case when Karts.Active = 1 then Version else '0' end
November 7, 2005 at 4:32 pm
CREATE VIEW dbo.TransView
AS
SELECT T1.Col2 as VC1, T1.Col3 as VC2, T2.Col1 as VC3, T2.Col2 as VC4
FROM Table1 T1
INNER JOIN Table2 T2 on T1.Col3 = T2.Col1
GO
-- Say Col1 in Table1...
November 7, 2005 at 3:52 pm
Create a view on your 2 tables to repeat schema of the table you are going to import data from.
Create trigger "INSTEAD OF INSERT" on this view.
Within a trigger you...
November 7, 2005 at 2:56 pm
You cannot use function call as a parameter for anither function. It's wrong syntax.
DECLARE @String varchar(100)
SELECT @String =dbo.getSOs(121616)
SELECT * FROM dbo.SplitToInt(@String,';')
November 7, 2005 at 2:44 pm
(@@Datefirst + DATEPART(WEEKDAY, @AnyDate) )%7
is constant for any DATEFIRST set up.
For Mon it's 2, fot Tue it's 3, etc.
Use it to get rid of DATEFIRST dependency.
If you use
(@@Datefirst...
November 7, 2005 at 2:36 pm
SELECT ...
FROM MyTable
WHERE LastUpdated between dateadd(n, -2, GETDATE()) and GETDATE()
November 7, 2005 at 2:21 pm
Sorry, because you have [Description] in resultset it will always being used for ordering. It was long discussion about year ago about ANSI and implementation of its prescriptions by Microsoft.
Good...
November 6, 2005 at 3:16 pm
Do not specify prefix in ORDER BY clause.
SELECT f.[Id],
[Description] = CASE
WHEN b.[Description] IS NOT NULL THEN b.[Description]
ELSE f.[Description]
END,
[Foo_Description] = f.[Description]
FROM [dbo].[Foo] AS f
LEFT OUTER JOIN...
November 6, 2005 at 2:48 pm
midan1, your problem you are playing with varchars where it must be datetime.
If period from 16:00 to 20:00 is something to be hardcoded?
I don't think so. So, store it in...
November 6, 2005 at 1:36 am
SELECT *
INTO ...
FROM ...
There is F1 key on your keyboard. It calls BOL. It's really useful in case of syntax questions.
November 4, 2005 at 6:58 am
Viewing 15 posts - 5,851 through 5,865 (of 6,036 total)