Friday, March 30, 2012
Is VARCHAR data type same as UTF-8?
Is data fields of varchar type internally encoded as UTF-8?
How is cyrillic text stored in varchar data fileds, as UTF-8 or not?No. Char, Varchar and Text are a CodePage representation.
If you don't want to have a lot of problems with Cyrillic and other things
like the Euro symbol; you should use nchar, nvarchar and ntext instead.
See:
http://msdn.microsoft.com/library/d...ataencoding.asp
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
<s_alexander04@.list.ru> wrote in message
news:1143694534.065217.68140@.i40g2000cwc.googlegroups.com...
> Hello
> Is data fields of varchar type internally encoded as UTF-8?
> How is cyrillic text stored in varchar data fileds, as UTF-8 or not?
>|||You can check windows region ,SQL Server settings and Database,Column
Collation.
To support globalization, you use Unicode data type such as
nchar,nvarchar,ntext.
"s_alexander04@.list.ru"?? ??? ??:
> Hello
> Is data fields of varchar type internally encoded as UTF-8?
> How is cyrillic text stored in varchar data fileds, as UTF-8 or not?
>
Wednesday, March 28, 2012
Is this the best way to do this ?
Help.
SELECT CustomerName, Filename, UserName, DateAdded, PhotoID
FROM (SELECT CustomerName, Filename, UserName, DateAdded, PhotoID, ROW_NUMBER() OVER (ORDER BY Filename) AS RowNum
FROM (SELECT DISTINCT Photos.CustomerName, Photos.Filename, Photos.UserName, Photos.DateAdded, Photos.PhotoID
FROM Photos INNER JOIN
IndustryCatalog ON Photos.PhotoID = IndustryCatalog.PhotoID INNER JOIN
OptionCatalog ON Photos.PhotoID = OptionCatalog.PhotoID
WHERE (Photos.CustomerName LIKE '%' + @.CustomerName + '%' OR
@.CustomerName IS NULL) AND (Photos.UserName LIKE '%' + @.UserName + '%' OR
@.UserName IS NULL) AND (Photos.State LIKE '%' + @.State + '%' OR
@.State IS NULL) AND (Photos.City LIKE '%' + @.City + '%' OR
@.City IS NULL) AND (Photos.WorkOrderNumber = @.WorkOrder OR
@.WorkOrder IS NULL) AND (Photos.Series = @.Series OR
@.Series IS NULL) AND (Photos.ColorID = @.ColorID OR
@.ColorID IS NULL) AND (Photos.StructureWidth = @.StructureWidth OR
@.StructureWidth IS NULL) AND (Photos.StructureLength = @.StructureLength OR
@.StructureLength IS NULL) AND (IndustryCatalog.IndustryID = @.IndustryID OR
@.IndustryID IS NULL) AND (IndustryCatalog.AppID = @.AppID OR
@.AppID IS NULL) AND (OptionCatalog.CategoryID = @.CategoryID OR
@.CategoryID IS NULL) AND (OptionCatalog.OptionID = @.OptionID OR
@.OptionID IS NULL) AND (Photos.Country LIKE '%' + @.Country + '%' OR
@.Country IS NULL) AND (Photos.PhotoFinishNumber = @.PhotoFinishNumber OR
@.PhotoFinishNumber IS NULL) AND (Photos.Description LIKE '%' + @.Description + '%' OR
@.Description IS NULL) AND (Photos.Resolution > @.Resolution OR
@.Resolution IS NULL)) AS FilteredPhotos) AS Paged
WHERE RowNum BETWEEN @.startRowIndex AND (@.startRowIndex + @.maximumRows) - 1
Hi, I simplied you query and did a test in my database, the 2 parameters (@.startRowIndex and @.maximumRows) did work. There must be some other thing that caused the 2 parameters ineffective. Have you set the ROWCOUNT option? You can turn off the option by using this statement:
SET ROWCOUNT 0
|||Turns out I was using the wrong type of join in my query and thats what was screwing up my sql... Thanks for hte help though.Is this query possible?
So I have a table which stores the following information:
a recordID (PK)
a regionID
a month (in text; such as "January 2005")
and other fields which probrably aren't important to know for this question.
The table can have more than one record for each region and month in question. The problem is for the report I want to pull up ONLY the last record for each region for the month. I got around this by doing a seperate query for each region (5 total). Now I have to do the totals for all regions combined. I could do this math using the array but I was wondering if I was able to do a query to do it for me.
So, I want to query the database and retreive 1 record. That record would contain aggragate data from each of the regions (the last record for each region and the month in question).
I might not be asking the right question, which aludes that I might not understand the problem or capabilities of SQL (newbie).
Thanks,
Douglas.If I am following you correctly, I'd try something like this:
SELECT
myTable.regionID,
myTable.month
FROM
myTable
INNER JOIN
(
SELECT
regionID,
max(recordID) AS recordID
FROM
myTable
GROUP BY
regionID
) AS SQ ON myTable.recordID = SQ.recordID
Terri|||That was perfect. Thank you.
I forgot to say thanks. Actually, I didn't even know that was an option. I use this sort of stuff a ton now.
Douglas.
Wednesday, March 21, 2012
Is this doable?
and Remaining Amount respectively. The Beginning Amount and Used Amount field
are retrieved from the SQL database, while the Remaining Amount needs to be
calculated from the previous record, e.g, ItemB's RemainingAmount = ItemA's
RemainingAmount - ItemB's UsedAmount. Basides subreport and global variable,
is there any easy way to do it? what is a good approach here?
Example,
Beginning Amount: $1000
============================================== Name Used Amount Remaining Amount
============================================== Item A 100 900
Item B 200 700
Item C 100 600
Thanks.
ShawnYes it is doable with the RunningValue function.
See BOL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rscreate/htm/rcr_creating_expressions_v1_5tt1.asp
The remaining amount would be e.g.:
= 1000 - RunningValue(Fields!Amount.Value, Sum, Nothing)
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Sean" <Sean@.discussions.microsoft.com> wrote in message
news:7E302ED6-E26D-4307-A190-F2573050CD85@.microsoft.com...
> On the report table, there are 3 fields called Beginning Amount, Used
Amount
> and Remaining Amount respectively. The Beginning Amount and Used Amount
field
> are retrieved from the SQL database, while the Remaining Amount needs to
be
> calculated from the previous record, e.g, ItemB's RemainingAmount =ItemA's
> RemainingAmount - ItemB's UsedAmount. Basides subreport and global
variable,
> is there any easy way to do it? what is a good approach here?
>
> Example,
> Beginning Amount: $1000
> ==============================================> Name Used Amount Remaining Amount
> ==============================================> Item A 100 900
> Item B 200 700
> Item C 100 600
> Thanks.
> Shawn
>|||Robert Bruckner [MSFT] wrote:
> Yes it is doable with the RunningValue function.
> See BOL:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rscreate/htm/rcr_creating_expressions_v1_5tt1.asp
> The remaining amount would be e.g.:
> = 1000 - RunningValue(Fields!Amount.Value, Sum, Nothing)
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Sean" <Sean@.discussions.microsoft.com> wrote in message
> news:7E302ED6-E26D-4307-A190-F2573050CD85@.microsoft.com...
>>On the report table, there are 3 fields called Beginning Amount, Used
> Amount
>>and Remaining Amount respectively. The Beginning Amount and Used Amount
> field
>>are retrieved from the SQL database, while the Remaining Amount needs to
> be
>>calculated from the previous record, e.g, ItemB's RemainingAmount => ItemA's
>>RemainingAmount - ItemB's UsedAmount. Basides subreport and global
> variable,
>>is there any easy way to do it? what is a good approach here?
>>
>>Example,
>>Beginning Amount: $1000
>>==============================================>>Name Used Amount Remaining Amount
>>==============================================>>Item A 100 900
>>Item B 200 700
>>Item C 100 600
>>Thanks.
>>Shawn
>>
>
>
RunningValue solves it.sql
Monday, March 19, 2012
Is this a bad database design?
may be in.
I put all three possible topic fields in the main table that holds the
title, etc. of the DVD.
For example, I have:
title, when_made, running_time, genre, subject, specific_subject
the last three are the three types a DVD may be.
My question is: Should I put the genre and subtypes all in that main
table or should I have related them in some way to the main table?
Thanks for any help.There should be a Genre table with a primary key and the Genre name. Then,
you set up a foreign key from the DVD table to the Genre table. If there
can be more than one genre per DVD, then you'd need to have a third table -
known as a link table or associative object - in order to resolve the M:M
relationship. In that case, there would be 2 foreign keys from it - one to
the Genre and another to the DVD. There would be no FK from DVD to Genre.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
<needin4mation@.gmail.com> wrote in message
news:1128428580.337372.277460@.g43g2000cwa.googlegroups.com...
I have a DVD database. I have several categories (three) that a DVD
may be in.
I put all three possible topic fields in the main table that holds the
title, etc. of the DVD.
For example, I have:
title, when_made, running_time, genre, subject, specific_subject
the last three are the three types a DVD may be.
My question is: Should I put the genre and subtypes all in that main
table or should I have related them in some way to the main table?
Thanks for any help.|||I keep the foreign keys in the main table. I have three other tables:
genre, subgenre, and subsubgenre (okay they aren't really called
subsub, but you get the drift). Each genre and sub has a key in the
main table. I don't save the wording, just the key. I was thinking
that having main genre, subgenre, and subsubgenre like that, all three,
in the same main table (even though keyed) was "wrong."|||Then it sounds like all you need in the DVD table is the subsubgenre, as far
as FK's are concerned. The subsubgenre should have a FK to the subgenre
table, which in turn has a FK to the genre table.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
<needin4mation@.gmail.com> wrote in message
news:1128439915.363058.318680@.z14g2000cwz.googlegroups.com...
I keep the foreign keys in the main table. I have three other tables:
genre, subgenre, and subsubgenre (okay they aren't really called
subsub, but you get the drift). Each genre and sub has a key in the
main table. I don't save the wording, just the key. I was thinking
that having main genre, subgenre, and subsubgenre like that, all three,
in the same main table (even though keyed) was "wrong."|||To be honest, it sounds like you need a many-to-many relationship
dvds - dvdGenres - Genres
This way you can assign multiple Genres to a single dvd without limiting
yourself to X number of them.
<needin4mation@.gmail.com> wrote in message
news:1128439915.363058.318680@.z14g2000cwz.googlegroups.com...
> I keep the foreign keys in the main table. I have three other tables:
> genre, subgenre, and subsubgenre (okay they aren't really called
> subsub, but you get the drift). Each genre and sub has a key in the
> main table. I don't save the wording, just the key. I was thinking
> that having main genre, subgenre, and subsubgenre like that, all three,
> in the same main table (even though keyed) was "wrong."
>|||>> Should I put the genre and subtypes all in that main table or should I
If they are distinct entity types, you must represent them in separate
tables. Based on your narratives :
CREATE TABLE Genre ( genre PK, ... )
CREATE TABLE Subjects ( subject PK, genre FK, ... )
CREATE TABLE Specifics ( spec_subject PK, subject FK, ... )
CREATE TABLE Movies (
movie_id PK, title, production_date, running_time, spec_subject FK,
UNIQUE( ... ), CHECK ( ... ), )
A seemingly easy & common, but misguided design is to cram all of them up in
a single table with NULL-able columns.
Anith|||I understood up until you had spec_subject FK in the Movies table. I
would have thought that genre went there. Do I misunderstand?
I actually have this design (except for the movies part), but was going
to use it for a drop down list. If for example a person selects
"Horror" they would not have the subject "kids under three movie"
(hopefully) and therefore should not have that in the selection.
In the main table that actually holds the data, I had the three columns
and insert a genre, subgenre and subsubwhatever in the table. The
values were limited at the data entry.
But what I think you are all saying is that if I have a single column
for genre that that would have a foreign key in subjects and that when
I retrieved my records it would pull that movie, that single genre and
then all subjects under that genre. Somewhere someone would have to,
of course, type in what subject was under a certain genre, but that is
okay.
On the other hand I'm not sure if that works because a Genre may imply
many subjects, but not all subjects apply to the save movie. It may be
comedy and have slapstick, black comedy, and so on, but the movie
itself may only be comedy and slapstick.
So how would I store this? Are you saying that in my table that I
would have:
movie - movieid, title...
genre - genreid, genre_verbiage
subject - subjectid, genreid, subject_verbiage
specific - specificid, subjectid, genreid, specific_verbiage
Is this why are saying to have the spec_subject FK in the master (one
side) table? so that when retrieve the data it would be like this:
select * from movie, specific, subject, genre
where
movie.spec_subject = specific.spec_subject
and
specific.subject_id = subject.subject_id
and
subject.genreid = genre.genre_id
Sorry for the long post. Just trying to understand. I inherited the
database.|||In general, newsgroups are not a great place for design advice since your
conceptual model & business rules are mostly transparent to others here.
Miscommunication and misinterpretations are common and the suggestions one
receives here are based on what others perceive as the problem and could
possibly be wrong with regard to the actual problem.
My lack of familiarity to your conceptual model and business rules might
have contributed to the misunderstanding. Your initial post gave me the
impression that specific subjects belong to subjects and subjects in turn
belong to genres. In other words, in my mind, a movie falls under one
specific subject, which in turn belonged to one main subject that belonged
to a single genre.
Before thinking about client side interface controls, let us consider the
actual entities, their attributes and the relationship among them. In your
case, is there a relationship between subjects and genre? Is there a
relationship between specifics and subjects? Can you post some examples for
each?
As a general recommendation, integrity constraints should be applied at the
database as well rather than only at the data entry interface.
Here is the categorization at blockbuster online: http://tinyurl.com/8rgz9 .
Do you have something similar? If not, post some examples for genre,
subject, specific_subject etc.
The general design rules of thumb are:
* When you have a 1-to-1 relationship between two entity types, unless there
are any non-de preserving relationships, you may represent them in a single
table.
* When you have a m-to-1 relationship between two entity types, you should
use a referential integrity constraint ( FK ) between the tables
representing these entity types
* When you have an m-to-n relationship between two or more entity types, you
should introduce an "association" table which reduces the schema to two or
more many-to-one relationships on each table representing these entity
types.
Anith|||>> I was thinking that having main genre, subgenre, and subsubgenre like tha
t, all three, in the same main table (even though keyed) was "wrong." <<
No, not if they are really different attributes. However, I would
prefer to design a hierachical encoding like Dewey Decimal for this
kind of thing.
Friday, March 9, 2012
Is there any way to use fields in a Header and/or Footer sections
hurdle that i have encountered is of how to use a fields in a header/footer
section. the requirement that i have reports forces me to use fields but RS
does not allow it.
I was wondering if there is any workaround for this limitationYou can do this but you have to use either an aggrate (sum, count) or first.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Sirish Saxena" <SirishSaxena@.discussions.microsoft.com> wrote in message
news:6A79C35A-BD05-4E15-B491-938D6BDCD0B0@.microsoft.com...
>I am New to reporting services and do not know most of it but the first
> hurdle that i have encountered is of how to use a fields in a
> header/footer
> section. the requirement that i have reports forces me to use fields but
> RS
> does not allow it.
> I was wondering if there is any workaround for this limitation|||thanks i am trying to print a company logo as this is not a numeric datatype
how would i use a aggregate function....if you can give me an example that
will be a great help.
Also I was thinking more in lines of declaring a vriable and storing a field
value in it and then assigning it to an Image item......the only problem
hereis i do not know how to do declare a variable
"Bruce L-C [MVP]" wrote:
> You can do this but you have to use either an aggrate (sum, count) or first.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Sirish Saxena" <SirishSaxena@.discussions.microsoft.com> wrote in message
> news:6A79C35A-BD05-4E15-B491-938D6BDCD0B0@.microsoft.com...
> >I am New to reporting services and do not know most of it but the first
> > hurdle that i have encountered is of how to use a fields in a
> > header/footer
> > section. the requirement that i have reports forces me to use fields but
> > RS
> > does not allow it.
> > I was wondering if there is any workaround for this limitation
>
>|||Is the data you want in a field in the dataset? That is what I thought you
were looking for. Note I said aggragate OR use first. Use the expression
builder and it should suggest using first.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Sirish Saxena" <SirishSaxena@.discussions.microsoft.com> wrote in message
news:36C6B519-412D-4F4E-93F1-8AD781BA36AD@.microsoft.com...
> thanks i am trying to print a company logo as this is not a numeric
> datatype
> how would i use a aggregate function....if you can give me an example
> that
> will be a great help.
> Also I was thinking more in lines of declaring a vriable and storing a
> field
> value in it and then assigning it to an Image item......the only problem
> hereis i do not know how to do declare a variable
>
> "Bruce L-C [MVP]" wrote:
>> You can do this but you have to use either an aggrate (sum, count) or
>> first.
>>
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>> "Sirish Saxena" <SirishSaxena@.discussions.microsoft.com> wrote in message
>> news:6A79C35A-BD05-4E15-B491-938D6BDCD0B0@.microsoft.com...
>> >I am New to reporting services and do not know most of it but the first
>> > hurdle that i have encountered is of how to use a fields in a
>> > header/footer
>> > section. the requirement that i have reports forces me to use fields
>> > but
>> > RS
>> > does not allow it.
>> > I was wondering if there is any workaround for this limitation
>>|||Ok, i will expllain the whole situation. I i am storing Logos of different
companies in a MS SQL DB, now i want to assign this filed to an Image. The
Image item is in a Header section. Header Section does not allow to refer to
any fields, which is where my problem starts. I do not want to move header to
body as that will print logo at all pages. I have tried First but it errors
out. So again my question is is there any way i can work around this? I was
also thinking if there is any way that i can defined a variable (much like in
VB or C#) ans assign the logo field to this variable and then assign the
variable to the image field, but i do not know how to declare a variable in
Reporting Services and then use it in header section.
ANY HELP WILL BE REALLY APPRECIATED!!!|||What is the error message?
What is the expression you are using that doesn't work?
=First(Fields!fieldname.Value) should work, or you may need
=First(Fields!fieldname.Value, "datasetname") when working with
multiple datasets.|||I know the use of a FIRST and multiple datasets ...my Question is: How to
use a field in Page Header? Reporting Service does not allow to use Fields in
Page Header so, i was wondering if there is any workaround?
"timseal" wrote:
> What is the error message?
> What is the expression you are using that doesn't work?
> =First(Fields!fieldname.Value) should work, or you may need
> =First(Fields!fieldname.Value, "datasetname") when working with
> multiple datasets.
>|||In Bruce's first post, he said you can do this.
If you are having trouble, please be specific. 'Errors out' is not
helpful.|||I had the same problem. Please confirm that the only way to use Fields in the
Page Header is to use an aggregate function. So what you are telling us is
that Reporting Services cannot display a field from a dataset on every page
of the report. Read below.
I am trying to display a calculated field in the Page Header for every page.
I have tried the suggestions written, but the textbox only appears on the
Page Header on the last page of the report.
For example, textbox29 in the body of my report is:
=First(Fields!Next_2_Years.Value, "AnalysisCngEECSalary")
In the Page Header, I just display the textbox:
=ReportItems!textbox29.value
The result only appears on the last page of the report. How can this result
appear on every page of the report? I tried using RepeatWith, but that did
nothing. Please help. Thanks.
--
-RB
:)
"Bruce L-C [MVP]" wrote:
> You can do this but you have to use either an aggrate (sum, count) or first.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Sirish Saxena" <SirishSaxena@.discussions.microsoft.com> wrote in message
> news:6A79C35A-BD05-4E15-B491-938D6BDCD0B0@.microsoft.com...
> >I am New to reporting services and do not know most of it but the first
> > hurdle that i have encountered is of how to use a fields in a
> > header/footer
> > section. the requirement that i have reports forces me to use fields but
> > RS
> > does not allow it.
> > I was wondering if there is any workaround for this limitation
>
>
Monday, February 20, 2012
Is there another way to obtain '-all-' the fields?
I'm using a Reporting Services webpart for Sharepoint. I made the reports
using Parameters with the SELECT UNION statement to bring 'ALL' the rows,
something like this:
SELECT priority AS prior, prioridad AS value
FROM dbo.priority
WHERE (priority <> ' ')
UNION
SELECT '-ALL-' AS prior, NULL AS value
ORDER BY priority
This worked excelent..!!, But know that i'm integrating it to the webpart it
doesn´t shows the parameters.
My question is, if there is another way to bring ALL the rows without using
the UNION statement? cause i proved that without it, the parameter appears in
my Reporting Services WebPart in Sharepoint.
Please help me, Masters of the Reporting Services and SQL..!!
--
Greetings from Mexico..!!Currently, this is the way to do this. We will support multi-select
parameters in the SQL 2005 version.
--
Brian Welcker
Group Program Manager
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Gerardo" <Gerardo@.discussions.microsoft.com> wrote in message
news:954039F6-A83D-478C-B915-F862EF8FB032@.microsoft.com...
> Hi all,
> I'm using a Reporting Services webpart for Sharepoint. I made the reports
> using Parameters with the SELECT UNION statement to bring 'ALL' the rows,
> something like this:
> SELECT priority AS prior, prioridad AS value
> FROM dbo.priority
> WHERE (priority <> ' ')
> UNION
> SELECT '-ALL-' AS prior, NULL AS value
> ORDER BY priority
> This worked excelent..!!, But know that i'm integrating it to the webpart
> it
> doesn´t shows the parameters.
> My question is, if there is another way to bring ALL the rows without
> using
> the UNION statement? cause i proved that without it, the parameter appears
> in
> my Reporting Services WebPart in Sharepoint.
> Please help me, Masters of the Reporting Services and SQL..!!
> --
> Greetings from Mexico..!!|||Thanks a lot, Brian, now i know what to say to my clients.
Cheers.
"Brian Welcker [MSFT]" wrote:
> Currently, this is the way to do this. We will support multi-select
> parameters in the SQL 2005 version.
> --
> Brian Welcker
> Group Program Manager
> SQL Server Reporting Services
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Gerardo" <Gerardo@.discussions.microsoft.com> wrote in message
> news:954039F6-A83D-478C-B915-F862EF8FB032@.microsoft.com...
> > Hi all,
> >
> > I'm using a Reporting Services webpart for Sharepoint. I made the reports
> > using Parameters with the SELECT UNION statement to bring 'ALL' the rows,
> > something like this:
> >
> > SELECT priority AS prior, prioridad AS value
> > FROM dbo.priority
> > WHERE (priority <> ' ')
> > UNION
> > SELECT '-ALL-' AS prior, NULL AS value
> > ORDER BY priority
> >
> > This worked excelent..!!, But know that i'm integrating it to the webpart
> > it
> > doesn´t shows the parameters.
> >
> > My question is, if there is another way to bring ALL the rows without
> > using
> > the UNION statement? cause i proved that without it, the parameter appears
> > in
> > my Reporting Services WebPart in Sharepoint.
> >
> > Please help me, Masters of the Reporting Services and SQL..!!
> >
> > --
> > Greetings from Mexico..!!
>
>