Showing posts with label fields. Show all posts
Showing posts with label fields. Show all posts

Tuesday, March 27, 2012

Adding a new parameter to a subreport

Each time we add a new parameter to a subreport and we link the main report's fields to be the value's to the parameters for the subreport, we get an error message stating that the parameter for the subreport has not been specified. If we physically REBOOT the computer and then reload the project, the error seems to clear up.

Is this a bug in Reporting Services or is there some other explaination.

Thanks for the information.

Actually the problem was that the developer added a parameter, but did not convert the value into an integer (cint). Sorry for the incorrect post.sql

Sunday, March 25, 2012

Adding a full text search across multiple tables (with text fields)

Hi, i'm trying to do a full text search on my site to add a weighting score to my results. I have the following database structure:

Documents:
- DocumentID (int, PK)
- Title (varchar)
- Content (text)
- CategoryID (int, FK)

Categories:
- CategoryID (int, PK)
- CategoryName (varchar)

I need to create a full text index which searches the Title, Content and CategoryName fields. I figured since i needed to search the CategoryName field i would create an indexed view. I tried to execute the following query:

CREATE VIEW vw_Documents
WITH SCHEMABINDING AS
SELECT dbo.Documents.DocumentID, dbo.Documents.Title, dbo.Documents.[Content], dbo.Documents.CategoryID, dbo.Categories.CategoryName
FROM dbo.Categories INNER JOIN dbo.Documents ON dbo.Categories.CategoryID = dbo.Documents.CategoryID

GO
CREATE UNIQUE CLUSTERED INDEX vw_DocumentsIndex
ON vw_Documents(DocumentID)

But this gave me the error:

Cannot create index on view 'dbname.dbo.vw_Documents'. It contains text, ntext, image or xml columns.

I tried converting the Content to a varchar(max) within my view but it still didn't like.

Appreciate if someone can tell me how this can be done as surely what i'm trying to do is not ground breaking.

Hi jgd12345,

After talking with my colleagues i find a solution:

First you need to change Content datatype from text to varchar(max);

Then set the following options:

SET CONCAT_NULL_YIELDS_NULL ON

|||Cheers, i'll test this out when i get back to the office. Thanks again.

Adding a field whose value DEPENDS on other fields in table

Hi,
Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
COMPLETED_STATUS. The values of these are T (true) or F . Now I need to add
another field for Status (a generic field) , which has value :
1.Open if the value of the field OPEN_STATUS=T ,
2.InProcess if the value of the field INPROCESS_STATUS=T
3.Completed if COMPLETED_STATUS=T.
Is there a way to do this ?...maybe by writing these if statements? How can
this be done? I know this is not a good desgin but already many applications
are using these 3 fields which I dont want to change... So is there any way
of creating this new field in the same table based on the criteria specified
above?
Thanks for any help.
--
pmudTry creating a calculated column.
alter table t
add status as case when OPEN_STATUS='T' then 'Open' when
INPROCESS_STATUS='T' then 'InProcess' when COMPLETED_STATUS='T' then
'Completed' else 'UNKNOWN' end
go
Are those columns exclusive?, because the expressions inside CASE will be
evaluated in the same order as they appear.
AMB
"pmud" wrote:

> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to ad
d
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How ca
n
> this be done? I know this is not a good desgin but already many applicatio
ns
> are using these 3 fields which I dont want to change... So is there any wa
y
> of creating this new field in the same table based on the criteria specifi
ed
> above?
> Thanks for any help.
> --
> pmud|||You might also consider changing the name of the table. then create a view
with the original table name and include the special column in the view...
This will insulate you and theprogrammers from future changes.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"pmud" <pmud@.discussions.microsoft.com> wrote in message
news:9176C167-F9FB-48D4-AA84-6DA690D02B76@.microsoft.com...
> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to
> add
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How
> can
> this be done? I know this is not a good desgin but already many
> applications
> are using these 3 fields which I dont want to change... So is there any
> way
> of creating this new field in the same table based on the criteria
> specified
> above?
> Thanks for any help.
> --
> pmud|||the solution using a caculated field is good if the field does not have to b
e
indexed or searched against (slow).
If the field has to be indexed or searched and the table has lots of rows,
consider using a trigger to calculate and store the value.
"pmud" wrote:

> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to ad
d
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How ca
n
> this be done? I know this is not a good desgin but already many applicatio
ns
> are using these 3 fields which I dont want to change... So is there any wa
y
> of creating this new field in the same table based on the criteria specifi
ed
> above?
> Thanks for any help.
> --
> pmud

Adding a field whose value DEPENDS on other fields in table

Hi,
Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
COMPLETED_STATUS. The values of these are T (true) or F . Now I need to add
another field for Status (a generic field) , which has value :
1.Open if the value of the field OPEN_STATUS=T ,
2.InProcess if the value of the field INPROCESS_STATUS=T
3.Completed if COMPLETED_STATUS=T.
Is there a way to do this ?...maybe by writing these if statements? How can
this be done? I know this is not a good desgin but already many applications
are using these 3 fields which I dont want to change... So is there any way
of creating this new field in the same table based on the criteria specified
above?
Thanks for any help.
pmud
Try creating a calculated column.
alter table t
add status as case when OPEN_STATUS='T' then 'Open' when
INPROCESS_STATUS='T' then 'InProcess' when COMPLETED_STATUS='T' then
'Completed' else 'UNKNOWN' end
go
Are those columns exclusive?, because the expressions inside CASE will be
evaluated in the same order as they appear.
AMB
"pmud" wrote:

> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to add
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How can
> this be done? I know this is not a good desgin but already many applications
> are using these 3 fields which I dont want to change... So is there any way
> of creating this new field in the same table based on the criteria specified
> above?
> Thanks for any help.
> --
> pmud
|||You might also consider changing the name of the table. then create a view
with the original table name and include the special column in the view...
This will insulate you and theprogrammers from future changes.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"pmud" <pmud@.discussions.microsoft.com> wrote in message
news:9176C167-F9FB-48D4-AA84-6DA690D02B76@.microsoft.com...
> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to
> add
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How
> can
> this be done? I know this is not a good desgin but already many
> applications
> are using these 3 fields which I dont want to change... So is there any
> way
> of creating this new field in the same table based on the criteria
> specified
> above?
> Thanks for any help.
> --
> pmud
|||the solution using a caculated field is good if the field does not have to be
indexed or searched against (slow).
If the field has to be indexed or searched and the table has lots of rows,
consider using a trigger to calculate and store the value.
"pmud" wrote:

> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to add
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How can
> this be done? I know this is not a good desgin but already many applications
> are using these 3 fields which I dont want to change... So is there any way
> of creating this new field in the same table based on the criteria specified
> above?
> Thanks for any help.
> --
> pmud
sql

Adding a field whose value DEPENDS on other fields in table

Hi,
Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
COMPLETED_STATUS. The values of these are T (true) or F . Now I need to add
another field for Status (a generic field) , which has value :
1.Open if the value of the field OPEN_STATUS=T ,
2.InProcess if the value of the field INPROCESS_STATUS=T
3.Completed if COMPLETED_STATUS=T.
Is there a way to do this ?...maybe by writing these if statements? How can
this be done? I know this is not a good desgin but already many applications
are using these 3 fields which I dont want to change... So is there any way
of creating this new field in the same table based on the criteria specified
above?
Thanks for any help.
--
pmudTry creating a calculated column.
alter table t
add status as case when OPEN_STATUS='T' then 'Open' when
INPROCESS_STATUS='T' then 'InProcess' when COMPLETED_STATUS='T' then
'Completed' else 'UNKNOWN' end
go
Are those columns exclusive?, because the expressions inside CASE will be
evaluated in the same order as they appear.
AMB
"pmud" wrote:
> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to add
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How can
> this be done? I know this is not a good desgin but already many applications
> are using these 3 fields which I dont want to change... So is there any way
> of creating this new field in the same table based on the criteria specified
> above?
> Thanks for any help.
> --
> pmud|||You might also consider changing the name of the table. then create a view
with the original table name and include the special column in the view...
This will insulate you and theprogrammers from future changes.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"pmud" <pmud@.discussions.microsoft.com> wrote in message
news:9176C167-F9FB-48D4-AA84-6DA690D02B76@.microsoft.com...
> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to
> add
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How
> can
> this be done? I know this is not a good desgin but already many
> applications
> are using these 3 fields which I dont want to change... So is there any
> way
> of creating this new field in the same table based on the criteria
> specified
> above?
> Thanks for any help.
> --
> pmud|||the solution using a caculated field is good if the field does not have to be
indexed or searched against (slow).
If the field has to be indexed or searched and the table has lots of rows,
consider using a trigger to calculate and store the value.
"pmud" wrote:
> Hi,
> Three fields in my database table are , OPEN_STATUS, INPROCESS_STATUS,
> COMPLETED_STATUS. The values of these are T (true) or F . Now I need to add
> another field for Status (a generic field) , which has value :
> 1.Open if the value of the field OPEN_STATUS=T ,
> 2.InProcess if the value of the field INPROCESS_STATUS=T
> 3.Completed if COMPLETED_STATUS=T.
> Is there a way to do this ?...maybe by writing these if statements? How can
> this be done? I know this is not a good desgin but already many applications
> are using these 3 fields which I dont want to change... So is there any way
> of creating this new field in the same table based on the criteria specified
> above?
> Thanks for any help.
> --
> pmud

Thursday, March 22, 2012

Adding 2 text fields together

is it possible to concatenate two fields of record text into one field of
record text?
Thanks In Advance,
MPMYou'll need to create a trigger. An example might be:
CREATE TRIGGER SetFullName ON Customers
FOR INSERT, UPDATE
Not for replication
AS
/* set fullname for Customers */
update Customers
set Customers.FullName = inserted.[FirstName] + ' ' +
inserted.[Surname]
from inserted
where Customers.CustomerID = inserted.CustomerID
"MANCPOLYMAN" wrote:

> is it possible to concatenate two fields of record text into one field of
> record text?
> Thanks In Advance,
> MPM

Adding 2 text fields together

is it possible to concatenate two fields of record text into one field of
record text?
Thanks In Advance,
MPM
You'll need to create a trigger. An example might be:
CREATE TRIGGER SetFullName ON Customers
FOR INSERT, UPDATE
Not for replication
AS
/* set fullname for Customers */
update Customers
set Customers.FullName = inserted.[FirstName] + ' ' +
inserted.[Surname]
from inserted
where Customers.CustomerID = inserted.CustomerID
"MANCPOLYMAN" wrote:

> is it possible to concatenate two fields of record text into one field of
> record text?
> Thanks In Advance,
> MPM

Adding 2 text fields together

is it possible to concatenate two fields of record text into one field of
record text?
Thanks In Advance,
MPMYou'll need to create a trigger. An example might be:
CREATE TRIGGER SetFullName ON Customers
FOR INSERT, UPDATE
Not for replication
AS
/* set fullname for Customers */
update Customers
set Customers.FullName = inserted.[FirstName] + ' ' +
inserted.[Surname]
from inserted
where Customers.CustomerID = inserted.CustomerID
"MANCPOLYMAN" wrote:
> is it possible to concatenate two fields of record text into one field of
> record text?
> Thanks In Advance,
> MPM

Tuesday, March 20, 2012

add with null

I have two int fields of a table: Count1 and Count2
I select with the sql:
Select Count1+Count2 as CountSum form myTable
When one filed have a value and the other with null, the CountSum will be
null.
I wnat to treate the null value as 0 int, So I want to 2+ null=2
How can I do?ad wrote:
> I have two int fields of a table: Count1 and Count2
> I select with the sql:
> Select Count1+Count2 as CountSum form myTable
>
> When one filed have a value and the other with null, the CountSum will be
> null.
> I wnat to treate the null value as 0 int, So I want to 2+ null=2
> How can I do?
>
SELECT COALESCE(Count1, 0) + COALESCE(Count2, 0)
Tracy McKibben
MCDBA
http://www.realsqlguy.com

add with null

I have two int fields of a table: Count1 and Count2
I select with the sql:
Select Count1+Count2 as CountSum form myTable
When one filed have a value and the other with null, the CountSum will be
null.
I wnat to treate the null value as 0 int, So I want to 2+ null=2
How can I do?ad wrote:
> I have two int fields of a table: Count1 and Count2
> I select with the sql:
> Select Count1+Count2 as CountSum form myTable
>
> When one filed have a value and the other with null, the CountSum will be
> null.
> I wnat to treate the null value as 0 int, So I want to 2+ null=2
> How can I do?
>
SELECT COALESCE(Count1, 0) + COALESCE(Count2, 0)
Tracy McKibben
MCDBA
http://www.realsqlguy.com

Monday, March 19, 2012

add two time hierarchies to a dimension?

I got problem when trying to add two exactly same time hierachies to a
dimension.
There are two fields StartTimeID, and EndTimeID, which point to Time
dimension table by TimeID. I would like to use these two time hierachies to
restrict my query.
Something like SQL: Select ... from ... where StartTimeID > 1000 and
EndTimeID < 2000 for a time range specified.
I am testing this. Is this possible in MDX after I have the hierachies?
Guangming
I found the solution: add one more named set (like View) of Time table and
join these two time ID fields to these two Time dimension tables. Everything
should be ok.
"Word 2003 memory Leakage" wrote:

> I got problem when trying to add two exactly same time hierachies to a
> dimension.
> There are two fields StartTimeID, and EndTimeID, which point to Time
> dimension table by TimeID. I would like to use these two time hierachies to
> restrict my query.
> Something like SQL: Select ... from ... where StartTimeID > 1000 and
> EndTimeID < 2000 for a time range specified.
> I am testing this. Is this possible in MDX after I have the hierachies?
>
> Guangming
|||I think you will still have issues, the two MDX ranges will be evaluated
independantly, effectively resulting the equivalent of a logical OR
between the two conditions.
eg: Select ... from ... where StartTimeID > 1000 OR
EndTimeID < 2000 for a time range specified.
Because multiple rows in the fact table typically rollup into a single
cell in the cube these sort of queries are difficult to implement in a
cube.
I don't know if anyone else out there has any experience with this?
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell

add two time hierarchies to a dimension?

I got problem when trying to add two exactly same time hierachies to a
dimension.
There are two fields StartTimeID, and EndTimeID, which point to Time
dimension table by TimeID. I would like to use these two time hierachies to
restrict my query.
Something like SQL: Select ... from ... where StartTimeID > 1000 and
EndTimeID < 2000 for a time range specified.
I am testing this. Is this possible in MDX after I have the hierachies?
GuangmingI found the solution: add one more named set (like View) of Time table and
join these two time ID fields to these two Time dimension tables. Everything
should be ok.
"Word 2003 memory Leakage" wrote:

> I got problem when trying to add two exactly same time hierachies to a
> dimension.
> There are two fields StartTimeID, and EndTimeID, which point to Time
> dimension table by TimeID. I would like to use these two time hierachies t
o
> restrict my query.
> Something like SQL: Select ... from ... where StartTimeID > 1000 and
> EndTimeID < 2000 for a time range specified.
> I am testing this. Is this possible in MDX after I have the hierachies?
>
> Guangming|||I think you will still have issues, the two MDX ranges will be evaluated
independantly, effectively resulting the equivalent of a logical OR
between the two conditions.
eg: Select ... from ... where StartTimeID > 1000 OR
EndTimeID < 2000 for a time range specified.
Because multiple rows in the fact table typically rollup into a single
cell in the cube these sort of queries are difficult to implement in a
cube.
I don't know if anyone else out there has any experience with this?
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell

Sunday, March 11, 2012

Add similar fields to many tables

Folks, i have to create four fields in every user table within my database:

CREATED_BY VARCHAR(25), CREATED_DATE [DATETIME], MODIFIED_BY VARCHAR(25), MODIFIED_DATE [DATETIME]

There are more than hundred tables, so i wanna automate this. i am tryin to do this in a cursor: please guide!

declare @.name VARCHAR (50)
declare cur cursor
fast_forward
for select name from sysobjects where type='u' and status not like '-%'
open cur
WHILE (1=1)
BEGIN
FETCH NEXT
FROM cur
INTO @.name
IF @.@.fetch_status = 0
BEGIN
ALTER TABLE @.name
ADD created_by [VARCHAR] (25)
GO
ALTER TABLE @.name
ADD created_by [VARCHAR] (25)
GO
ALTER TABLE @.name
ADD created_date [DATETIME]
GO
ALTER TABLE @.name
ADD modified_by [VARCHAR] (25)
GO
ALTER TABLE @.name
ADD modified_date [DATETIME]
END
ELSE
BREAK
END
DEALLOCATE cur

I also want that if one column for a table exists; the other columns should be created rather than it quits.

Howdy!Folks, please help!
Or do i have to add the columns manually! :confused:

Howdy!|||Maybe if you are concerned about whether a column already exists it would be easier to run the four different ALTER statements separately rather than coding around possibilities...y'know, four scripts that you run against all the tables instead of one.

Just a suggestion.

But for a one-time modification like this, you have to be careful that you don't spend more time trying to devise the most optimal and elegant solution than it would take you to just knuckle down and do the dirty work.|||declare @.tablename varchar(50)
declare @.add_field varchar(255)

declare cur_tables cursor for
select name from sysobjects where type='u' and status not like '-%'

open cur_tables
fetch next from cur_tables into @.tablename
while @.@.fetch_status = 0
begin
--print 'table name is ' + @.tablename

set @.add_field = 'alter table ' + @.tablename + ' add created_by varchar(25)'
--print '@.add_field is ' + @.add_field
exec (@.add_field)

set @.add_field = 'alter table ' + @.tablename + ' add created_date smalldatetime'
--print '@.add_field is ' + @.add_field
exec (@.add_field)

set @.add_field = 'alter table ' + @.tablename + ' add modified_by varchar(25)'
--print '@.add_field is ' + @.add_field
exec (@.add_field)

set @.add_field = 'alter table ' + @.tablename + ' add modified_date smalldatetime'
--print '@.add_field is ' + @.add_field
exec (@.add_field)

fetch next from cur_tables into @.tablename
end
close cur_tables
deallocate cur_tables|||-- Run this and cut results to query window & run it.
-- Tim S

SET NOCOUNT ON;
SELECT
CASE WHEN col1.COLUMN_NAME IS NULL THEN 'ALTER TABLE ' + tab.TABLE_NAME + ' ADD CREATED_BY VARCHAR(25);' + CHAR(10) ELSE '' END +
CASE WHEN col2.COLUMN_NAME IS NULL THEN 'ALTER TABLE ' + tab.TABLE_NAME + ' ADD CREATED_DATE [DATETIME];'+ CHAR(10) ELSE '' END +
CASE WHEN col3.COLUMN_NAME IS NULL THEN 'ALTER TABLE ' + tab.TABLE_NAME + ' ADD MODIFIED_BY VARCHAR(25);'+ CHAR(10) ELSE '' END +
CASE WHEN col4.COLUMN_NAME IS NULL THEN 'ALTER TABLE ' + tab.TABLE_NAME + ' ADD MODIFIED_DATE [DATETIME];'+ CHAR(10) ELSE '' END
FROM INFORMATION_SCHEMA.TABLES tab
LEFT JOIN INFORMATION_SCHEMA.COLUMNS col1
ON tab.TABLE_NAME = col1.TABLE_NAME AND tab.TABLE_SCHEMA = col1.TABLE_SCHEMA AND 'CREATED_BY' = col1.COLUMN_NAME
LEFT JOIN INFORMATION_SCHEMA.COLUMNS col2
ON tab.TABLE_NAME = col2.TABLE_NAME AND tab.TABLE_SCHEMA = col2.TABLE_SCHEMA AND 'CREATED_DATE' = col2.COLUMN_NAME
LEFT JOIN INFORMATION_SCHEMA.COLUMNS col3
ON tab.TABLE_NAME = col3.TABLE_NAME AND tab.TABLE_SCHEMA = col3.TABLE_SCHEMA AND 'MODIFIED_BY' = col3.COLUMN_NAME
LEFT JOIN INFORMATION_SCHEMA.COLUMNS col4
ON tab.TABLE_NAME = col4.TABLE_NAME AND tab.TABLE_SCHEMA = col4.TABLE_SCHEMA AND 'MODIFIED_DATE' = col4.COLUMN_NAME
WHERE tab.TABLE_TYPE = 'BASE TABLE' AND -- tab.TABLE_NAME = 'test2' AND
( col1.COLUMN_NAME IS NULL OR col2.COLUMN_NAME IS NULL OR col3.COLUMN_NAME IS NULL OR col4.COLUMN_NAME IS NULL)

Saturday, February 25, 2012

Add fields vs. Join new table

Is there any sort of rule of thumb for this situation?
I have a fairly large table in my database (currently 21 fields with
over 800,000 records and growing) that is selected from, inserted to and
updated fairly often. I am adding some new features and cant decide if
it would be more efficient to add 2 fields to this table (of which 97%
of records would be null in these 2 fields) or create a new table that
would need 4 fields but only need records for the 3% and join to 1st
table for queries and reports.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!>> Is there any sort of rule of thumb for this situation?
Yes, determine whether these potential columns are really attributes of the
entity type, which the table represents. Based on your narrative, since you
have a mostly NULLs, it is reasonable to consider them as inapplicable
attributes. So they must be moved to another table. This would give you the
logical solution.
Btw, in some cases certain designers trivialize logical consequences and pay
more attention to space and performance related considerations. The myopic
justification is such cases is generally focused on the reduction in the
number of joins as an aid in performance improvements.
Anith|||I think you should have a separate table for those fields and join the 1st
table for reports and queries.
"Debbie" wrote:

> Is there any sort of rule of thumb for this situation?
> I have a fairly large table in my database (currently 21 fields with
> over 800,000 records and growing) that is selected from, inserted to and
> updated fairly often. I am adding some new features and cant decide if
> it would be more efficient to add 2 fields to this table (of which 97%
> of records would be null in these 2 fields) or create a new table that
> would need 4 fields but only need records for the 3% and join to 1st
> table for queries and reports.
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
>

Add fields to a table

is there a way to add fields to a SQL Server 2005 table using an SQL statement?
Thank You
Hello Mark,
You can use same command as SQL Server 2000 to add columns to the table. For
further details refer the following link:
http://msdn2.microsoft.com/en-us/library/ms190273.aspx
Cheers,
MB
"Mark Shields" <MarkShields@.discussions.microsoft.com> wrote in message
news:120BDFF7-3B50-43B9-BFE0-66A51399BA87@.microsoft.com...
> is there a way to add fields to a SQL Server 2005 table using an SQL
> statement?
>
> Thank You
|||On Jan 31, 4:16 am, Mark Shields
<MarkShie...@.discussions.microsoft.com> wrote:
> is there a way to add fields to a SQL Server 2005 table using an SQL statement?
> Thank You
alter table MENU_ITEM add Price bigint null
This would add the Price column to the MENU_ITEM table as a bigInt
that allows nulls.

Add fields to a table

is there a way to add fields to a SQL Server 2005 table using an SQL statement?
Thank YouHello Mark,
You can use same command as SQL Server 2000 to add columns to the table. For
further details refer the following link:
http://msdn2.microsoft.com/en-us/library/ms190273.aspx
Cheers,
MB
"Mark Shields" <MarkShields@.discussions.microsoft.com> wrote in message
news:120BDFF7-3B50-43B9-BFE0-66A51399BA87@.microsoft.com...
> is there a way to add fields to a SQL Server 2005 table using an SQL
> statement?
>
> Thank You|||On Jan 31, 4:16 am, Mark Shields
<MarkShie...@.discussions.microsoft.com> wrote:
> is there a way to add fields to a SQL Server 2005 table using an SQL statement?
> Thank You
alter table MENU_ITEM add Price bigint null
This would add the Price column to the MENU_ITEM table as a bigInt
that allows nulls.

Add fields to a table

is there a way to add fields to a SQL Server 2005 table using an SQL stateme
nt?
Thank YouHello Mark,
You can use same command as SQL Server 2000 to add columns to the table. For
further details refer the following link:
http://msdn2.microsoft.com/en-us/library/ms190273.aspx
Cheers,
MB
"Mark Shields" <MarkShields@.discussions.microsoft.com> wrote in message
news:120BDFF7-3B50-43B9-BFE0-66A51399BA87@.microsoft.com...
> is there a way to add fields to a SQL Server 2005 table using an SQL
> statement?
>
> Thank You|||On Jan 31, 4:16 am, Mark Shields
<MarkShie...@.discussions.microsoft.com> wrote:
> is there a way to add fields to a SQL Server 2005 table using an SQL state
ment?
> Thank You
alter table MENU_ITEM add Price bigint null
This would add the Price column to the MENU_ITEM table as a bigInt
that allows nulls.

Add field to multiple tables

How can I add one or two fields to about 50 tables without having to go into
each one seperately?Write a Transact-SQL script.
"scuba79" <scuba79@.discussions.microsoft.com> wrote in message
news:C6DDC84D-5D08-415A-8805-392465AA6041@.microsoft.com...
> How can I add one or two fields to about 50 tables without having to go
> into
> each one seperately?|||Brian,
Are you saying that is possible through a TSQL script to do this? If so, do
you have any examples that could assist me with this?
Thanks
Scuba79
"Brian Selzer" wrote:

> Write a Transact-SQL script.
> "scuba79" <scuba79@.discussions.microsoft.com> wrote in message
> news:C6DDC84D-5D08-415A-8805-392465AA6041@.microsoft.com...
>
>|||SELECT 'ALTER TABLE [' + LTRIM(RTRIM(TABLE_NAME)) + '] ADD Column1 INT NOT
NULL DEFAULT(0), Column2 CHAR(8) NOT NULL DEFAULT('''')' FROM
INFORMATION_SCHEMA.TABLES
"scuba79" <scuba79@.discussions.microsoft.com> wrote in message
news:EA1FEFB2-62B2-4B4B-9E9F-51404BA4E560@.microsoft.com...
> Brian,
> Are you saying that is possible through a TSQL script to do this? If so,
> do
> you have any examples that could assist me with this?
> Thanks
> Scuba79
> "Brian Selzer" wrote:
>|||Brian,
Thanks for the assistance, this is exactly what I needed to know.
Scuba79
"Brian Selzer" wrote:

> SELECT 'ALTER TABLE [' + LTRIM(RTRIM(TABLE_NAME)) + '] ADD Column1 INT NOT
> NULL DEFAULT(0), Column2 CHAR(8) NOT NULL DEFAULT('''')' FROM
> INFORMATION_SCHEMA.TABLES
>
> "scuba79" <scuba79@.discussions.microsoft.com> wrote in message
> news:EA1FEFB2-62B2-4B4B-9E9F-51404BA4E560@.microsoft.com...
>
>

Friday, February 24, 2012

add date range filter - brand newbie to reporting services

I've used report wizard to create a report - one of the fields in the report is a date field. I simply want a From Date: and To Date: filter which enables a user to select a range of dates to filter results. I know how to do this in .Net, but am not sure how to achieve this in RS. If anyone could shed some light, or point me to an thread which describes a similar process, I'd appreciate it.

thx

If you are using Visual Studio then for the data source your query should be just like a stored procedure with a parm...

Select col1, col2

From tbl1

Where col1 = @.parm1

When you open the report in Report Manager it should have a space for you to type in the value.

Now if you are using Report Builder then I don't know as I'm here looking for that answer myself.

|||

If you are using the report builder you just put the following the filter column for the date field.

Between @.SDate and @.EDate

Then go to your report parameters (right click on the upper left corner of the layout)

Click on each parameter SDate and EDate and set the type to Date/Time. It defaults as a string.

Hope this helps.

Jen

Thursday, February 16, 2012

add additional right scale on chart report

Hi there,

I have a case. I have 3 numeric fields and 1 category field to be displayed on bar chart reports. the problem is 2 of the 3 numeric fields have significant different scale value. so I need to add additonal scale at the right side of bar chart to represent 1 numeric fields + the 2 other numeric fields at the left side scale (Y). Please advice. Thanks.

R'gards

Toni

A secondary y-axis is currently not supported natively. Adding this feature in RS charts natively is under consideration for a future release.

Note: RS 2005 also has the new CustomReportItem feature. This enables ISVs to offer add-on components which integrate with RS 2005 and e.g. provide secondary y-axis in charts already today. E.g. Dundas Software offers such a product which needs to be licensed separately.

-- Robert