Showing posts with label display. Show all posts
Showing posts with label display. Show all posts

Wednesday, March 28, 2012

Newbie Question about Events

Hello,
I have a report in an .aspx page. When the user expands the row the records
display correctly except when there are a ton of records (1500 or more).
Does anyone know a way to display the records in another page when the user
expands a row?
Thanks,
JohnOn Jun 4, 11:18 am, John <J...@.discussions.microsoft.com> wrote:
> Hello,
> I have a report in an .aspx page. When the user expands the row the records
> display correctly except when there are a ton of records (1500 or more).
> Does anyone know a way to display the records in another page when the user
> expands a row?
> Thanks,
> John
You can either use a subreport or you can use drill-through or Jump to
URL or Report (via right-clicking the cell/etc to jump through and
select the Navigation tab and link to a new report/etc). Hope this
helps.
Regards,
Enrique Martinez
Sr. Software Consultant

Monday, March 12, 2012

Newbie HELP (ON SQL)

Hi all
I am very new to SQL and trying to select some records from a M/S
SQL database to display 7 days worth of data

My date column is set as a small date UK format

15/10/2002 00:33:13

Would I use the commands something like this

Select *
From my database
Where my table between GETDATE () AND GETDATE ()-7

Can anybody help as i am real lostohhh found it

SELECT Whatever, WhateverElse FROM TableName WHERE DateField >= DATEADD(d, -7, GETDATE())

Originally posted by webstep
Hi all
I am very new to SQL and trying to select some records from a M/S
SQL database to display 7 days worth of data

My date column is set as a small date UK format

15/10/2002 00:33:13

Would I use the commands something like this

Select *
From my database
Where my table between GETDATE () AND GETDATE ()-7

Can anybody help as i am real lost|||If you put this at the top of your script:

declare @.date1 datetime, @.date2 datetime
set @.date2 = convert(varchar(11), getdate(), 111)
set @.date1 = convert(varchar(11), getdate()-7, 111)

...then you can just use @.date1 as your from date and @.date2 as your to date. You won't have to put in any dates.

Steve

Saturday, February 25, 2012

Newbie - Query convert money

I have been unsuccessful at getting this to display the way I want it to.
BOL says that convert(money, [expression] , 1) will display my sales figures
as 1,234,567.89. However the results for my query
SELECT TOP 100 PERCENT SalespersonID, convert(money, SUM(NetSales),1)
AS NetSales
GROUP BY SalespersonID
ORDER BY SalespersonID
returns the column NetSales as 1234567.89.
This is driving my boss crazy trying to determine whether the result is
$100,000 or $1,000,000.
Can someone explain this to me? The data type is already money, so I'm
wondering if it is just ignoring the convert...
I appreciate your help!Format at the client / presentation tier, because asking SQL Server to do
this is silly:
SELECT
'$'+REVERSE(SUBSTRING(REVERSE(CONVERT(VA
RCHAR(100),CONVERT(MONEY,money_colum
n),1)),1,100))
AS money_column
FROM table
"Chuck" <Chuck@.discussions.microsoft.com> wrote in message
news:B3584EDB-D8FA-422B-8A67-D2B45735E2ED@.microsoft.com...
>I have been unsuccessful at getting this to display the way I want it to.
> BOL says that convert(money, [expression] , 1) will display my sales
> figures
> as 1,234,567.89. However the results for my query
> SELECT TOP 100 PERCENT SalespersonID, convert(money, SUM(NetSales),1)
> AS NetSales
> GROUP BY SalespersonID
> ORDER BY SalespersonID
> returns the column NetSales as 1234567.89.
> This is driving my boss crazy trying to determine whether the result is
> $100,000 or $1,000,000.
> Can someone explain this to me? The data type is already money, so I'm
> wondering if it is just ignoring the convert...
> I appreciate your help!
>

newbie - Display rows with identical values

Hello,
how can i retrieve duplicate records?
I have this table with about 6500 records, and i know that there are a few
where a combination (Column1 - Column2) is identical
how can i retrieve these?SELECT Column1, Column2
FROM YourTable
GROUP BY Column1 - Column2
HAVING COUNT(*) > 1
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:2851EFFB-2722-47E6-A654-D953AA4FB86A@.microsoft.com...
> Hello,
> how can i retrieve duplicate records?
> I have this table with about 6500 records, and i know that there are a few
> where a combination (Column1 - Column2) is identical
> how can i retrieve these?
>
>|||hi benoit,
Just a question, your table own a indentity field?
If so, use this:
delete from table1
where <identityfield> not in
(select max(<identityfiedl> ) from table1
group by [<field1>,<field2>]
Otherwise, let me know or post DDL
regards,
"benoit" wrote:

> Hello,
> how can i retrieve duplicate records?
> I have this table with about 6500 records, and i know that there are a few
> where a combination (Column1 - Column2) is identical
> how can i retrieve these?
>
>|||i was thinking the same way as roji
use northwind
select lastname,firstname into x from employees
union all
select top 5 lastname,firstname from employees
go
select lastname, firstname from x
group by lastname,firstname
having count(*)>1
Jose de Jesus Jr. Mcp,Mcdba
Data Architect
Sykes Asia (Manila philippines)
MCP #2324787
"benoit" wrote:

> Hello,
> how can i retrieve duplicate records?
> I have this table with about 6500 records, and i know that there are a few
> where a combination (Column1 - Column2) is identical
> how can i retrieve these?
>
>|||works great !
thx
"Roji. P. Thomas" wrote:

> SELECT Column1, Column2
> FROM YourTable
> GROUP BY Column1 - Column2
> HAVING COUNT(*) > 1
> --
> Roji. P. Thomas
> Net Asset Management
> http://toponewithties.blogspot.com
>
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:2851EFFB-2722-47E6-A654-D953AA4FB86A@.microsoft.com...
>
>|||Hi
This article had written by Itzik Ben-Gan
CREATE TABLE #Demo (
idNo int identity(1,1),
colA int,
colB int
)
INSERT INTO #Demo(colA,colB) VALUES (1,6)
INSERT INTO #Demo(colA,colB) VALUES (1,6)
INSERT INTO #Demo(colA,colB) VALUES (2,4)
INSERT INTO #Demo(colA,colB) VALUES (3,3)
INSERT INTO #Demo(colA,colB) VALUES (4,2)
INSERT INTO #Demo(colA,colB) VALUES (3,3)
INSERT INTO #Demo(colA,colB) VALUES (5,1)
INSERT INTO #Demo(colA,colB) VALUES (8,1)
PRINT 'Table'
SELECT * FROM #Demo
PRINT 'Duplicates in Table'
SELECT * FROM #Demo
WHERE idNo IN
(SELECT B.idNo
FROM #Demo A JOIN #Demo B
ON A.idNo <> B.idNo
AND A.colA = B.colA
AND A.colB = B.colB)
PRINT 'Duplicates to Delete'
SELECT * FROM #Demo
WHERE idNo IN
(SELECT B.idNo
FROM #Demo A JOIN #Demo B
ON A.idNo < B.idNo -- < this time, not <>
AND A.colA = B.colA
AND A.colB = B.colB)
DELETE FROM #Demo
WHERE idNo IN
(SELECT B.idNo
FROM #Demo A JOIN #Demo B
ON A.idNo < B.idNo -- < this time, not <>
AND A.colA = B.colA
AND A.colB = B.colB)
PRINT 'Cleaned-up Table'
SELECT * FROM #Demo
DROP TABLE #Demo
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:2851EFFB-2722-47E6-A654-D953AA4FB86A@.microsoft.com...
> Hello,
> how can i retrieve duplicate records?
> I have this table with about 6500 records, and i know that there are a few
> where a combination (Column1 - Column2) is identical
> how can i retrieve these?
>
>

Newbie - can I do this in a script

I would like my script to check for the existance of a table, and if found
make sure theres enuf dispace back it up (otherwise display a message and
halt), then I need to alter a table. If it doesn't exist I would like to
create it like normal.
I've been trolling thru the sql help files but can't find how to check for
existence of a table. Any pointers/articles someone can get me too?
JeffYou can check the existence of a table using the following syntax:
IF OBJECT_ID('database.object_owner.object') IS NOT NULL
BEGIN
PRINT 'object exists'
END
eg. Checking if the Northwind Orders table exists
IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
BEGIN
PRINT 'object exists'
END
- Peter Ward
WARDY IT Solutions
"J. Clarke" wrote:

> I would like my script to check for the existance of a table, and if found
> make sure theres enuf dispace back it up (otherwise display a message and
> halt), then I need to alter a table. If it doesn't exist I would like to
> create it like normal.
> I've been trolling thru the sql help files but can't find how to check for
> existence of a table. Any pointers/articles someone can get me too?
> Jeff
>
>|||Thanks Peter - I guess you answered my followup question about "if"
statements. How would I format a user defined procedure or a function?
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
> You can check the existence of a table using the following syntax:
> IF OBJECT_ID('database.object_owner.object') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
> eg. Checking if the Northwind Orders table exists
> IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END|||Will this work on just the db also (i.e. northwind)?
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
> You can check the existence of a table using the following syntax:
> IF OBJECT_ID('database.object_owner.object') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
> eg. Checking if the Northwind Orders table exists
> IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END|||Jeff
I am not sure what you are asking, can you please clarify your question.
Thanks
- Peter Ward
WARDY IT Solutions
"J. Clarke" wrote:

> Will this work on just the db also (i.e. northwind)?
> Jeff
> "P. Ward" <peter@.remove_online.wardyit.com> wrote in message
> news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
>
>|||Sorry Ward - the question is can I check for the existance of a DB (vs. the
table)?
I think I tried something like: IF OBJECT_ID('database') IS NOT NULL and
the QA didn't seem to like it. I guess it doesn't matter too much since
that table will always be there if the DB is...
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:F576737F-8C16-4D87-B830-7D3A95960907@.microsoft.com...
> Jeff
> I am not sure what you are asking, can you please clarify your question.
> Thanks
>
> - Peter Ward|||Use DB_ID() for that:
IF DB_ID('pubs') IS NOT NULL
PRINT 'Database exists'
ELSE
PRINT 'Database doesn''t exists'
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"J. Clarke" <jclarke@.docstorsysNOSPAM.com> wrote in message
news:O7KMBXHMFHA.508@.TK2MSFTNGP12.phx.gbl...
> Sorry Ward - the question is can I check for the existance of a DB (vs. th
e
> table)?
> I think I tried something like: IF OBJECT_ID('database') IS NOT NULL and
> the QA didn't seem to like it. I guess it doesn't matter too much since
> that table will always be there if the DB is...
> Jeff
>
> "P. Ward" <peter@.remove_online.wardyit.com> wrote in message
> news:F576737F-8C16-4D87-B830-7D3A95960907@.microsoft.com...
>

Newbie - can I do this in a script

I would like my script to check for the existance of a table, and if found
make sure theres enuf dispace back it up (otherwise display a message and
halt), then I need to alter a table. If it doesn't exist I would like to
create it like normal.
I've been trolling thru the sql help files but can't find how to check for
existence of a table. Any pointers/articles someone can get me too?
JeffYou can check the existence of a table using the following syntax:
IF OBJECT_ID('database.object_owner.object') IS NOT NULL
BEGIN
PRINT 'object exists'
END
eg. Checking if the Northwind Orders table exists
IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
BEGIN
PRINT 'object exists'
END
- Peter Ward
WARDY IT Solutions
"J. Clarke" wrote:
> I would like my script to check for the existance of a table, and if found
> make sure theres enuf dispace back it up (otherwise display a message and
> halt), then I need to alter a table. If it doesn't exist I would like to
> create it like normal.
> I've been trolling thru the sql help files but can't find how to check for
> existence of a table. Any pointers/articles someone can get me too?
> Jeff
>
>|||Thanks Peter - I guess you answered my followup question about "if"
statements. How would I format a user defined procedure or a function?
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
> You can check the existence of a table using the following syntax:
> IF OBJECT_ID('database.object_owner.object') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
> eg. Checking if the Northwind Orders table exists
> IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END|||Will this work on just the db also (i.e. northwind)?
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
> You can check the existence of a table using the following syntax:
> IF OBJECT_ID('database.object_owner.object') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
> eg. Checking if the Northwind Orders table exists
> IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END|||Jeff
I am not sure what you are asking, can you please clarify your question.
Thanks
- Peter Ward
WARDY IT Solutions
"J. Clarke" wrote:
> Will this work on just the db also (i.e. northwind)?
> Jeff
> "P. Ward" <peter@.remove_online.wardyit.com> wrote in message
> news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
> > You can check the existence of a table using the following syntax:
> >
> > IF OBJECT_ID('database.object_owner.object') IS NOT NULL
> > BEGIN
> > PRINT 'object exists'
> > END
> >
> > eg. Checking if the Northwind Orders table exists
> >
> > IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
> > BEGIN
> > PRINT 'object exists'
> > END
>
>|||Sorry Ward - the question is can I check for the existance of a DB (vs. the
table)?
I think I tried something like: IF OBJECT_ID('database') IS NOT NULL and
the QA didn't seem to like it. I guess it doesn't matter too much since
that table will always be there if the DB is...
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:F576737F-8C16-4D87-B830-7D3A95960907@.microsoft.com...
> Jeff
> I am not sure what you are asking, can you please clarify your question.
> Thanks
>
> - Peter Ward|||Use DB_ID() for that:
IF DB_ID('pubs') IS NOT NULL
PRINT 'Database exists'
ELSE
PRINT 'Database doesn''t exists'
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"J. Clarke" <jclarke@.docstorsysNOSPAM.com> wrote in message
news:O7KMBXHMFHA.508@.TK2MSFTNGP12.phx.gbl...
> Sorry Ward - the question is can I check for the existance of a DB (vs. the
> table)?
> I think I tried something like: IF OBJECT_ID('database') IS NOT NULL and
> the QA didn't seem to like it. I guess it doesn't matter too much since
> that table will always be there if the DB is...
> Jeff
>
> "P. Ward" <peter@.remove_online.wardyit.com> wrote in message
> news:F576737F-8C16-4D87-B830-7D3A95960907@.microsoft.com...
>> Jeff
>> I am not sure what you are asking, can you please clarify your question.
>> Thanks
>>
>> - Peter Ward
>

Newbie - can I do this in a script

I would like my script to check for the existance of a table, and if found
make sure theres enuf dispace back it up (otherwise display a message and
halt), then I need to alter a table. If it doesn't exist I would like to
create it like normal.
I've been trolling thru the sql help files but can't find how to check for
existence of a table. Any pointers/articles someone can get me too?
Jeff
You can check the existence of a table using the following syntax:
IF OBJECT_ID('database.object_owner.object') IS NOT NULL
BEGIN
PRINT 'object exists'
END
eg. Checking if the Northwind Orders table exists
IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
BEGIN
PRINT 'object exists'
END
- Peter Ward
WARDY IT Solutions
"J. Clarke" wrote:

> I would like my script to check for the existance of a table, and if found
> make sure theres enuf dispace back it up (otherwise display a message and
> halt), then I need to alter a table. If it doesn't exist I would like to
> create it like normal.
> I've been trolling thru the sql help files but can't find how to check for
> existence of a table. Any pointers/articles someone can get me too?
> Jeff
>
>
|||Thanks Peter - I guess you answered my followup question about "if"
statements. How would I format a user defined procedure or a function?
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
> You can check the existence of a table using the following syntax:
> IF OBJECT_ID('database.object_owner.object') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
> eg. Checking if the Northwind Orders table exists
> IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
|||Will this work on just the db also (i.e. northwind)?
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
> You can check the existence of a table using the following syntax:
> IF OBJECT_ID('database.object_owner.object') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
> eg. Checking if the Northwind Orders table exists
> IF OBJECT_ID('northwind.dbo.orders') IS NOT NULL
> BEGIN
> PRINT 'object exists'
> END
|||Jeff
I am not sure what you are asking, can you please clarify your question.
Thanks
- Peter Ward
WARDY IT Solutions
"J. Clarke" wrote:

> Will this work on just the db also (i.e. northwind)?
> Jeff
> "P. Ward" <peter@.remove_online.wardyit.com> wrote in message
> news:BD0B1E97-FE1F-4A38-89A9-A53385DBFCDC@.microsoft.com...
>
>
|||Sorry Ward - the question is can I check for the existance of a DB (vs. the
table)?
I think I tried something like: IF OBJECT_ID('database') IS NOT NULL and
the QA didn't seem to like it. I guess it doesn't matter too much since
that table will always be there if the DB is...
Jeff
"P. Ward" <peter@.remove_online.wardyit.com> wrote in message
news:F576737F-8C16-4D87-B830-7D3A95960907@.microsoft.com...
> Jeff
> I am not sure what you are asking, can you please clarify your question.
> Thanks
>
> - Peter Ward
|||Use DB_ID() for that:
IF DB_ID('pubs') IS NOT NULL
PRINT 'Database exists'
ELSE
PRINT 'Database doesn''t exists'
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"J. Clarke" <jclarke@.docstorsysNOSPAM.com> wrote in message
news:O7KMBXHMFHA.508@.TK2MSFTNGP12.phx.gbl...
> Sorry Ward - the question is can I check for the existance of a DB (vs. the
> table)?
> I think I tried something like: IF OBJECT_ID('database') IS NOT NULL and
> the QA didn't seem to like it. I guess it doesn't matter too much since
> that table will always be there if the DB is...
> Jeff
>
> "P. Ward" <peter@.remove_online.wardyit.com> wrote in message
> news:F576737F-8C16-4D87-B830-7D3A95960907@.microsoft.com...
>