Showing posts with label query. Show all posts
Showing posts with label query. Show all posts

Thursday, March 22, 2012

changing a query

This is my current query that I have in an App I wrote:
MySQL = "select DateEntered,Shipper,PickupDate,PUTime,City, State, Zip,
Consignee, Destination, DState, DZip, PickupNumber, ShippersNumber,
PONumber, Consignee_Ref_Number, Weight, Number_Packages, Carrier,
Carrier_Number, Trailer_Number, ApptDate, ApptTime, IDFProNumber,
DeliveredDate, DeliveredTime, FreightCharges, TransitTime, Comments,
LastUpdate, lastcomment from IntermodalTracingMasterFile where " &
tmpMyShippers & " Order by [" & strSort & "] desc "
This works fine.
I need to modify it a little I need to have one query that will return when
the DeliveredDate is empty
and anohter query to return the ones that have somethign in the
DeliveredDate field.
Thanks> the DeliveredDate is empty
If by 'empty' you mean NULL, you can add the following to your WHERE clause:
AND DeliveredDate IS NULL
For non-null values:
AND DeliveredDate IS NOT NULL
--
Hope this helps.
Dan Guzman
SQL Server MVP
"johnfli" <john@.here.com> wrote in message
news:us241LQzEHA.2196@.TK2MSFTNGP14.phx.gbl...
> This is my current query that I have in an App I wrote:
> MySQL = "select DateEntered,Shipper,PickupDate,PUTime,City, State, Zip,
> Consignee, Destination, DState, DZip, PickupNumber, ShippersNumber,
> PONumber, Consignee_Ref_Number, Weight, Number_Packages, Carrier,
> Carrier_Number, Trailer_Number, ApptDate, ApptTime, IDFProNumber,
> DeliveredDate, DeliveredTime, FreightCharges, TransitTime, Comments,
> LastUpdate, lastcomment from IntermodalTracingMasterFile where " &
> tmpMyShippers & " Order by [" & strSort & "] desc "
>
> This works fine.
> I need to modify it a little I need to have one query that will return
> when
> the DeliveredDate is empty
> and anohter query to return the ones that have somethign in the
> DeliveredDate field.
>
> Thanks
>

Monday, March 19, 2012

Changes made in Query Analizer don't show in Enterprise Manager

If I run e.g. a table-creating sql statement then the changes won't show in
Enterprise Manager no matter how many times I refresh. They only show if I
restart Enterprise Manager.
1. Is there a way to get EM to reflect the changes made in Query Analizer?
2. I couldn't seem to find a way to run arbitrary sql statements in
Enterprise Manager (There are SQL panes when operating with tables or views,
but which is fine for running a select into, for instance?). Have I missed
something or should I use the Query Analizer?
Hi
1. EM normally does. Make sure you are running SQL 2000 sp3a on both the
server and on the machine you have EM installed.
2. EM is intended for a DBA to manager servers. QA is the tool to use to run
queries and other SQL statements.
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Agoston Bejo" <gusz1@.freemail.hu> wrote in message
news:#Vv6eMvrEHA.2136@.TK2MSFTNGP14.phx.gbl...
> If I run e.g. a table-creating sql statement then the changes won't show
in
> Enterprise Manager no matter how many times I refresh. They only show if I
> restart Enterprise Manager.
> 1. Is there a way to get EM to reflect the changes made in Query Analizer?
> 2. I couldn't seem to find a way to run arbitrary sql statements in
> Enterprise Manager (There are SQL panes when operating with tables or
views,
> but which is fine for running a select into, for instance?). Have I missed
> something or should I use the Query Analizer?
>
>
|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:

>1. Is there a way to get EM to reflect the changes made in Query Analizer?
Hi Agoston,
Right-click any icon in the right pane. Most have an option "Refresh".
Note that this option will only refresh the direct sublist of that
specific icon; there is no "full refresh" option (as far as I know).
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)
|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:

>no matter how many times I refresh
Hi Agoston,
It seems I missed this part of your message when I sent my previous
message. Please disregard it.
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)

Changes made in Query Analizer don't show in Enterprise Manager

If I run e.g. a table-creating sql statement then the changes won't show in
Enterprise Manager no matter how many times I refresh. They only show if I
restart Enterprise Manager.
1. Is there a way to get EM to reflect the changes made in Query Analizer?
2. I couldn't seem to find a way to run arbitrary sql statements in
Enterprise Manager (There are SQL panes when operating with tables or views,
but which is fine for running a select into, for instance?). Have I missed
something or should I use the Query Analizer?
Hi
1. EM normally does. Make sure you are running SQL 2000 sp3a on both the
server and on the machine you have EM installed.
2. EM is intended for a DBA to manager servers. QA is the tool to use to run
queries and other SQL statements.
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Agoston Bejo" <gusz1@.freemail.hu> wrote in message
news:#Vv6eMvrEHA.2136@.TK2MSFTNGP14.phx.gbl...
> If I run e.g. a table-creating sql statement then the changes won't show
in
> Enterprise Manager no matter how many times I refresh. They only show if I
> restart Enterprise Manager.
> 1. Is there a way to get EM to reflect the changes made in Query Analizer?
> 2. I couldn't seem to find a way to run arbitrary sql statements in
> Enterprise Manager (There are SQL panes when operating with tables or
views,
> but which is fine for running a select into, for instance?). Have I missed
> something or should I use the Query Analizer?
>
>
|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:

>1. Is there a way to get EM to reflect the changes made in Query Analizer?
Hi Agoston,
Right-click any icon in the right pane. Most have an option "Refresh".
Note that this option will only refresh the direct sublist of that
specific icon; there is no "full refresh" option (as far as I know).
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)
|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:

>no matter how many times I refresh
Hi Agoston,
It seems I missed this part of your message when I sent my previous
message. Please disregard it.
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)

Changes made in Query Analizer don't show in Enterprise Manager

If I run e.g. a table-creating sql statement then the changes won't show in
Enterprise Manager no matter how many times I refresh. They only show if I
restart Enterprise Manager.
1. Is there a way to get EM to reflect the changes made in Query Analizer?
2. I couldn't seem to find a way to run arbitrary sql statements in
Enterprise Manager (There are SQL panes when operating with tables or views,
but which is fine for running a select into, for instance?). Have I missed
something or should I use the Query Analizer?Hi
1. EM normally does. Make sure you are running SQL 2000 sp3a on both the
server and on the machine you have EM installed.
2. EM is intended for a DBA to manager servers. QA is the tool to use to run
queries and other SQL statements.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Agoston Bejo" <gusz1@.freemail.hu> wrote in message
news:#Vv6eMvrEHA.2136@.TK2MSFTNGP14.phx.gbl...
> If I run e.g. a table-creating sql statement then the changes won't show
in
> Enterprise Manager no matter how many times I refresh. They only show if I
> restart Enterprise Manager.
> 1. Is there a way to get EM to reflect the changes made in Query Analizer?
> 2. I couldn't seem to find a way to run arbitrary sql statements in
> Enterprise Manager (There are SQL panes when operating with tables or
views,
> but which is fine for running a select into, for instance?). Have I missed
> something or should I use the Query Analizer?
>
>|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:
>1. Is there a way to get EM to reflect the changes made in Query Analizer?
Hi Agoston,
Right-click any icon in the right pane. Most have an option "Refresh".
Note that this option will only refresh the direct sublist of that
specific icon; there is no "full refresh" option (as far as I know).
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:
>no matter how many times I refresh
Hi Agoston,
It seems I missed this part of your message when I sent my previous
message. Please disregard it.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Changes made in Query Analizer don't show in Enterprise Manager

If I run e.g. a table-creating sql statement then the changes won't show in
Enterprise Manager no matter how many times I refresh. They only show if I
restart Enterprise Manager.
1. Is there a way to get EM to reflect the changes made in Query Analizer?
2. I couldn't seem to find a way to run arbitrary sql statements in
Enterprise Manager (There are SQL panes when operating with tables or views,
but which is fine for running a select into, for instance?). Have I missed
something or should I use the Query Analizer?Hi
1. EM normally does. Make sure you are running SQL 2000 sp3a on both the
server and on the machine you have EM installed.
2. EM is intended for a DBA to manager servers. QA is the tool to use to run
queries and other SQL statements.
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Agoston Bejo" <gusz1@.freemail.hu> wrote in message
news:#Vv6eMvrEHA.2136@.TK2MSFTNGP14.phx.gbl...
> If I run e.g. a table-creating sql statement then the changes won't show
in
> Enterprise Manager no matter how many times I refresh. They only show if I
> restart Enterprise Manager.
> 1. Is there a way to get EM to reflect the changes made in Query Analizer?
> 2. I couldn't seem to find a way to run arbitrary sql statements in
> Enterprise Manager (There are SQL panes when operating with tables or
views,
> but which is fine for running a select into, for instance?). Have I missed
> something or should I use the Query Analizer?
>
>|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:

>1. Is there a way to get EM to reflect the changes made in Query Analizer?
Hi Agoston,
Right-click any icon in the right pane. Most have an option "Refresh".
Note that this option will only refresh the direct sublist of that
specific icon; there is no "full refresh" option (as far as I know).
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||On Sun, 10 Oct 2004 20:00:39 +0200, Agoston Bejo wrote:

>no matter how many times I refresh
Hi Agoston,
It seems I missed this part of your message when I sent my previous
message. Please disregard it.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Sunday, March 11, 2012

change value type from Int64 to Int32 ?

I have a query which calculates a number... but by default the number is represented as a 64 bit integer. I cannot remember the function name but it is only using SQL9.0 built in functions. Is there a way to cast the number?

This is not a trivial issue since I have found an easier way to do this which did not involve the number, although any input would be greatly appreciated.

Thank you :)

I don't quite understand your question. But you can cast a value to a different data type using CAST function. You may or may not get runtime errors depending on the data. See Books Online for more details. So in your query, you can do something like below:

select cast(<expr> as int)

from ...

Thursday, March 8, 2012

Change Type greyed out in 2k5 mgmt studio

in 2000 ent mgr, I can right click on a table/Query/perform a query and then
"Change Type" to update or whatever.
In 2k5 mgmt studio (against a 2000 database) I can arrange the panes to look
the same and perform the same query.
But Change Type is greyed out (on the screen). For what its work the icon
isnt there, but the words "Change Type".
Its enabled (checked) - well, I forget how I got there, but it was checked.
If I click on a table in the object explorer, its no longer grey-out, but
all the options are (which makes sense).
So - how can I Change Type graphically on a query?
You may need to logon but add your vote and comment here.
http://connect.microsoft.com/SQLServer
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124911
Regards,
Dave Patrick ...Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
"SandpointGuy" wrote:
> in 2000 ent mgr, I can right click on a table/Query/perform a query and
> then
> "Change Type" to update or whatever.
> In 2k5 mgmt studio (against a 2000 database) I can arrange the panes to
> look
> the same and perform the same query.
> But Change Type is greyed out (on the screen). For what its work the icon
> isnt there, but the words "Change Type".
> Its enabled (checked) - well, I forget how I got there, but it was
> checked.
> If I click on a table in the object explorer, its no longer grey-out, but
> all the options are (which makes sense).
> So - how can I Change Type graphically on a query?
|||I don't use the designer tools but when I played around with
it, it looks like you have to be in the Query Designer to
get that functionality.
1. From the toolbar, select new query
2. On the new query window, right click and select Design
Query in Editor
You can right click on the panes in this designer and select
Change Type.
-Sue
On Fri, 10 Aug 2007 10:50:01 -0700, SandpointGuy
<SandpointGuy@.discussions.microsoft.com> wrote:

>in 2000 ent mgr, I can right click on a table/Query/perform a query and then
>"Change Type" to update or whatever.
>In 2k5 mgmt studio (against a 2000 database) I can arrange the panes to look
>the same and perform the same query.
>But Change Type is greyed out (on the screen). For what its work the icon
>isnt there, but the words "Change Type".
>Its enabled (checked) - well, I forget how I got there, but it was checked.
>If I click on a table in the object explorer, its no longer grey-out, but
>all the options are (which makes sense).
>So - how can I Change Type graphically on a query?

Change the type of an expression container

Hi,

I use expressions to build the SQL query that is executed by the data flow.

Today, I ran into an issue. For the first time the SQL query has exceeded 4000 char so the expression cannot be validated and it is not possible to use it.

Is there a way to change the expression datatype to nvarchar(max) instead of the default nvarchar(4000) ?

Thanks,

Philippe

Philippe,

Unfortunately 4000 is the limit on the result of an expression.

-Jamie

|||

So i am back in the business of using multiple variables.

Too bad

|||Is there any way around the 4000 literal string masx issues. Its sad that the case because a table could contain many fields and that might cause the literal string to be more than 4000.

Change the Sort Order

Hi,
I hope than somebody can explain me why the report order on the reporting
services desing (Visual Studio), is differen than the query sort order.
Normal SQL Query
1) AA
2) AB
3) A1
4) 1A
Visual Studio Report Design
1) 1A
2) A1
3) AA
4) AB
Can some body help me to change that setting on the
Thanksplease... help me !!!!.....
Edman wrote:
>Hi,
>I hope than somebody can explain me why the report order on the reporting
>services desing (Visual Studio), is differen than the query sort order.
>Normal SQL Query
>1) AA
>2) AB
>3) A1
>4) 1A
> Visual Studio Report Design
>1) 1A
>2) A1
>3) AA
>4) AB
>Can some body help me to change that setting on the
>Thanks
Message posted via http://www.sqlmonster.com|||I almost never set the sort in RS, I set the sort order in my query.
Sometimes I can't do this but when I can, I do.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Edman via SQLMonster.com" <u14374@.uwe> wrote in message
news:554a9135a7fd0@.uwe...
> please... help me !!!!.....
> Edman wrote:
>>Hi,
>>I hope than somebody can explain me why the report order on the reporting
>>services desing (Visual Studio), is differen than the query sort order.
>>Normal SQL Query
>>1) AA
>>2) AB
>>3) A1
>>4) 1A
>> Visual Studio Report Design
>>1) 1A
>>2) A1
>>3) AA
>>4) AB
>>Can some body help me to change that setting on the
>>Thanks
>
> --
> Message posted via http://www.sqlmonster.com

Wednesday, March 7, 2012

Change the Parameter in an query

I have a report "Clearance Summary Report:
Each page summarized the total sales for one agency.
Everything works great except for one total "Adjustments:"
An agency can have one order but have 50 adjustments to that order.
That is why the Adjustments can not be included in the "dsReport" query.
For that reason the Adjustments number is calculate with its own query
(dsAdjustments). but gets two parameters ClearanceID and MagazineID.
NOW the problem.
The help file says to create two parameters. ClearanceID and MagazineID.
Declear them internal.
Link them to the fields: ClearanceID and MagazineID.
Then the dsAdjustments query can refreance the paramters ClearanceID and
MagazineID.
When the report is run the dsAjustments query gets it value from the
parameters ClearanceID and MagazineID and then returns a number. That is how
I get the adjusments.
This works if I lookup only one Agency. But if there are two or more
agencies in the report the parameters ClearanceID and MagazineID are only
fill in at the begining of the report. All the other Agencies reports ty to
use the first agency adjustmets numbers.
Question: How do I get the parameters ClearanceID and MagzineID to update
for every new Agency''
Thank you
Scott BurkeRead up on subreports. Subreports are exactly for this sort of this.
Master-detail type reports pretty much must be done using subreports.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Scott Burke" <ScottBurke@.discussions.microsoft.com> wrote in message
news:A7930198-0781-4DB7-A25E-9EDFBE434C6A@.microsoft.com...
>I have a report "Clearance Summary Report:
> Each page summarized the total sales for one agency.
> Everything works great except for one total "Adjustments:"
> An agency can have one order but have 50 adjustments to that order.
> That is why the Adjustments can not be included in the "dsReport" query.
> For that reason the Adjustments number is calculate with its own query
> (dsAdjustments). but gets two parameters ClearanceID and MagazineID.
> NOW the problem.
> The help file says to create two parameters. ClearanceID and MagazineID.
> Declear them internal.
> Link them to the fields: ClearanceID and MagazineID.
> Then the dsAdjustments query can refreance the paramters ClearanceID and
> MagazineID.
> When the report is run the dsAjustments query gets it value from the
> parameters ClearanceID and MagazineID and then returns a number. That is
> how
> I get the adjusments.
> This works if I lookup only one Agency. But if there are two or more
> agencies in the report the parameters ClearanceID and MagazineID are only
> fill in at the begining of the report. All the other Agencies reports ty
> to
> use the first agency adjustmets numbers.
> Question: How do I get the parameters ClearanceID and MagzineID to update
> for every new Agency''
> Thank you
> Scott Burke
>|||Hi Bruce, This report org used a subreport to produce the totals. HOWEVER;
For some reason unknow to everyone I talked to the Report server tends to
lose/ can't find the subreport!!!!!
The last time it happed I had to redeploy the main report. That did not
work this time.
We only had the report server for four months! I dont look forward to
redeploying the CommisionSummaryReport every two months!
my solution is to replace the subreport. Besides running faster the only
problem I am having is getting the right values to the dsAdjustment query.
My only problem is getting the right ClearanceID and MagazineID value to the
query.
Is it possible to load a value into the parameters?
I am trying this in the textbox:
=Parameters!MagazineID.Value = Fields!MagazineID.Value
=(Fields!Adjustment.Value, "dsAdjustment")
The problem here is that "=Parameters!MagazineID.Value =Fields!MagazineID.Value" is being treaded like a comparason. The textbox
displays "True" or "False".
Any Ideals?
Scott Burke
"Bruce L-C [MVP]" wrote:
> Read up on subreports. Subreports are exactly for this sort of this.
> Master-detail type reports pretty much must be done using subreports.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Scott Burke" <ScottBurke@.discussions.microsoft.com> wrote in message
> news:A7930198-0781-4DB7-A25E-9EDFBE434C6A@.microsoft.com...
> >I have a report "Clearance Summary Report:
> > Each page summarized the total sales for one agency.
> >
> > Everything works great except for one total "Adjustments:"
> >
> > An agency can have one order but have 50 adjustments to that order.
> > That is why the Adjustments can not be included in the "dsReport" query.
> >
> > For that reason the Adjustments number is calculate with its own query
> > (dsAdjustments). but gets two parameters ClearanceID and MagazineID.
> >
> > NOW the problem.
> > The help file says to create two parameters. ClearanceID and MagazineID.
> > Declear them internal.
> > Link them to the fields: ClearanceID and MagazineID.
> > Then the dsAdjustments query can refreance the paramters ClearanceID and
> > MagazineID.
> >
> > When the report is run the dsAjustments query gets it value from the
> > parameters ClearanceID and MagazineID and then returns a number. That is
> > how
> > I get the adjusments.
> >
> > This works if I lookup only one Agency. But if there are two or more
> > agencies in the report the parameters ClearanceID and MagazineID are only
> > fill in at the begining of the report. All the other Agencies reports ty
> > to
> > use the first agency adjustmets numbers.
> >
> > Question: How do I get the parameters ClearanceID and MagzineID to update
> > for every new Agency''
> >
> > Thank you
> > Scott Burke
> >
>
>|||Don't know why you are losing subreports. I have lots and lots and lots of
subreports. Not only have I never seen this but I have not seen any posting
about losing subreports. Makes me wonder what is unusual about your
environment.
Read up on drill-down (not drill through). Basically you have a single query
that contains all your information. The master information is repeated for
every row. Then you design your report to drill-down (click on a + sign to
see more) OR if you don't want to use drill down UI then you just hide the
master information when it is in the above row.
What you are trying to do will not work.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Scott Burke" <ScottBurke@.discussions.microsoft.com> wrote in message
news:D302FB3A-8351-4C5E-AD1E-0011FCFC6634@.microsoft.com...
> Hi Bruce, This report org used a subreport to produce the totals.
> HOWEVER;
> For some reason unknow to everyone I talked to the Report server tends to
> lose/ can't find the subreport!!!!!
> The last time it happed I had to redeploy the main report. That did not
> work this time.
> We only had the report server for four months! I dont look forward to
> redeploying the CommisionSummaryReport every two months!
> my solution is to replace the subreport. Besides running faster the only
> problem I am having is getting the right values to the dsAdjustment query.
> My only problem is getting the right ClearanceID and MagazineID value to
> the
> query.
> Is it possible to load a value into the parameters?
> I am trying this in the textbox:
> =Parameters!MagazineID.Value = Fields!MagazineID.Value
> =(Fields!Adjustment.Value, "dsAdjustment")
>
> The problem here is that "=Parameters!MagazineID.Value => Fields!MagazineID.Value" is being treaded like a comparason. The textbox
> displays "True" or "False".
> Any Ideals?
> Scott Burke
>
>
> "Bruce L-C [MVP]" wrote:
>> Read up on subreports. Subreports are exactly for this sort of this.
>> Master-detail type reports pretty much must be done using subreports.
>>
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>> "Scott Burke" <ScottBurke@.discussions.microsoft.com> wrote in message
>> news:A7930198-0781-4DB7-A25E-9EDFBE434C6A@.microsoft.com...
>> >I have a report "Clearance Summary Report:
>> > Each page summarized the total sales for one agency.
>> >
>> > Everything works great except for one total "Adjustments:"
>> >
>> > An agency can have one order but have 50 adjustments to that order.
>> > That is why the Adjustments can not be included in the "dsReport"
>> > query.
>> >
>> > For that reason the Adjustments number is calculate with its own query
>> > (dsAdjustments). but gets two parameters ClearanceID and MagazineID.
>> >
>> > NOW the problem.
>> > The help file says to create two parameters. ClearanceID and
>> > MagazineID.
>> > Declear them internal.
>> > Link them to the fields: ClearanceID and MagazineID.
>> > Then the dsAdjustments query can refreance the paramters ClearanceID
>> > and
>> > MagazineID.
>> >
>> > When the report is run the dsAjustments query gets it value from the
>> > parameters ClearanceID and MagazineID and then returns a number. That
>> > is
>> > how
>> > I get the adjusments.
>> >
>> > This works if I lookup only one Agency. But if there are two or more
>> > agencies in the report the parameters ClearanceID and MagazineID are
>> > only
>> > fill in at the begining of the report. All the other Agencies reports
>> > ty
>> > to
>> > use the first agency adjustmets numbers.
>> >
>> > Question: How do I get the parameters ClearanceID and MagzineID to
>> > update
>> > for every new Agency''
>> >
>> > Thank you
>> > Scott Burke
>> >
>>

Change the name of the database from keyboard

When a new window opens in the Query Analyser allmost everytime I need to change the name of the Database from the drop down list.For that I have to click the drop down list in the bar and change.What is the short cut key for that?I mean how can I change the name of the database in the QA from the keyboard without using mouse?

SubhasishOriginally posted by subhasishray
When a new window opens in the Query Analyser allmost everytime I need to change the name of the Database from the drop down list.For that I have to click the drop down list in the bar and change.What is the short cut key for that?I mean how can I change the name of the database in the QA from the keyboard without using mouse?

Subhasish

Do mean change db using code or simply using the keyboard?

u can change the db simply using the keyboard by 'Ctrl-U' and then selecting the db using the up and down arrows.|||or try

use <database name>

change the data results from vertical to horizontally

I have a table that saves data vertical and I need a result query to return
the data in horizontally.
i.e.
id |value
cals |230.5
VitC |14.8
fats |2.3
query results will return
item |cals |vitc |fats
taco |230.5 |14.8 |2.3
salad |123.3 |23 |5.8
any suggestion? Thanks.Xref: TK2MSFTNGP08.phx.gbl microsoft.public.sqlserver.programming:583261
Potentially, you could use a CROSS JOIN or
something like the following:
Create Table MyTable (id VARCHAR(20), value INT)
INSERT INTO MyTable(id, value) VALUES('Cals', 4)
INSERT INTO MyTable(id, value) VALUES('VitC', 2)
INSERT INTO MyTable(id, value) VALUES('fats', 3)
INSERT INTO MyTable(id, value) VALUES('cals', 1)
INSERT INTO MyTable(id, value) VALUES('vitc', 6)
Declare @.str varchar(2000),
@.pattern varchar(200),
@.count int
Set @.str = ''
Set @.pattern = '(Select [name] = value From myTable Where id= [name])
S[count], '
Set @.count = 1
Select
@.str = @.str +
replace(replace(@.pattern,'[name]',''''+i
d+''''),'[count]',@.count),
@.count = @.count + 1
From (Select distinct id From MyTable) A
Select @.str = 'Select * From ' + left(@.str,len(@.str)-1)
Exec(@.str)
Drop Table MyTable
Jack Vamvas
________________________________________
__________________________
Receive free SQL tips - register at www.ciquery.com/sqlserver.htm
SQL Server Performance Audit - check www.ciquery.com/sqlserver_audit.htm
New article by Jack Vamvas - SQL and Markov Chains -
www.ciquery.com/articles/art_04.asp
"Grant" <email@.nowhere.com> wrote in message
news:eZMSxhLLGHA.904@.TK2MSFTNGP10.phx.gbl...
> I have a table that saves data vertical and I need a result query to
return
> the data in horizontally.
>
> i.e.
> id |value
> cals |230.5
> VitC |14.8
> fats |2.3
> query results will return
> item |cals |vitc |fats
> taco |230.5 |14.8 |2.3
> salad |123.3 |23 |5.8
> any suggestion? Thanks.
>|||See KBA 175574 at support.microsoft.com
Anith|||Thanks guys.
"Grant" <email@.nowhere.com> wrote in message
news:eZMSxhLLGHA.904@.TK2MSFTNGP10.phx.gbl...
>I have a table that saves data vertical and I need a result query to return
>the data in horizontally.
>
> i.e.
> id |value
> cals |230.5
> VitC |14.8
> fats |2.3
> query results will return
> item |cals |vitc |fats
> taco |230.5 |14.8 |2.3
> salad |123.3 |23 |5.8
> any suggestion? Thanks.
>

Change the Column_Name Data Type with a query? Possible?

Hi everyone,
Ive got a small question: Is it possible to change the Column_Name Data Type from a SQL table with a query?
I want to do this with a query.
The Data Type ntext must be changed to text
Thanks in advance!i"m not shure what you want

BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_table1
(
kolnew text,
)
GO
IF EXISTS(SELECT * FROM dbo.table1)
EXEC('INSERT INTO dbo.Tmp_table1 (kol)
SELECT CONVERT(text, kolnew) FROM dbo.table1 TABLOCKX')

GO
DROP TABLE dbo.tabla1
GO
EXECUTE sp_rename N'dbo.Tmp_table1', N'table1', 'OBJECT'
commit transaction|||Here you have a screenshot from what I mean: (Edited out - not usefull anymore!)|||so you have the answer|||THX! I'm gonna try it... :D

I hope it works!!

I asked this because off topic 'Euro symbol appears like a '?' instead ''

Friday, February 24, 2012

Change SqlCommand Based On Combo Box Selection

I have a textbox, combo box, and a button on a form. I would like to perform a different query depending on the combo box selection. I thought I could do something such as:

if (cboSearch.Text =="Selection1") { scCmd ="SELECT * FROM tblTable WHERE txtSearch = @.Selection1"; }else if (cboSearch.Text =="Selection2") { scCmd ="SELECT * FROM tblTable WHERE txtSearch = @.Selection2"; }else { scCmd ="SELECT * FROM tblTable WHERE txtSearch = @.Selection3"; }
However, this obviously does not operate as I would need it to. What is the proper method for conditional SqlCommand statements like this?

You need to pass the value in as a Control Parameter.

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.controlparameter.aspx

Change SQL Server query optimizer locking

Hi,

Our app has been distributed on more then 300 different sites.
On one of the sites we get the error "Could not continue scan with NOLOCK due to data movement" indicating that the query optimizer takes a NOLOCK for our select statement ( has been opened with adOpenDynamic, adLockOptimistic ).

It's no option to change the source, we have to solve this without touching the code.

Is there any way to tweak the query optimizer so that our app works correctly?
I know that there will be a reduction of performance but it's our only choose.

thnx in advance,

adOpenDynamic, adLockOptimisticCan you reproduce the same behavior in a lab machine, or only on site?

-PatP|||On our test environment it happens once, then it continues correctly.
But on site the problem is persistent.|||Using NOLOCK on highly voletile data in cursor-based situations is not recommended. What you're experiencing is very typical in high activity in terms of action queries. You will have to change your cursor and lock types.|||I'd suggest fixing the cursor, or trying to run the query at a very low (preferably zero) usage time of day for the tables involved in the query.

-PatP

Change SQL Command at runtime?

I have tried some of the fixes for the other posts but it still doesn't work.
My query looks like this:
SELECT *
FROM table1 AS t1, table1 AS t2
WHERE t1.id =t2.id + @.myParam
I want @.myParam to have a value of =" AND t1.custId=t2.custId "
How can I make this work?Use an expression as your source. Note that once you do this in the dataset
tab that you can no longer execute the query or get the field list returned
so make sure you have the appropriate field list before you change it to an
expression.
="SELECT * FROM table1 AS t1, table1 AS t2 WHERE t1.id =t2.id " &
Parameters!myParam.Value
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"KCBTDev" <KCBTDev@.discussions.microsoft.com> wrote in message
news:95A60AE1-12C4-4CF3-9A82-B037D9E57BFB@.microsoft.com...
>I have tried some of the fixes for the other posts but it still doesn't
>work.
> My query looks like this:
> SELECT *
> FROM table1 AS t1, table1 AS t2
> WHERE t1.id =t2.id + @.myParam
> I want @.myParam to have a value of =" AND t1.custId=t2.custId "
> How can I make this work?|||How do I set the source? This query is a very large query with many other
parameters being used to narrow down the search and return data. I use a
text command type in the data tab.
"Bruce L-C [MVP]" wrote:
> Use an expression as your source. Note that once you do this in the dataset
> tab that you can no longer execute the query or get the field list returned
> so make sure you have the appropriate field list before you change it to an
> expression.
> ="SELECT * FROM table1 AS t1, table1 AS t2 WHERE t1.id =t2.id " &
> Parameters!myParam.Value
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "KCBTDev" <KCBTDev@.discussions.microsoft.com> wrote in message
> news:95A60AE1-12C4-4CF3-9A82-B037D9E57BFB@.microsoft.com...
> >I have tried some of the fixes for the other posts but it still doesn't
> >work.
> >
> > My query looks like this:
> > SELECT *
> > FROM table1 AS t1, table1 AS t2
> > WHERE t1.id =t2.id + @.myParam
> >
> > I want @.myParam to have a value of =" AND t1.custId=t2.custId "
> >
> > How can I make this work?
>
>|||Ok I have it figured out. I left the existing parameters setup as is and
just put a =" at the beginning of the query, a " at the end, and took out all
Carriage Returns and it works. Thanks for all of your help!
"KCBTDev" wrote:
> How do I set the source? This query is a very large query with many other
> parameters being used to narrow down the search and return data. I use a
> text command type in the data tab.
> "Bruce L-C [MVP]" wrote:
> > Use an expression as your source. Note that once you do this in the dataset
> > tab that you can no longer execute the query or get the field list returned
> > so make sure you have the appropriate field list before you change it to an
> > expression.
> >
> > ="SELECT * FROM table1 AS t1, table1 AS t2 WHERE t1.id =t2.id " &
> > Parameters!myParam.Value
> >
> >
> > --
> > Bruce Loehle-Conger
> > MVP SQL Server Reporting Services
> >
> > "KCBTDev" <KCBTDev@.discussions.microsoft.com> wrote in message
> > news:95A60AE1-12C4-4CF3-9A82-B037D9E57BFB@.microsoft.com...
> > >I have tried some of the fixes for the other posts but it still doesn't
> > >work.
> > >
> > > My query looks like this:
> > > SELECT *
> > > FROM table1 AS t1, table1 AS t2
> > > WHERE t1.id =t2.id + @.myParam
> > >
> > > I want @.myParam to have a value of =" AND t1.custId=t2.custId "
> > >
> > > How can I make this work?
> >
> >
> >

Change SQL command at runtime using a stored procedure?

My query looks like this:
SELECT *
FROM table1 AS t1, table1 AS t2
WHERE t1.id =t2.id + @.myParam
I want @.myParam to have a value of =" AND t1.custId=t2.custId "
How can I make this work?
I did have my report working correctly with my source as an expression. But
with added complexities to the query, it will be easier to maintain in a
stored procedure.Sounds like you need to research dynamic sql
"KCBTDev" wrote:
> My query looks like this:
> SELECT *
> FROM table1 AS t1, table1 AS t2
> WHERE t1.id =t2.id + @.myParam
> I want @.myParam to have a value of =" AND t1.custId=t2.custId "
> How can I make this work?
> I did have my report working correctly with my source as an expression. But
> with added complexities to the query, it will be easier to maintain in a
> stored procedure.

Sunday, February 19, 2012

Change results

I have created query As shown:

SELECT distinct [Table] FROM [Database]

The results i get back are A, B & C. What i am trying to do is show a result as a different word.

i.e instead of displaying A is shows in drop down list as Apple, B shows Banana. etc.

Can anyone help please.

Thanks

Duncan:

It sounds to me like what you want to do is to join to a translation table to do a simple lookup; something like?

declare @.source table ( sourceKey varchar(8))
insert into @.source values ('A')
insert into @.source values ('B')
insert into @.source values ('C')

declare @.translate table ( sourceKey varchar(8), xlate varchar (10))
insert into @.translate values ('A', 'Apple')
insert into @.translate values ('B', 'Banana')
insert into @.translate values ('C', 'Cherry')

select xlate as Target
from @.source p
inner join @.translate q
on p.sourceKey = q.sourceKey

-- Target
-- -
-- Apple
-- Banana
-- Cherry

|||

The syntax of your query is not correct. Normally in SQL Server you would use the following:

SELECT [Columns] FROM [Table]

It is good practice to create a lookup table that contains a set of unique shorthand codes or IDs, such as 'A' and 'B' in your example, and an alphanumerical field to contain a description of the code/ID - 'Apple' or 'Banana' in your example. You would then join the fact table to the lookup table and return the appropriate columns from each table.

Could you post your table definitions and the query that you are using to return the data?

Chris

|||Thanks for that. I can see what you've done but the fields i need are carries in a field in a table. there can be only 3 results a b or c. there are alot of records. i don;t see how i can use this to select distinct from field in table but display as something else.|||I must agree with Chris; I don't know where I am going and I'm afraid that I need a roadmap.|||

Query

SELECT distinct [COLUMN] FROM [TABLE]

Returns

A
B
C

What i would like is for it to show

Apple
Banana
Cranberry

It is to populate a drop down list with SSRS. So that the users see what each entry means and not just ABC.

|||

In that case then the answers previously given to your original post will work, however if in the short term you want to make this really simple then you could use this:

SELECT 'Apple' AS [LookupValue], 'A' AS LookupCode UNION
SELECT 'Banana', 'B' UNION
SELECT 'Cranberry', 'C'
ORDER BY 1

The LookupValue is the value that you would display in your drop-down list, the LookupCode is the value that you feed back into the report's main query.

I wouldn't recommend the above approach as you'd need to modify the SELECT statement if you make changes to the reference data - you'd be far better off by using a lookup table as originally suggested, I've provided the example below to show how this can be done.

The choice is yours.

Chris

CREATE TABLE dbo.FruitType
(
FruitTypeCode CHAR(1) NOT NULL PRIMARY KEY,
FruitTypeValue VARCHAR(100) NOT NULL,
)
GO

--Ideally you would declare a Foreign Key constraint between the FruitTypeCode columns in your fact table and the following lookup table.
INSERT INTO dbo.FruitType(FruitTypeCode, FruitTypeValue)
SELECT 'A', 'Apple' UNION
SELECT 'B', 'Banana' UNION
SELECT 'C', 'Cranberry'
GO

--Use this to populate your combo - display FruitTypeValue and feed FruitTypeCode back into the report's main query.
SELECT FruitTypeCode, FruitTypeValue
FROM dbo.FruitType
ORDER BY FruitTypeValue
GO

|||

Ok got it working.

select distinct

case [COLUMN NAME]

when 'A' then 'Apple'

when 'B' then 'Banana'

else 'Unknown'end

from [TABLE NAME]

where [COLUMN NAME] in ('A', 'B', 'C')

Change request: Parameter mapping

In some places in the SSIS enviroment, you can use parameters in queries, for examples in the query part of the OLE DB Command component.

You do this by specifying placeholders using question marks. The question marks result in parameters on the Column Mappings tab of the Advanced Editor named Param_0, Param_1, etc. When adding question marks to the query later on, new parameters are created named Param_<x>, where ‘x’ is the next higher index number, no matter where the question mark appears in the query. If, for example, your initial query contains two parameters and later on you add a third one that appears as the first parameter in the query, it results in a new Param_3 on the Column Mappings tab.

This is all a bit confusing and not very wanted from a maintenance point of view. I know this might be a limitation caused by using OLE DB connections; we tried to do something with ADO.NET connections, but until now, not very succesful. Therefore we think this is something to put on a wish list for a next SSIS version. It would be great to have the opportunity to give parameters a meaningful name, in stead of the question marks in the queries and the generated Param_<x> names in other places.
Hans Geurtsen
MoreInfo BV

I couldn't agree more. I recently had to do the same thing for a pipeline with >50 columns in it. Debugging it when it didn't work was near impossible.

You should raise this request at http://lab.msdn.microsoft.com/productfeedback/default.aspx (and let us know because I will vote for it) and also on the "SSIS Requests" thread at the top of this forum.

-Jamie

Thursday, February 16, 2012

Change query of report in reportviewer

Hi,

I have a reporting services report that i show in an asp.net page by a reportviewer control.

Is there a property that i can set in my asp.net page, to change the query for changing the data in my report.

The number and names of the columns will be the same.

I should work with parameters, but the query changes more than just a few where-clauses. So i think working with parameters looks impossible.

Thanks,

Dennis

Hi,

using parameters is the only way to accomplish it. You can use a stored procedure in conjunction with a parameter which decicde within your stored procedue code which query to execute.

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Excuse me

How Can I do a clr routine with a call to crystal report?

Thanks