Wednesday, March 28, 2012
Increase columns width of merge replicated table
Any suggession highly appreciated by us.
ThanksI have only been able to accomplish this by copying out the data and the rowguid for each record, sp_repldropcolumn the old column, sp_repladdcolumn'ing it back in, and copying the data back in. (might not have sproc names exactly right)
I remember reading about a builtin sproc that you could execute that would run certain commands on a database or table that was in replication, but I can't find it's name, and I don't know it's limitations.
Friday, March 23, 2012
Incorrect syntax near '='
I'm using multiple select statements in MS-Access with logical
expressions like (ID=10)*50 instead of an if statement. In this manner
i'm able to get the same results as with if statements (if ID=10 then
result=50) only faster (in MS-Access that is).
when trying to get the same sql statement running in SQL-server I
receive an Incorrect syntax near '=' error message.
Are there any solutions? I will try to avoid updating all queries
because MS-Access will also be used as backend next to a version for
SQL-server backend.
Maybe anyone can help me.You can use CASE statement
SELECT result =
CASE WHEN ID = 10 THEN 50
ELSE something END
"Niels Verkaart" wrote:
> Hi,
> I'm using multiple select statements in MS-Access with logical
> expressions like (ID=10)*50 instead of an if statement. In this manner
> i'm able to get the same results as with if statements (if ID=10 then
> result=50) only faster (in MS-Access that is).
> when trying to get the same sql statement running in SQL-server I
> receive an Incorrect syntax near '=' error message.
> Are there any solutions? I will try to avoid updating all queries
> because MS-Access will also be used as backend next to a version for
> SQL-server backend.
> Maybe anyone can help me.
>|||Thank you Jack,
now I only have to write a clever function to convert dynamic queries
like:
INSERT INTO _CalcAfzet_2394 ( ID, K001, K002, K003, K004 ) SELECT
VerkoopsoortID,Sum(-(Year([Datum])=2006)*[Aantal]),Sum(-(Year([Datum])=2
007)*[Aantal]),Sum(-(Year([Datum])=2008)*[Aantal]),Sum(-(Year([Datum])=2
009)*[Aantal]) FROM CalcAfzetPeriode WHERE CalcID=1528 AND
VerkoopsoortID NOT IN (0) GROUP BY VerkoopsoortID
That's a nice little problem for me. but i'll get there.
> You can use CASE statement
> SELECT result =
> CASE WHEN ID = 10 THEN 50
> ELSE something END
> "Niels Verkaart" wrote:
>|||Hi Niels,
This is a typical crosstab (FAQ). The solution is basically the same as
what Jack has posted:
INSERT INTO _CalcAfzet_2394 ( ID, K001, K002, K003, K004 )
SELECT VerkoopsoortID
, SUM(CASE Year(Datum) WHEN 2006 THEN Aantal END)
, SUM(CASE Year(Datum) WHEN 2007 THEN Aantal END)
, SUM(CASE Year(Datum) WHEN 2008 THEN Aantal END)
, SUM(CASE Year(Datum) WHEN 2009 THEN Aantal END)
FROM CalcAfzetPeriode
WHERE CalcID=1528
AND VerkoopsoortID NOT IN (0)
GROUP BY VerkoopsoortID
HTH,
Gert-Jan
Niels Verkaart wrote:
> Thank you Jack,
> now I only have to write a clever function to convert dynamic queries
> like:
> INSERT INTO _CalcAfzet_2394 ( ID, K001, K002, K003, K004 ) SELECT
> VerkoopsoortID,Sum(-(Year([Datum])=2006)*[Aantal]),Sum(-(Year([Datum])=2
> 007)*[Aantal]),Sum(-(Year([Datum])=2008)*[Aantal]),Sum(-(Year([Datum])=2
> 009)*[Aantal]) FROM CalcAfzetPeriode WHERE CalcID=1528 AND
> VerkoopsoortID NOT IN (0) GROUP BY VerkoopsoortID
> That's a nice little problem for me. but i'll get there.
>|||Great Gert-Jan,
thank you both Gert-Jan and Jack!
Gert-Jan Strik wrote:
> Hi Niels,
> This is a typical crosstab (FAQ). The solution is basically the same
> as what Jack has posted:
> INSERT INTO _CalcAfzet_2394 ( ID, K001, K002, K003, K004 )
> SELECT VerkoopsoortID
> , SUM(CASE Year(Datum) WHEN 2006 THEN Aantal END)
> , SUM(CASE Year(Datum) WHEN 2007 THEN Aantal END)
> , SUM(CASE Year(Datum) WHEN 2008 THEN Aantal END)
> , SUM(CASE Year(Datum) WHEN 2009 THEN Aantal END)
> FROM CalcAfzetPeriode
> WHERE CalcID=1528
> AND VerkoopsoortID NOT IN (0)
> GROUP BY VerkoopsoortID
> HTH,
> Gert-Jan
>
> Niels Verkaart wrote:
Monday, March 12, 2012
Inconsistent sort order using ORDER BY clause
Product: Microsoft SQL Server Express Edition
Version: 9.00.1399.06
Server Collation: SQL_Latin1_General_CP1_CI_AS
for example,
create table test_sort
( description varchar(75) );
insert into test_sort values('Non-A');
insert into test_sort values('Non-O');
insert into test_sort values('Noni');
insert into test_sort values('Nons');
then execute the following selects:
select
*
from
test_sort
order by
cast( 1 as nvarchar(75));
select
*
from
test_sort
order by
cast( description as nvarchar(75));
Resultset1
-
Non-A
Non-O
Noni
Nons
Resultset2
-
Non-A
Noni
Non-O
Nons
Any ideas?As far as i figured your query out, i am just wondering why this works for you as the 1 will be casted to a constant string which should not be allowed in the order by clause. Are you sure this works for you ?
Jens K. Suessmeyer.
http://www.sqlserver2005.de|||First, you are running the release version of 2005. You should install at least SP1.
Second, if you install SP1, you would see an error:
Msg 408, Level 16, State 1, Line 9
A constant expression was encountered in the ORDER BY list, position 1.
Because you are sorting by the NUMBER 1, not column 1 by using the cast. So basically you have no sort.