Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Sunday, March 25, 2012

Cursor for

Hi,

Declare wh_ctry_id CURSOR FOR

Is "cursor for" is a function or datatype or what is this?

Regards

Abdul

According to the MSDN documentation...

Microsoft SQL Server statements produce a complete result set, butthere are times when the results are best processed one row at a time.Opening a cursor on a result set allows processing the result set onerow at a time. You can assign a cursor to a variable or parameter withacursor data type.

... a cursor is sort of result set within SQL Server.

|||

To know about the Cursors, check out the links given below:

http://www.databasejournal.com/features/mssql/article.php/1439731

http://www.teratrax.com/articles/sql_server_cursor.html

http://www.sqlteam.com/article/cursors-an-overview

|||

Hello Abdul,

The CURSOR FOR declaration is part of T-SQL. See:http://msdn2.microsoft.com/en-us/library/aa258831(SQL.80).aspx

You can use a cursor for looping over a number of records to perform certain actions in a stored procedure.

Jeroen Molenaar.

Thursday, March 22, 2012

cursor + rounding?

Hi Guys,

I've created a cursor inside a function. When I break it down and execute the code piece by piece, no problem. However, try and parse it together and I get an error - 'Mixing old and new syntax is not allowed?' Something to do with the return statements? as I can alter the function to a procedure and it parses fine. Anyone come across this before?

Also, the values are being rounded when putting them into the cursor, even though I've declared the variables the cursor uses specifically as decimal? How can I get around this please?

Cheers,

Michelle

Michelle:

Can you describe what you are doing? This sounds rather vague.

|||

Blast, it didn't post. Umm, I've sorted the first problem, and I think I may have the answer to the second one. Will give it a go and let you know. Thanks for your help!

Cheers,

Michelle

|||

OK, both of those problems fixed. Should have been

DECLARE product_cursor CURSOR local SCROLL

NOT

DECLARE product_cursor SCROLL CURSOR

and Should have been:

decimal(8,2)

NOT

decimal.

Stupid mistakes! However, now I'm able to parse it fine, but am getting:

Msg 443, Level 16, State 15, Procedure CalculateFreight, Line 15

Invalid use of side-effecting or time-dependent operator in 'SELECT INTO' within a function.

Msg 443, Level 16, State 15, Procedure CalculateFreight, Line 25

Invalid use of side-effecting or time-dependent operator in 'UPDATE' within a function.

when I execute it!?

The SELECT INTO and UPDATE statements are fine when executed alone

Michelle

sql

CURRENT_USER issue

I've inherited Database for a Web Application (with no support) that
makes heavy use of the following function, at least in the report views
that have been defined:
ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
RETURNS bit
AS
BEGIN
DECLARE @.UserId int
SET @.UserId = CAST(CURRENT_USER AS int)
DECLARE @.SysAdmin bit
SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
-- Returns 1 if SysAdmin, 0 if normal user
RETURN @.SysAdmin
END
If you use the web application, everything runs fine.
If you try to access the report view from with SQL Management Studio, I
receive an error about not being able to convert an NVARCHAR ('dbo') to
an INT on the CAST operation above.
I understand what the above function is trying to do, but when I execute
'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
the result. Somehow, when this function is called from the Web
Application, it returns a 'username' defined in the dbo.Users table that
gets converted to an INT, which is supposed to be the exact value stored
in the UserID column for that particular record.
Sample user record:
UserID = 10001
Username = john.doe@.example.com
SystemAdministrator = 1 (true)
The function should return true in this instance, but I don't know how
that would be possible. It doesn't seem like the function should work at
all.
Any help would be greatly appreciated.
-={ Kyle K. }=-
Hi,
Instead of Current_user, can you please use function SYSTEM_USER.
Please write back if it works.
Thanks
Hari
SQL Server MVP
"Kyle K." wrote:

> I've inherited Database for a Web Application (with no support) that
> makes heavy use of the following function, at least in the report views
> that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I
> receive an error about not being able to convert an NVARCHAR ('dbo') to
> an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute
> 'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
> the result. Somehow, when this function is called from the Web
> Application, it returns a 'username' defined in the dbo.Users table that
> gets converted to an INT, which is supposed to be the exact value stored
> in the UserID column for that particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how
> that would be possible. It doesn't seem like the function should work at
> all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-
>
|||My guess is that you do have users in your database named in a way so the names can be converted to
int. You can see what usernames exists in the database thought the sys.database_principals catalog
view. If my assumption is correct, they written a pretty crappy function, which need to be fixed.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Kyle K." <SKyleK@.Frontiernet.net> wrote in message news:55_Ng.498$Ka1.99@.news01.roc.ny...
> I've inherited Database for a Web Application (with no support) that makes heavy use of the
> following function, at least in the report views that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I receive an error about not
> being able to convert an NVARCHAR ('dbo') to an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute 'SELECT CURRENT_USER'
> from within SQL Management Studio, I get 'dbo' as the result. Somehow, when this function is
> called from the Web Application, it returns a 'username' defined in the dbo.Users table that gets
> converted to an INT, which is supposed to be the exact value stored in the UserID column for that
> particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how that would be possible. It
> doesn't seem like the function should work at all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-

CURRENT_USER issue

I've inherited Database for a Web Application (with no support) that
makes heavy use of the following function, at least in the report views
that have been defined:
ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
RETURNS bit
AS
BEGIN
DECLARE @.UserId int
SET @.UserId = CAST(CURRENT_USER AS int)
DECLARE @.SysAdmin bit
SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
-- Returns 1 if SysAdmin, 0 if normal user
RETURN @.SysAdmin
END
If you use the web application, everything runs fine.
If you try to access the report view from with SQL Management Studio, I
receive an error about not being able to convert an NVARCHAR ('dbo') to
an INT on the CAST operation above.
I understand what the above function is trying to do, but when I execute
'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
the result. Somehow, when this function is called from the Web
Application, it returns a 'username' defined in the dbo.Users table that
gets converted to an INT, which is supposed to be the exact value stored
in the UserID column for that particular record.
Sample user record:
UserID = 10001
Username = john.doe@.example.com
SystemAdministrator = 1 (true)
The function should return true in this instance, but I don't know how
that would be possible. It doesn't seem like the function should work at
all.
Any help would be greatly appreciated.
-={ Kyle K. }=-Hi,
Instead of Current_user, can you please use function SYSTEM_USER.
Please write back if it works.
Thanks
Hari
SQL Server MVP
"Kyle K." wrote:
> I've inherited Database for a Web Application (with no support) that
> makes heavy use of the following function, at least in the report views
> that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I
> receive an error about not being able to convert an NVARCHAR ('dbo') to
> an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute
> 'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
> the result. Somehow, when this function is called from the Web
> Application, it returns a 'username' defined in the dbo.Users table that
> gets converted to an INT, which is supposed to be the exact value stored
> in the UserID column for that particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how
> that would be possible. It doesn't seem like the function should work at
> all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-
>|||My guess is that you do have users in your database named in a way so the names can be converted to
int. You can see what usernames exists in the database thought the sys.database_principals catalog
view. If my assumption is correct, they written a pretty crappy function, which need to be fixed.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Kyle K." <SKyleK@.Frontiernet.net> wrote in message news:55_Ng.498$Ka1.99@.news01.roc.ny...
> I've inherited Database for a Web Application (with no support) that makes heavy use of the
> following function, at least in the report views that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I receive an error about not
> being able to convert an NVARCHAR ('dbo') to an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute 'SELECT CURRENT_USER'
> from within SQL Management Studio, I get 'dbo' as the result. Somehow, when this function is
> called from the Web Application, it returns a 'username' defined in the dbo.Users table that gets
> converted to an INT, which is supposed to be the exact value stored in the UserID column for that
> particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how that would be possible. It
> doesn't seem like the function should work at all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-

CURRENT_USER issue

I've inherited Database for a Web Application (with no support) that
makes heavy use of the following function, at least in the report views
that have been defined:
ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
RETURNS bit
AS
BEGIN
DECLARE @.UserId int
SET @.UserId = CAST(CURRENT_USER AS int)
DECLARE @.SysAdmin bit
SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
-- Returns 1 if SysAdmin, 0 if normal user
RETURN @.SysAdmin
END
If you use the web application, everything runs fine.
If you try to access the report view from with SQL Management Studio, I
receive an error about not being able to convert an NVARCHAR ('dbo') to
an INT on the CAST operation above.
I understand what the above function is trying to do, but when I execute
'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
the result. Somehow, when this function is called from the Web
Application, it returns a 'username' defined in the dbo.Users table that
gets converted to an INT, which is supposed to be the exact value stored
in the UserID column for that particular record.
Sample user record:
UserID = 10001
Username = john.doe@.example.com
SystemAdministrator = 1 (true)
The function should return true in this instance, but I don't know how
that would be possible. It doesn't seem like the function should work at
all.
Any help would be greatly appreciated.
-={ Kyle K. }=-Hi,
Instead of Current_user, can you please use function SYSTEM_USER.
Please write back if it works.
Thanks
Hari
SQL Server MVP
"Kyle K." wrote:

> I've inherited Database for a Web Application (with no support) that
> makes heavy use of the following function, at least in the report views
> that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I
> receive an error about not being able to convert an NVARCHAR ('dbo') to
> an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute
> 'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
> the result. Somehow, when this function is called from the Web
> Application, it returns a 'username' defined in the dbo.Users table that
> gets converted to an INT, which is supposed to be the exact value stored
> in the UserID column for that particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how
> that would be possible. It doesn't seem like the function should work at
> all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-
>|||My guess is that you do have users in your database named in a way so the na
mes can be converted to
int. You can see what usernames exists in the database thought the sys.datab
ase_principals catalog
view. If my assumption is correct, they written a pretty crappy function, wh
ich need to be fixed.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Kyle K." <SKyleK@.Frontiernet.net> wrote in message news:55_Ng.498$Ka1.99@.news01.roc.ny...[v
bcol=seagreen]
> I've inherited Database for a Web Application (with no support) that makes
heavy use of the
> following function, at least in the report views that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I re
ceive an error about not
> being able to convert an NVARCHAR ('dbo') to an INT on the CAST operation
above.
> I understand what the above function is trying to do, but when I execute '
SELECT CURRENT_USER'
> from within SQL Management Studio, I get 'dbo' as the result. Somehow, whe
n this function is
> called from the Web Application, it returns a 'username' defined in the db
o.Users table that gets
> converted to an INT, which is supposed to be the exact value stored in the
UserID column for that
> particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how tha
t would be possible. It
> doesn't seem like the function should work at all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-[/vbcol]

current_timestamp vs getdate()

Is one preferable to the other?
bol says of that current_timestamp "This function is equivalent to
GETDATE()."
Do they both exist in sql 2005? (I only have 2k)
Is one for backward compatibility?
gracias
Tom
--
E-mail correspondence to and from this address may be subject to the
North Carolina Public Records Law and may be disclosed to third parties.it exists in both ss2k and ss2k5. Yes, they are backward compatible.
--
Venkat
sql server admirer
"Tom W" wrote:
> Is one preferable to the other?
> bol says of that current_timestamp "This function is equivalent to
> GETDATE()."
> Do they both exist in sql 2005? (I only have 2k)
> Is one for backward compatibility?
> gracias
> Tom
> --
>
> E-mail correspondence to and from this address may be subject to the
> North Carolina Public Records Law and may be disclosed to third parties.
>|||Getdate() was inherited from Sybase and is not portable. Current_timestamp
was added more recently for ANSI compliance.
Both are available in SQL Server 2005 and there is no indication that
getdate() will be going away, so your choice is just whether you want
portability or not.
--
HTH
Kalen Delaney, SQL Server MVP
"Tom W" <Tom.Williams@.DontSpamMencmail.net> wrote in message
news:ewE3U9glGHA.4044@.TK2MSFTNGP03.phx.gbl...
> Is one preferable to the other?
> bol says of that current_timestamp "This function is equivalent to
> GETDATE()."
> Do they both exist in sql 2005? (I only have 2k)
> Is one for backward compatibility?
> gracias
> Tom
> --
>
> E-mail correspondence to and from this address may be subject to the
> North Carolina Public Records Law and may be disclosed to third parties.|||Hi Kalen,
Pardon my ignorance,when you say portable, what does that mean?
Thanks,
--
Venkat
sql server admirer
"Kalen Delaney" wrote:
> Getdate() was inherited from Sybase and is not portable. Current_timestamp
> was added more recently for ANSI compliance.
> Both are available in SQL Server 2005 and there is no indication that
> getdate() will be going away, so your choice is just whether you want
> portability or not.
> --
> HTH
> Kalen Delaney, SQL Server MVP
>
> "Tom W" <Tom.Williams@.DontSpamMencmail.net> wrote in message
> news:ewE3U9glGHA.4044@.TK2MSFTNGP03.phx.gbl...
> > Is one preferable to the other?
> > bol says of that current_timestamp "This function is equivalent to
> > GETDATE()."
> > Do they both exist in sql 2005? (I only have 2k)
> > Is one for backward compatibility?
> >
> > gracias
> > Tom
> >
> > --
> >
> >
> >
> > E-mail correspondence to and from this address may be subject to the
> > North Carolina Public Records Law and may be disclosed to third parties.
>
>|||Other database products may use this function in their SQL dialect.
--
HTH
Kalen Delaney, SQL Server MVP
"Venkat" <Venkat@.discussions.microsoft.com> wrote in message
news:7C16A1DB-25D9-4A18-BEEB-1285A3A2AFCB@.microsoft.com...
> Hi Kalen,
> Pardon my ignorance,when you say portable, what does that mean?
> Thanks,
> --
> Venkat
> sql server admirer
>
> "Kalen Delaney" wrote:
>> Getdate() was inherited from Sybase and is not portable.
>> Current_timestamp
>> was added more recently for ANSI compliance.
>> Both are available in SQL Server 2005 and there is no indication that
>> getdate() will be going away, so your choice is just whether you want
>> portability or not.
>> --
>> HTH
>> Kalen Delaney, SQL Server MVP
>>
>> "Tom W" <Tom.Williams@.DontSpamMencmail.net> wrote in message
>> news:ewE3U9glGHA.4044@.TK2MSFTNGP03.phx.gbl...
>> > Is one preferable to the other?
>> > bol says of that current_timestamp "This function is equivalent to
>> > GETDATE()."
>> > Do they both exist in sql 2005? (I only have 2k)
>> > Is one for backward compatibility?
>> >
>> > gracias
>> > Tom
>> >
>> > --
>> >
>> >
>> >
>> > E-mail correspondence to and from this address may be subject to the
>> > North Carolina Public Records Law and may be disclosed to third
>> > parties.
>>|||Thanks for being patient with me.
--
Venkat
sql server admirer
"Kalen Delaney" wrote:
> Other database products may use this function in their SQL dialect.
> --
> HTH
> Kalen Delaney, SQL Server MVP
>
> "Venkat" <Venkat@.discussions.microsoft.com> wrote in message
> news:7C16A1DB-25D9-4A18-BEEB-1285A3A2AFCB@.microsoft.com...
> > Hi Kalen,
> > Pardon my ignorance,when you say portable, what does that mean?
> > Thanks,
> > --
> > Venkat
> > sql server admirer
> >
> >
> > "Kalen Delaney" wrote:
> >
> >> Getdate() was inherited from Sybase and is not portable.
> >> Current_timestamp
> >> was added more recently for ANSI compliance.
> >> Both are available in SQL Server 2005 and there is no indication that
> >> getdate() will be going away, so your choice is just whether you want
> >> portability or not.
> >>
> >> --
> >> HTH
> >> Kalen Delaney, SQL Server MVP
> >>
> >>
> >> "Tom W" <Tom.Williams@.DontSpamMencmail.net> wrote in message
> >> news:ewE3U9glGHA.4044@.TK2MSFTNGP03.phx.gbl...
> >> > Is one preferable to the other?
> >> > bol says of that current_timestamp "This function is equivalent to
> >> > GETDATE()."
> >> > Do they both exist in sql 2005? (I only have 2k)
> >> > Is one for backward compatibility?
> >> >
> >> > gracias
> >> > Tom
> >> >
> >> > --
> >> >
> >> >
> >> >
> >> > E-mail correspondence to and from this address may be subject to the
> >> > North Carolina Public Records Law and may be disclosed to third
> >> > parties.
> >>
> >>
> >>
>
>sql

Current_Date function

Has any one been able to use the CURRENT_DATE function?
I'm in the middle of a very simple SQL query, and I keep
getting errors when I try and use CURRENT_DATE. Here is
my SQL QUERY:
Select * from Cal where ONDATE >= (CURRENT_DATE - 3)
Sounds simple enough but it always returns "Syntax Error
near 'CURRENT_DATE' I can't see any syntax error in the
above statement.
I'm running SQL server 2000
Use either GETDATE() or CURRENT_TIMESTAMP and convert if you just want the
date part.
You need to escape calls to CURRENT_DATE e.g
select {fn CURRENT_DATE()}
Note this returns a varchar so you need to convert to datetime
select * from orders where OrderDate < (cast({fn CURRENT_DATE()} as
datetime)-3)
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Pierre" <pmitham@.pbviews.com> wrote in message
news:085001c48479$1871ffd0$a301280a@.phx.gbl...
> Has any one been able to use the CURRENT_DATE function?
> I'm in the middle of a very simple SQL query, and I keep
> getting errors when I try and use CURRENT_DATE. Here is
> my SQL QUERY:
> Select * from Cal where ONDATE >= (CURRENT_DATE - 3)
> Sounds simple enough but it always returns "Syntax Error
> near 'CURRENT_DATE' I can't see any syntax error in the
> above statement.
> I'm running SQL server 2000
|||Wonderfuil. But that's a bit different from what MS says
the Syntax is ;-) figures.

>--Original Message--
>Use either GETDATE() or CURRENT_TIMESTAMP and convert if
you just want the
>date part.
>You need to escape calls to CURRENT_DATE e.g
>select {fn CURRENT_DATE()}
>Note this returns a varchar so you need to convert to
datetime
>select * from orders where OrderDate < (cast({fn
CURRENT_DATE()} as[vbcol=seagreen]
>datetime)-3)
>--
>HTH
>Jasper Smith (SQL Server MVP)
>http://www.sqldbatips.com
>I support PASS - the definitive, global
>community for SQL Server professionals -
>http://www.sqlpass.org
>"Pierre" <pmitham@.pbviews.com> wrote in message
>news:085001c48479$1871ffd0$a301280a@.phx.gbl...
keep
>
>.
>
|||If you can post to where MS documents the syntax you tried, we can feedback to them...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Pierre mitham" <pmitham@.pbviews.com> wrote in message
news:7e1101c48495$be2ab540$a401280a@.phx.gbl...[vbcol=seagreen]
> Wonderfuil. But that's a bit different from what MS says
> the Syntax is ;-) figures.
>
> you just want the
> datetime
> CURRENT_DATE()} as
> keep

Wednesday, March 21, 2012

current row no?

i know there is a function to count number of rows in a group, but is there anyway of numbering each row?

So that I can use =Last(ReportIems("norow") to find the last row on the page?

Thanks

Try putting this into your detail row (where GroupName is the name of your group):

=RowNumber("GroupName")

Hope this helps.

Jarret

|||Thank you SO much.... I used this to a Page no for each group ;)

current row no?

i know there is a function to count number of rows in a group, but is there anyway of numbering each row?

So that I can use =Last(ReportIems("norow") to find the last row on the page?

Thanks

Try putting this into your detail row (where GroupName is the name of your group):

=RowNumber("GroupName")

Hope this helps.

Jarret

|||Thank you SO much.... I used this to a Page no for each group ;)

Tuesday, March 20, 2012

Current Date Member

I am trying to get an specific member from the Time Dimension.

I tried the function VBA!Date() with any success.

WITH

MEMBER MEASURES.[UniqueName] AS

'[Time].[ Time].CURRENTMEMBER.UNIQUENAME'

SELECT

{MEASURES.[UniqueName]} ON COLUMNS

,Filter( [Time].[Year].ALLMEMBERS

, ([Time].[Year].CurrentMember.membervalue

= VBA!DatePart( "yyyy", VBA!Date()))

) ON ROWS

FROM [FT FIBU]

How can I get the current date?

Try and see if function VBA!Now() will work for you.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

sql

Monday, March 19, 2012

Current Database ID/Name

Hi,
How could I find the Current database name when I am Query Analyzer. Is
there any function like @.@.Servername.
--
Shanselect db_name()
Jackie
"Shan" <Shan@.discussions.microsoft.com> wrote in message
news:9E7D2FEC-B653-4C54-B2BF-D3AF2E73AC63@.microsoft.com...
> Hi,
> How could I find the Current database name when I am Query Analyzer. Is
> there any function like @.@.Servername.
> --
> Shan

Current Database ID/Name

Hi,
How could I find the Current database name when I am Query Analyzer. Is
there any function like @.@.Servername.
--
Shanselect db_name()
Jackie
"Shan" <Shan@.discussions.microsoft.com> wrote in message
news:9E7D2FEC-B653-4C54-B2BF-D3AF2E73AC63@.microsoft.com...
> Hi,
> How could I find the Current database name when I am Query Analyzer. Is
> there any function like @.@.Servername.
> --
> Shan

Sunday, March 11, 2012

Currency

hi,
i would like to write a sql function which takes 3 parameters.
1. Source currency type
2. destination currency type
3. Amount to be converted
I need the dynamic rates.
Does anybody hav any idea about how to go with this.
Thanks in advance,
Vinu
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1Are you using SQL Server 2005 ? Therefore you could use Webservices to
call an currency service synchronously or async. by storing the data
in a currency table. That sure is possible with SQL 2000 but it MORE
easier with SQL 2005.
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--

Currency

hi,
i would like to write a sql function which takes 3 parameters.
1. Source currency type
2. destination currency type
3. Amount to be converted
I need the dynamic rates.
Does anybody hav any idea about how to go with this.
Thanks in advance,
Vinu
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200605/1Are you using SQL Server 2005 ? Therefore you could use Webservices to
call an currency service synchronously or async. by storing the data
in a currency table. That sure is possible with SQL 2000 but it MORE
easier with SQL 2005.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--

Thursday, March 8, 2012

cumulative function

is there a function which does cumulative in SQL Server 2000
Thanks
Can you be more specific?
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
news:E3D20576-00B4-453C-8E96-F3CD3C6AD508@.microsoft.com...
is there a function which does cumulative in SQL Server 2000
Thanks
|||On Mon, 13 Feb 2006 15:53:27 -0800, Sanjay wrote:

>is there a function which does cumulative in SQL Server 2000
>Thanks
Hi Sanjay,
Look up SUM in Books Online.
Hugo Kornelis, SQL Server MVP

cumulative function

is there a function which does cumulative in SQL Server 2000
ThanksCan you be more specific?
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
news:E3D20576-00B4-453C-8E96-F3CD3C6AD508@.microsoft.com...
is there a function which does cumulative in SQL Server 2000
Thanks|||On Mon, 13 Feb 2006 15:53:27 -0800, Sanjay wrote:
>is there a function which does cumulative in SQL Server 2000
>Thanks
Hi Sanjay,
Look up SUM in Books Online.
--
Hugo Kornelis, SQL Server MVP

cumulative function

is there a function which does cumulative in SQL Server 2000
ThanksCan you be more specific?
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
news:E3D20576-00B4-453C-8E96-F3CD3C6AD508@.microsoft.com...
is there a function which does cumulative in SQL Server 2000
Thanks|||On Mon, 13 Feb 2006 15:53:27 -0800, Sanjay wrote:

>is there a function which does cumulative in SQL Server 2000
>Thanks
Hi Sanjay,
Look up SUM in Books Online.
Hugo Kornelis, SQL Server MVP