Showing posts with label operations. Show all posts
Showing posts with label operations. Show all posts

Sunday, February 19, 2012

Array in SQL Server

How would one implement an array in SQL Server ?
Specically, i'm parsing a field into the array, and doing operations on these elements.
Thanks.use a temp table instead?|||You can't...

BUT! If you buy Ken Henderson's book:

"The Guru's Guide to SQL Server Stored Procedures, XML, and HTLM"

Chapter 26 discusses how to fake it out...

http://www.sqlteam.com/store.asp|||come on brett .. why dont you share your knowledge ...

and btw ... i am desperately trying to secure a copy of that book|||Originally posted by Enigma
come on brett .. why dont you share your knowledge ...

and btw ... i am desperately trying to secure a copy of that book

I never did it...had no need, and with table variables it's a breeze...

BUT...I should play with it, just from a learning experience (always move forward, no?)

It entails creating and registering dll's and the like...

I think all the ciode is on the cd that come with the book...

and if you don't have this book, you should by it now, and read it cover to cover...sleep with it...take it out to a hockey game...whatever...

just get it

There are like 6 array function that Ken builds...they let you create, set, get, list, determine the length and destroy the array

He does make mention that you have to be careful...failing to destroy the array will make memory unavailable to the server...

Monday, February 13, 2012

arithmetic operations with money and real

Hallo,
as far as I remember the result of an arithmetic operation
in SQL Server 2000 is implicitly casted to the higher ranked
data type.
In SQL Server 7.0 real is higher than money so that every
multiplication or divison of a money and real value is real.
I think this is valid for SQL Server 2000 too.
My new project includes some very high money values and I
have a lot of multiplications (percentage up to 100) and
divisions (by rates of exchange).
So is it a good idea to cast explicitly every real value to
a money value in arithmetic operations like?
Klaus
www.trappdata.dehi,
you must be aware that when you do something with real datatype, in some
cases you may loose precision. even if it is a cent, it may matter to
someone.
peter
"Klaus Trapp" <Klaus.Trapp@.gmx.de> wrote in message
news:uKnj9hFSGHA.1780@.TK2MSFTNGP12.phx.gbl...
> Hallo,
> as far as I remember the result of an arithmetic operation
> in SQL Server 2000 is implicitly casted to the higher ranked
> data type.
> In SQL Server 7.0 real is higher than money so that every
> multiplication or divison of a money and real value is real.
> I think this is valid for SQL Server 2000 too.
> My new project includes some very high money values and I
> have a lot of multiplications (percentage up to 100) and
> divisions (by rates of exchange).
> So is it a good idea to cast explicitly every real value to
> a money value in arithmetic operations like?
>
> Klaus
> www.trappdata.de|||Klaus,
Money and real?. This is not a good combination because real is an
approximate number.
See is this can help.
monney vs numeric
http://groups.google.com/group/micr...r />
t=0&num=3
AMB
"Klaus Trapp" wrote:

> Hallo,
> as far as I remember the result of an arithmetic operation
> in SQL Server 2000 is implicitly casted to the higher ranked
> data type.
> In SQL Server 7.0 real is higher than money so that every
> multiplication or divison of a money and real value is real.
> I think this is valid for SQL Server 2000 too.
> My new project includes some very high money values and I
> have a lot of multiplications (percentage up to 100) and
> divisions (by rates of exchange).
> So is it a good idea to cast explicitly every real value to
> a money value in arithmetic operations like?
>
> Klaus
> www.trappdata.de
>

Sunday, February 12, 2012

Are there any MS SQL operations that are not transactional ?

I pretty new to MS SQL.
Long ago I heard that some MS SQL data definition operations are not
transactional.
Executed in the transaction's boundaries their results persists even if
transaction rolls back.
Could anyone ellaborat on that subject ?
Thank you.Table variables are non-transaction, that is to say, they aren't affected by
transaction scope - there is still logging on the transaction log.
declare @.tb table ( mycol int )
insert @.tb values( 1 )
begin tran
update @.tb set mycol = mycol + 1
rollback tran
select * from @.tb
The above returns 2, if you use a temporary table or permanent table you
will get 1...
create table #tb ( mycol int )
insert #tb values( 1 )
begin tran
update #tb set mycol = mycol + 1
rollback tran
select * from #tb
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"Marek" <nospam@.nowhere.com> wrote in message
news:e2n$QpL0FHA.3780@.TK2MSFTNGP12.phx.gbl...
>I pretty new to MS SQL.
> Long ago I heard that some MS SQL data definition operations are not
> transactional.
> Executed in the transaction's boundaries their results persists even if
> transaction rolls back.
> Could anyone ellaborat on that subject ?
> Thank you.
>|||TRUNCATE table.
"Marek" <nospam@.nowhere.com> wrote in message
news:e2n$QpL0FHA.3780@.TK2MSFTNGP12.phx.gbl...
>I pretty new to MS SQL.
> Long ago I heard that some MS SQL data definition operations are not
> transactional.
> Executed in the transaction's boundaries their results persists even if
> transaction rolls back.
> Could anyone ellaborat on that subject ?
> Thank you.
>|||That's incorrect. TRUNCATE participates in a transaction like any other
DML operation (table variables excepted).
David Portas
SQL Server MVP
--|||> TRUNCATE table.
?
CREATE TABLE MyTable(Col1 int NOT NULL)
INSERT INTO MyTable VALUES(1)
BEGIN TRAN
TRUNCATE TABLE MyTable
ROLLBACK
SELECT Col1 FROM MyTable
DROP TABLE MyTable
Hope this helps.
Dan Guzman
SQL Server MVP
"JT" <someone@.microsoft.com> wrote in message
news:%23LIQ8RM0FHA.1192@.TK2MSFTNGP10.phx.gbl...
> TRUNCATE table.
> "Marek" <nospam@.nowhere.com> wrote in message
> news:e2n$QpL0FHA.3780@.TK2MSFTNGP12.phx.gbl...
>|||You can have non transaction DDL inside a transaction if you use xp_cmdshell
and osql to execute the DDL. Extended stored procedures are not included in
a transaction. But if you are looking for a bug or "feature" where plain DDL
(table variables excepted as mentioned in the other posts) is not
transactional, there is none I am aware of in SQL Server 2000, although
there might have been in long ago versions like 6.0 or 6.5.
Jacco Schalkwijk
SQL Server MVP
"Marek" <nospam@.nowhere.com> wrote in message
news:e2n$QpL0FHA.3780@.TK2MSFTNGP12.phx.gbl...
>I pretty new to MS SQL.
> Long ago I heard that some MS SQL data definition operations are not
> transactional.
> Executed in the transaction's boundaries their results persists even if
> transaction rolls back.
> Could anyone ellaborat on that subject ?
> Thank you.
>|||I stand corrected.
"JT" <someone@.microsoft.com> wrote in message
news:%23LIQ8RM0FHA.1192@.TK2MSFTNGP10.phx.gbl...
> TRUNCATE table.
> "Marek" <nospam@.nowhere.com> wrote in message
> news:e2n$QpL0FHA.3780@.TK2MSFTNGP12.phx.gbl...
>