Showing posts with label force. Show all posts
Showing posts with label force. Show all posts

Thursday, March 29, 2012

ForEachLoop Container - How to Force Next Iteration -

How can I force a Next Iteration in a ForEach Loop container?

I am looping through a folder(ForEach Loop Container) looking for a specific File Name ( Child 'Script Task') to evaluate name).

If the current file is not the File Name I need, get the next file, other wise drop down to a Exec Proc task.

Is it possible to force "Next Interation' on the parent container?

Thanks - Covi

Not quite sure what you mean. In what circumstances do you want to 'force teh next iteration'?

-Jamie

sql

Monday, March 26, 2012

Forcing use of an index

Hi
Can you force a query to use a particular index. IF so please let me
know the sql statement syntax.
thanks
Newish
Hi
Take a look at "index hints" topic in the BOL
"Newish" <ahussain3@.gmail.com> wrote in message
news:1164198675.592286.139920@.m7g2000cwm.googlegro ups.com...
> Hi
> Can you force a query to use a particular index. IF so please let me
> know the sql statement syntax.
> thanks
> Newish
>

Forcing use of an index

Hi
Can you force a query to use a particular index. IF so please let me
know the sql statement syntax.
thanks
NewishHi
Take a look at "index hints" topic in the BOL
"Newish" <ahussain3@.gmail.com> wrote in message
news:1164198675.592286.139920@.m7g2000cwm.googlegroups.com...
> Hi
> Can you force a query to use a particular index. IF so please let me
> know the sql statement syntax.
> thanks
> Newish
>

Forcing use of an index

Hi
Can you force a query to use a particular index. IF so please let me
know the sql statement syntax.
thanks
NewishHi
Take a look at "index hints" topic in the BOL
"Newish" <ahussain3@.gmail.com> wrote in message
news:1164198675.592286.139920@.m7g2000cwm.googlegroups.com...
> Hi
> Can you force a query to use a particular index. IF so please let me
> know the sql statement syntax.
> thanks
> Newish
>

Forcing size of a field

Hi,
I have a field x varchar(6)
I want force the values at least at 4 char no less
how can i do it?
NULL must be still valid.
Thanks, FilippoUse a CHECK constraint:
CREATE TABLE #t(c1 varchar(6) NULL)
ALTER TABLE #t ADD CONSTRAINT cnstname CHECK (LEN(c1) >= 4)
GO
INSERT INTO #t (c1) VALUES('1234')
GO
INSERT INTO #t (c1) VALUES('123')
GO
INSERT INTO #t (c1) VALUES(NULL)
GO
SELECT * FROM #t
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Filippo Bettinaglio" <anonymous@.discussions.microsoft.com> wrote in message
news:1ed701c53e80$f4885ac0$a601280a@.phx.gbl...
> Hi,
> I have a field x varchar(6)
> I want force the values at least at 4 char no less
> how can i do it?
> NULL must be still valid.
> Thanks, Filippo|||Use a CHECK constraint:
ALTER TABLE Filippo
ADD CONSTRAINT CK_Filippo__len_x_gte_4
CHECK (LEN(x) >=4)
Note that the LEN of NULL is NULL, and NULL>=4 returns UNKNOWN, and that
doesn't violate the CHECK constraint. CHECK constraints (and constraints in
general) are only violated if the expression they check returns FALSE.
Jacco Schalkwijk
SQL Server MVP
"Filippo Bettinaglio" <anonymous@.discussions.microsoft.com> wrote in message
news:1ed701c53e80$f4885ac0$a601280a@.phx.gbl...
> Hi,
> I have a field x varchar(6)
> I want force the values at least at 4 char no less
> how can i do it?
> NULL must be still valid.
> Thanks, Filippo

Forcing section break to odd pages

Hi - I'm new to this forum and fairly new to Crystal. Using 9.0. Because we print two-sided, I need to force a section break to start on next available odd numbered page so that I can treat the printed sections as separate documents (e.g. I don't want 1st page of new section to print on back of preceeding section). These sections are anywhere from 10 - 18 pages in length, and it is a huge report - over 11,000 pages. I'm pretty sure that there is a way to do this but I don't have time to fumble around with it. I already have 10 hours in this one report!

Thanks in advance
RobinI wrote a report recently that needed something simular, prehaps you can try this. The report prints a list of people at a specific place. Sometimes the place (group one) has lots of people and stems onto two pages and other times it fits on one page. As I'm duplex printing, I need to check whether the pages are even or odd and thus to include a page break or not.

In the section expect, I added a new group footer. In both group footer 1a and 1b I checked the 'new page after'. Then in group footer 1b, I added

Right (ToText(PageNumber),1) in ["0","2","4","6","8"]

which causes my report only to add a blank page after group one has finished if the current page number ends in any of the values above.

Hope it helps.

Forcing Query Plans

Is it possible to force a query plan on a Stored procedue. I have attempted the following and i receive a Incorrect syntax near the keyword 'OPTION'. Any ideas?

EXEC testdatabases..testprocedure

OPTION (USE PLAN N'
<ShowPlanXML xmlns=
"http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="0.5"
Build="9.00.1187.07">
<BatchSequence>
<Batch>
<Statements>
...
</Statements>
</Batch>
</BatchSequence>
</ShowPlanXML>
')
GO

You could use OPTION and USE PLAN only with SELECT/INSERT/DELETE/STATEMENTS. So move your plan in body of stored procedures.

If you couldn't change your stored procedure use Plan Guide by sp_create_plan_guide http://msdn2.microsoft.com/en-us/library/ms179880.aspx

Forcing Primary Keys

Hi all,

As our DB has no primary keys or indexes ive taken a copy of all populated tables and tried to force primary keys within a new DB.

the problem is all off the tables have multiple datasets within them, a dataset for each year. This causes all instances of ID numbers to not be unique as they are replicated for every year they are active.

Its a school database so a student who has been here for 3 years will have 3 instances of his ID number, one for each years' data set.

So how do i force primary keys if there is no unique identifier? ive been highlighting both data set and ID columns and setting that combination as the primary key.

Essentially i need to analyse the relationships between the tabls in a diagram and also run some speed tests to see how fast the db works when it has indexes and primary keys.

the reason im writing is that ive done this on ten tables and with another 160 to do im just checking im doing the right thing?

gregCreate a composite primary key of student ID and year number.|||thought so,
ta

greg|||Why do you keep enrollment info (a record for each year of enrollment) in the master table? StudentID should be the only PK in StudentsMaster, and Enrollment should have StudentID as FK.|||Could you create views for each year and put a unique index on each view?|||Yes, you CAN.
No, you SHOULDN'T.|||rdjabarov its not my design, its just the way the company programmed it, its a very bad system, ive alreday had to weed out 400+ tables that werent being used, and it seems instead of introducing foreign keys to child tables they used the studentId and the SetId,

peterlemonjello, i didnt know you could do that, well at least in sql server 2000, thought it was a 2005 feature...ill look into that

blindman, i had read it wasn't a good idea...ill think of an alternative

greg|||Where ever did you read that? Tables need primary keys, and if they don't have a natural unary key then you either create a surrogate key or use a composite key. Creating indexed views would be an odd alternative.|||well this is the thing, im not trying to fix the db so it functions- im just truying to analyse the relationships between tables and see how much faster introducing keys and indexes make my queries run...

as you can imagine the company released the software with no primary keys and expect it to work but im not about to try and fix there mistakes...its purely for my own use...

i really cant believe they have released software like this but i have to work with what i inhereted off my predecessor

greg|||It will run faster if it is indexed, especially clustered indexes as associated with primary keys.
No need to test this concept...

What's more, you can throw indexes on it without affecting the functioning of the operation. You cannot throw constraints on the tables (unique indexes, for example, or primary keys) without potentially causing failures in the crappy code which is doubtless used to access the data.|||Hmmm, really? I wouldn't be so certain, especially without seeing the database, and without knowing what indexes are to be created and what their definitions are. I've seen "index seek" being more expensive than table scan on multiple occasions (of course because of the poor db and/or query design).|||Nothing is certain in life except death and taxes, but the benefits of indexing a table come damn close.|||In general that might be true, but then you find a table with 947 indexes, all of which have the first seven columns... Then discover that only the leftmost index column is ever used in queries!

-PatP|||Yeah, yeah,...|||I've seen "index seek" being more expensive than table scan on multiple occasions (of course because of the poor db and/or query design).The only time I've seen this is as a result of parameter sniffing. Are there other reasons this can occur? ... actually thinking about it now I guess a poorly chosen index (e.g. low selectivity) and an equally poor plan on the part of the optimiser might cause this.

BTW - I am probably just being a pedant but if there are no primary keys then there are no relationships. You will not be investigating the relationships of the tables - you will be creating the relationships. I imagine this is not helpful to the issue in hand at all :)|||Hi all,

yes bit of a can of worms here, to summarize it is the relationships im interested in, i wanna see how the tables should be connected by matching up similar indexes so although ill be cretaing the relationships, as most tables only have one index, it should be pretty close to the original design...

the problem is i need to prove to the management that my systems (access mde's,ade's accessing sql backend) are faster than the db we pay for because there is no primary keys or relationships..and was hoping that by recreating the relationships i could run speed tests to compare against...

cheers

greg|||Relationships don't affect the speed of your db directly. Relationships are logical constraints - they merely ensure your data conforms to certain constraints. As such - you are quite likely to find a fair slew of invalid intries in your tables since these contraints have not existed previously.

However - relationships are typically between primary and foreign keys. Both of these should be indexed. It is these indexes that should be likely to improve the speed of your queries.

HTH

Forcing password changes.

Is there a way to force password changes for SQL logins? I'd like to do some
thing similar to our NT authentication.Hi,
SQL Server do not have password / user policies, so you cant force password
changes or set any other policies for SQL
server authenticated users.
Thanks
Hari
MCDBA
"Francis Kamp" <anonymous@.discussions.microsoft.com> wrote in message
news:E2AD754B-E88B-49D4-ADA0-6F68F8338F5C@.microsoft.com...
> Is there a way to force password changes for SQL logins? I'd like to do
something similar to our NT authentication.|||Not in the current product. You can look forward to this feature in Yukon
http://www.microsoft.com/technet/tr...xt/SQLSYSec.asp
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Francis Kamp" <anonymous@.discussions.microsoft.com> wrote in message
news:E2AD754B-E88B-49D4-ADA0-6F68F8338F5C@.microsoft.com...
> Is there a way to force password changes for SQL logins? I'd like to do
something similar to our NT authentication.

Forcing leading zero

How can I force a number to have leading zeros ?

select '123456' from dual;

I have try using TO_NUMBER :

select TO_NUMBER('123456','00999999') from dual;

But it doesn't seems to work. It will conserve the leading zeros but I want to add some.Hehe.. sorry I get it, I just have to use TO_CHAR instead of TO_NUMBER|||Thats the way it is :)

Greetz

Manfred Peter
(Alligator Company)
http://www.alligatorsql.com

Forcing display of QA's buffer

How can I force the contents of Query Analyzer's buffer to display to the
screen?
A stored proc has some debug PRINT statements in it. The proc takes a long
time to execute and the PRINT statements don't display until execution is
complete.
Is it possible to force them to display immediately? If so, how?How about RAISERROR WITH NOWAIT? Watch the messages pane:
PRINT 'foo'
WAITFOR DELAY '00:00:05'
GO
RAISERROR('foo', 11, 1) WITH NOWAIT
WAITFOR DELAY '00:00:05'
GO
http://www.aspfaq.com/
(Reverse address to reply.)
"Dave" <dave@.nospam.ru> wrote in message
news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
> How can I force the contents of Query Analyzer's buffer to display to the
> screen?
> A stored proc has some debug PRINT statements in it. The proc takes a
long
> time to execute and the PRINT statements don't display until execution is
> complete.
> Is it possible to force them to display immediately? If so, how?
>|||Thanks Aaron
That works and it also prints out any unprinted PRINT statements previous to
the RAISERROR.
THe red error messages are a distraction but I can live with that.
Thank you.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> How about RAISERROR WITH NOWAIT? Watch the messages pane:
>
> PRINT 'foo'
> WAITFOR DELAY '00:00:05'
> GO
> RAISERROR('foo', 11, 1) WITH NOWAIT
> WAITFOR DELAY '00:00:05'
> GO
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Dave" <dave@.nospam.ru> wrote in message
> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
> > How can I force the contents of Query Analyzer's buffer to display to
the
> > screen?
> >
> > A stored proc has some debug PRINT statements in it. The proc takes a
> long
> > time to execute and the PRINT statements don't display until execution
is
> > complete.
> >
> > Is it possible to force them to display immediately? If so, how?
> >
> >
>|||Even better, use a severity of 10 or lower to emulate what PRINT does (i.e.,
no error condition raised)...
--
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> How about RAISERROR WITH NOWAIT? Watch the messages pane:
>
> PRINT 'foo'
> WAITFOR DELAY '00:00:05'
> GO
> RAISERROR('foo', 11, 1) WITH NOWAIT
> WAITFOR DELAY '00:00:05'
> GO
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Dave" <dave@.nospam.ru> wrote in message
> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
> > How can I force the contents of Query Analyzer's buffer to display to
the
> > screen?
> >
> > A stored proc has some debug PRINT statements in it. The proc takes a
> long
> > time to execute and the PRINT statements don't display until execution
is
> > complete.
> >
> > Is it possible to force them to display immediately? If so, how?
> >
> >
>|||Good point, just in the habit of using 11.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:egrs6xbHFHA.720@.TK2MSFTNGP10.phx.gbl...
> Even better, use a severity of 10 or lower to emulate what PRINT does
(i.e.,
> no error condition raised)...
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> > How about RAISERROR WITH NOWAIT? Watch the messages pane:
> >
> >
> > PRINT 'foo'
> > WAITFOR DELAY '00:00:05'
> > GO
> > RAISERROR('foo', 11, 1) WITH NOWAIT
> > WAITFOR DELAY '00:00:05'
> > GO
> >
> >
> > --
> > http://www.aspfaq.com/
> > (Reverse address to reply.)
> >
> >
> >
> >
> > "Dave" <dave@.nospam.ru> wrote in message
> > news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
> > > How can I force the contents of Query Analyzer's buffer to display to
> the
> > > screen?
> > >
> > > A stored proc has some debug PRINT statements in it. The proc takes a
> > long
> > > time to execute and the PRINT statements don't display until execution
> is
> > > complete.
> > >
> > > Is it possible to force them to display immediately? If so, how?
> > >
> > >
> >
> >
>|||> THe red error messages are a distraction but I can live with that.
Just follow Adam's advice and lower the severity level.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Dave" <dave@.nospam.ru> wrote in message news:emHu5xbHFHA.3780@.TK2MSFTNGP10.phx.gbl...
> Thanks Aaron
> That works and it also prints out any unprinted PRINT statements previous to
> the RAISERROR.
> THe red error messages are a distraction but I can live with that.
> Thank you.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
>> How about RAISERROR WITH NOWAIT? Watch the messages pane:
>>
>> PRINT 'foo'
>> WAITFOR DELAY '00:00:05'
>> GO
>> RAISERROR('foo', 11, 1) WITH NOWAIT
>> WAITFOR DELAY '00:00:05'
>> GO
>>
>> --
>> http://www.aspfaq.com/
>> (Reverse address to reply.)
>>
>>
>> "Dave" <dave@.nospam.ru> wrote in message
>> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
>> > How can I force the contents of Query Analyzer's buffer to display to
> the
>> > screen?
>> >
>> > A stored proc has some debug PRINT statements in it. The proc takes a
>> long
>> > time to execute and the PRINT statements don't display until execution
> is
>> > complete.
>> >
>> > Is it possible to force them to display immediately? If so, how?
>> >
>> >
>>
>|||Got it.
Thanks
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uj4f94bHFHA.3624@.tk2msftngp13.phx.gbl...
> > THe red error messages are a distraction but I can live with that.
> Just follow Adam's advice and lower the severity level.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Dave" <dave@.nospam.ru> wrote in message
news:emHu5xbHFHA.3780@.TK2MSFTNGP10.phx.gbl...
> > Thanks Aaron
> >
> > That works and it also prints out any unprinted PRINT statements
previous to
> > the RAISERROR.
> >
> > THe red error messages are a distraction but I can live with that.
> >
> > Thank you.
> >
> >
> > "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> > news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> >> How about RAISERROR WITH NOWAIT? Watch the messages pane:
> >>
> >>
> >> PRINT 'foo'
> >> WAITFOR DELAY '00:00:05'
> >> GO
> >> RAISERROR('foo', 11, 1) WITH NOWAIT
> >> WAITFOR DELAY '00:00:05'
> >> GO
> >>
> >>
> >> --
> >> http://www.aspfaq.com/
> >> (Reverse address to reply.)
> >>
> >>
> >>
> >>
> >> "Dave" <dave@.nospam.ru> wrote in message
> >> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
> >> > How can I force the contents of Query Analyzer's buffer to display to
> > the
> >> > screen?
> >> >
> >> > A stored proc has some debug PRINT statements in it. The proc takes
a
> >> long
> >> > time to execute and the PRINT statements don't display until
execution
> > is
> >> > complete.
> >> >
> >> > Is it possible to force them to display immediately? If so, how?
> >> >
> >> >
> >>
> >>
> >
> >
>|||did you try using "results in text" instead of "results in grid"?
Dave wrote:
> How can I force the contents of Query Analyzer's buffer to display to the
> screen?
> A stored proc has some debug PRINT statements in it. The proc takes a long
> time to execute and the PRINT statements don't display until execution is
> complete.
> Is it possible to force them to display immediately? If so, how?|||SQL Server doesn't send its output to the client immediately as it is generated by the engine. This
is to consume less network resources. And this is the reason why we don't see things like PRINT
immediately after they have been performed. SQL Server will wait until its output buffer is full, or
until the batch has ended. The trick with RAISERROR and NOWAIT is that it forces SQL Server to flush
the output buffer.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"ch" <ch@.dontemailme.com> wrote in message news:42237E8F.7DC18B52@.dontemailme.com...
> did you try using "results in text" instead of "results in grid"?
>
> Dave wrote:
>> How can I force the contents of Query Analyzer's buffer to display to the
>> screen?
>> A stored proc has some debug PRINT statements in it. The proc takes a long
>> time to execute and the PRINT statements don't display until execution is
>> complete.
>> Is it possible to force them to display immediately? If so, how?|||> The trick with RAISERROR and NOWAIT is that it forces SQL Server to flush
> the output buffer.
Right, this is why you usually see the PRINT and the RAISERROR come to the
messages pane at roughly the same time, even if the PRINT is issued before a
delay and the RAISERROR comes after.
--
http://www.aspfaq.com/
(Reverse address to reply.)

Forcing display of QA's buffer

How can I force the contents of Query Analyzer's buffer to display to the
screen?
A stored proc has some debug PRINT statements in it. The proc takes a long
time to execute and the PRINT statements don't display until execution is
complete.
Is it possible to force them to display immediately? If so, how?
How about RAISERROR WITH NOWAIT? Watch the messages pane:
PRINT 'foo'
WAITFOR DELAY '00:00:05'
GO
RAISERROR('foo', 11, 1) WITH NOWAIT
WAITFOR DELAY '00:00:05'
GO
http://www.aspfaq.com/
(Reverse address to reply.)
"Dave" <dave@.nospam.ru> wrote in message
news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
> How can I force the contents of Query Analyzer's buffer to display to the
> screen?
> A stored proc has some debug PRINT statements in it. The proc takes a
long
> time to execute and the PRINT statements don't display until execution is
> complete.
> Is it possible to force them to display immediately? If so, how?
>
|||Even better, use a severity of 10 or lower to emulate what PRINT does (i.e.,
no error condition raised)...
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...[vbcol=seagreen]
> How about RAISERROR WITH NOWAIT? Watch the messages pane:
>
> PRINT 'foo'
> WAITFOR DELAY '00:00:05'
> GO
> RAISERROR('foo', 11, 1) WITH NOWAIT
> WAITFOR DELAY '00:00:05'
> GO
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Dave" <dave@.nospam.ru> wrote in message
> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
the[vbcol=seagreen]
> long
is
>
|||Thanks Aaron
That works and it also prints out any unprinted PRINT statements previous to
the RAISERROR.
THe red error messages are a distraction but I can live with that.
Thank you.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...[vbcol=seagreen]
> How about RAISERROR WITH NOWAIT? Watch the messages pane:
>
> PRINT 'foo'
> WAITFOR DELAY '00:00:05'
> GO
> RAISERROR('foo', 11, 1) WITH NOWAIT
> WAITFOR DELAY '00:00:05'
> GO
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Dave" <dave@.nospam.ru> wrote in message
> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
the[vbcol=seagreen]
> long
is
>
|||Good point, just in the habit of using 11.
http://www.aspfaq.com/
(Reverse address to reply.)
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:egrs6xbHFHA.720@.TK2MSFTNGP10.phx.gbl...
> Even better, use a severity of 10 or lower to emulate what PRINT does
(i.e.,
> no error condition raised)...
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> the
> is
>
|||> THe red error messages are a distraction but I can live with that.
Just follow Adam's advice and lower the severity level.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Dave" <dave@.nospam.ru> wrote in message news:emHu5xbHFHA.3780@.TK2MSFTNGP10.phx.gbl...
> Thanks Aaron
> That works and it also prints out any unprinted PRINT statements previous to
> the RAISERROR.
> THe red error messages are a distraction but I can live with that.
> Thank you.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> the
> is
>
|||Got it.
Thanks
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uj4f94bHFHA.3624@.tk2msftngp13.phx.gbl...
> Just follow Adam's advice and lower the severity level.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Dave" <dave@.nospam.ru> wrote in message
news:emHu5xbHFHA.3780@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
previous to[vbcol=seagreen]
a[vbcol=seagreen]
execution
>
|||did you try using "results in text" instead of "results in grid"?
Dave wrote:
> How can I force the contents of Query Analyzer's buffer to display to the
> screen?
> A stored proc has some debug PRINT statements in it. The proc takes a long
> time to execute and the PRINT statements don't display until execution is
> complete.
> Is it possible to force them to display immediately? If so, how?
|||SQL Server doesn't send its output to the client immediately as it is generated by the engine. This
is to consume less network resources. And this is the reason why we don't see things like PRINT
immediately after they have been performed. SQL Server will wait until its output buffer is full, or
until the batch has ended. The trick with RAISERROR and NOWAIT is that it forces SQL Server to flush
the output buffer.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"ch" <ch@.dontemailme.com> wrote in message news:42237E8F.7DC18B52@.dontemailme.com...[vbcol=seagreen]
> did you try using "results in text" instead of "results in grid"?
>
> Dave wrote:
|||> The trick with RAISERROR and NOWAIT is that it forces SQL Server to flush
> the output buffer.
Right, this is why you usually see the PRINT and the RAISERROR come to the
messages pane at roughly the same time, even if the PRINT is issued before a
delay and the RAISERROR comes after.
http://www.aspfaq.com/
(Reverse address to reply.)

Friday, March 23, 2012

Forcing display of QA's buffer

How can I force the contents of Query Analyzer's buffer to display to the
screen?
A stored proc has some debug PRINT statements in it. The proc takes a long
time to execute and the PRINT statements don't display until execution is
complete.
Is it possible to force them to display immediately? If so, how?How about RAISERROR WITH NOWAIT? Watch the messages pane:
PRINT 'foo'
WAITFOR DELAY '00:00:05'
GO
RAISERROR('foo', 11, 1) WITH NOWAIT
WAITFOR DELAY '00:00:05'
GO
http://www.aspfaq.com/
(Reverse address to reply.)
"Dave" <dave@.nospam.ru> wrote in message
news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
> How can I force the contents of Query Analyzer's buffer to display to the
> screen?
> A stored proc has some debug PRINT statements in it. The proc takes a
long
> time to execute and the PRINT statements don't display until execution is
> complete.
> Is it possible to force them to display immediately? If so, how?
>|||Even better, use a severity of 10 or lower to emulate what PRINT does (i.e.,
no error condition raised)...
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> How about RAISERROR WITH NOWAIT? Watch the messages pane:
>
> PRINT 'foo'
> WAITFOR DELAY '00:00:05'
> GO
> RAISERROR('foo', 11, 1) WITH NOWAIT
> WAITFOR DELAY '00:00:05'
> GO
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Dave" <dave@.nospam.ru> wrote in message
> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
the[vbcol=seagreen]
> long
is[vbcol=seagreen]
>|||Thanks Aaron
That works and it also prints out any unprinted PRINT statements previous to
the RAISERROR.
THe red error messages are a distraction but I can live with that.
Thank you.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> How about RAISERROR WITH NOWAIT? Watch the messages pane:
>
> PRINT 'foo'
> WAITFOR DELAY '00:00:05'
> GO
> RAISERROR('foo', 11, 1) WITH NOWAIT
> WAITFOR DELAY '00:00:05'
> GO
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Dave" <dave@.nospam.ru> wrote in message
> news:uyWPdkbHFHA.2784@.TK2MSFTNGP09.phx.gbl...
the[vbcol=seagreen]
> long
is[vbcol=seagreen]
>|||Good point, just in the habit of using 11.
http://www.aspfaq.com/
(Reverse address to reply.)
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:egrs6xbHFHA.720@.TK2MSFTNGP10.phx.gbl...
> Even better, use a severity of 10 or lower to emulate what PRINT does
(i.e.,
> no error condition raised)...
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> the
> is
>|||> THe red error messages are a distraction but I can live with that.
Just follow Adam's advice and lower the severity level.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Dave" <dave@.nospam.ru> wrote in message news:emHu5xbHFHA.3780@.TK2MSFTNGP10.phx.gbl...[vbcol
=seagreen]
> Thanks Aaron
> That works and it also prints out any unprinted PRINT statements previous
to
> the RAISERROR.
> THe red error messages are a distraction but I can live with that.
> Thank you.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:uVVzjnbHFHA.4048@.TK2MSFTNGP15.phx.gbl...
> the
> is
>[/vbcol]|||Got it.
Thanks
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uj4f94bHFHA.3624@.tk2msftngp13.phx.gbl...
> Just follow Adam's advice and lower the severity level.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Dave" <dave@.nospam.ru> wrote in message
news:emHu5xbHFHA.3780@.TK2MSFTNGP10.phx.gbl...
previous to[vbcol=seagreen]
a[vbcol=seagreen]
execution[vbcol=seagreen]
>|||did you try using "results in text" instead of "results in grid"?
Dave wrote:
> How can I force the contents of Query Analyzer's buffer to display to the
> screen?
> A stored proc has some debug PRINT statements in it. The proc takes a lon
g
> time to execute and the PRINT statements don't display until execution is
> complete.
> Is it possible to force them to display immediately? If so, how?|||SQL Server doesn't send its output to the client immediately as it is genera
ted by the engine. This
is to consume less network resources. And this is the reason why we don't se
e things like PRINT
immediately after they have been performed. SQL Server will wait until its o
utput buffer is full, or
until the batch has ended. The trick with RAISERROR and NOWAIT is that it fo
rces SQL Server to flush
the output buffer.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"ch" <ch@.dontemailme.com> wrote in message news:42237E8F.7DC18B52@.dontemailme.com...[vbcol=s
eagreen]
> did you try using "results in text" instead of "results in grid"?
>
> Dave wrote:|||> The trick with RAISERROR and NOWAIT is that it forces SQL Server to flush
> the output buffer.
Right, this is why you usually see the PRINT and the RAISERROR come to the
messages pane at roughly the same time, even if the PRINT is issued before a
delay and the RAISERROR comes after.
http://www.aspfaq.com/
(Reverse address to reply.)sql

Forcing a set number of result rows in a query

I'm trying to select 5 rows of data from a query. Sometimes there is less than 5 rows of data in the result set.

Is there a way to FORCE a return of 5 rows - even if they don't exist? For example, returning some text such as "No Data" or NULL in the result set?

What I'm doing to return 5 rows of data:

Select top 5 *

From MyTable

I need help modifying this query to make sure I always get 5 rows of data.

Thanks!

There is no pre-defined settings available but you do something below,

Code Snippet

Create table #Data(

Id int,

Name varchar(100)

)

Insert Into #Data Values(1,100)

Insert Into #Data Values(2,100)

Insert Into #Data Values(3,100)

Select Top 5 * From

(

Select Id, Name from #Data

Union ALL

Select NULL, NULL

Union ALL

Select NULL, NULL

Union ALL

Select NULL, NULL

Union ALL

Select NULL, NULL

Union ALL

Select NULL, NULL

)

as Data

Order By Case When Id is NULL Then 1 Else 0 End , ID

|||

Code Snippet

CREATE TABLE #temp (test int)

INSERT INTO #temp SELECT 1

INSERT INTO #temp SELECT 2

INSERT INTO #temp SELECT 3

DECLARE @.counter as int

set @.counter = (SELECT COUNT(*) from #temp)

SELECT * FROM #temp

WHILE @.counter < 5

BEGIN

INSERT INTO #temp SELECT NULL

SET @.counter = @.counter + 1

END

SELECT * FROM #temp

DROP TABLE #temp

Adamus

|||Thanks for the prompt replies - both of these replies were helpful and answered my question!

Forcing a package to run as 32 bit on a x64 machine using SQL Server Agent?

I have a need to force a package to run using the 32-bit runtime from the SQL Server Agent. The machine is a x64 unit. I'm having to use an ODBC driver to extract data from our ERP package that will only run in 32 bit. Any help would be appreciated.

Hi.

Here is another suggestion: run distributed queries through SqlExpress/32. Here is a sample for MS Access:

http://gorm-braarvig.blogspot.com/2005/11/access-database-from-sql-200564.html

Hope this helps

|||

In Agent, use an Operating System (CmdExec) step and use the copy of dtexec.exe in C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn

hth

Donald Farmer

|||Thanks, Donald. That worked like a charm.sql

Forcing a delete of a table even if a program is connected.

Hello All,

Is it possible to force a delete of a table even when another program is using that DB, and still has some view data on that specific table.

I know that I can delete tables if another program is just have connection to the DB, but not using the specific table I'd like to delete. Can it be done also on a viewed table?

You cannot delete (or alter) a table if there is an open cursor on it: the engine refuses to do so.

|||

Thanks for your answer,

If so, is there a way to force a complete disconnect of a specific DB, then to delete the table?

|||Not that I know of...

Forcing a branch with decision trees

In a decision tree algorithm, is there a known way to force a branch at a top level? For exmaple, I have 30 known decision patterns that are going to be completely different and I don't want them to intermingle. I wanted to force a branch at the top node on one of the 30 patterns so I wouldn't have to create 30 mining models per client.

Brian

Interactive training of models (including partial tree definition) is not supported in SQL Server 2005 Data Mining.

In many cases, instead of 30 models per client it is possible to create a single model containing 30 trees, by using a nested table (which, effectively, has the same effect as forcing a branch at the top). This works easily, for instance, if your target variable has 30 states.

Could you please provide a few details on your known decision patterns?

|||

Bogdan, thanks for the answer!

The project essentially has two nested tables of terms (from SSIS' term extraction) that a specific item uses. Each item is in the parent case table 30 times (once per group,state or view based on your vocabulary you'd like to choose). The state (or group) is an input into the model and it does seem to work great for some of the states but not others and that's why I was trying to force it to break at the state level.

Essentially, we're trying to determine that if a record mentions term X, Y and Z that it's a great item to client. The problem is that it's a great item to show one group of clients but not others (based on their state).

Brian

|||I was able to get the model to branch by changing the scoring mechanism and by making the value that I was trying to force the break on discrete. Thanks again for your help. Is there any plans in future releases to enable users to force a break?sql

Forcing a branch with decision trees

In a decision tree algorithm, is there a known way to force a branch at a top level? For exmaple, I have 30 known decision patterns that are going to be completely different and I don't want them to intermingle. I wanted to force a branch at the top node on one of the 30 patterns so I wouldn't have to create 30 mining models per client.

Brian

Interactive training of models (including partial tree definition) is not supported in SQL Server 2005 Data Mining.

In many cases, instead of 30 models per client it is possible to create a single model containing 30 trees, by using a nested table (which, effectively, has the same effect as forcing a branch at the top). This works easily, for instance, if your target variable has 30 states.

Could you please provide a few details on your known decision patterns?

|||

Bogdan, thanks for the answer!

The project essentially has two nested tables of terms (from SSIS' term extraction) that a specific item uses. Each item is in the parent case table 30 times (once per group,state or view based on your vocabulary you'd like to choose). The state (or group) is an input into the model and it does seem to work great for some of the states but not others and that's why I was trying to force it to break at the state level.

Essentially, we're trying to determine that if a record mentions term X, Y and Z that it's a great item to client. The problem is that it's a great item to show one group of clients but not others (based on their state).

Brian

|||I was able to get the model to branch by changing the scoring mechanism and by making the value that I was trying to force the break on discrete. Thanks again for your help. Is there any plans in future releases to enable users to force a break?

Force View || Create View Accessing view that has not been created yet?

Hello All.

Does Sql 2005 support forced-later-compliation? Which is to say, can I create a view that access another view which has not been created yet? e.g. "Create Force View Foo" in Oracle.

Thanks,

Steve

You can only do that for stored procedures. This is known and filed in the BOL under "Deferred Name Resolution".

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de
sql

Force users/connections to disconnect from db

Hello,
I need to attach and detach 50 DB's, for which I have wrote a simple script. How can I make sure that there are no connections or users connected to the DB's, if there any users how can I forcefully disconnect them.
Thanks
DakkiOriginally posted by Dakki
Hello,

I need to attach and detach 50 DB's, for which I have wrote a simple script. How can I make sure that there are no connections or users connected to the DB's, if there any users how can I forcefully disconnect them.

Thanks
Dakki

sp_detachDB does detach a db even if users are logged in. Only if transactions are running, dettach will fail. sp_who shows you for every db on this server all logged in users.

Hope this helps
Peter|||Originally posted by peterdbd
sp_detachDB does detach a db even if users are logged in. Only if transactions are running, dettach will fail. sp_who shows you for every db on this server all logged in users.

Hope this helps
Peter

Excellent, I shall try this...

many thanks

dakki|||peterdbd,

i don't think it's an accurate statement, because you'll get this error if there is at least 1 connection open for the database you're trying to detach, even if this connection has not performed a single operation:

Server: Msg 3701, Level 16, State 1, Line 1
Cannot detach the database 'db_name' because it is currently in use.|||guru, you are right, I had to re run the script, since some of the db's had connections to it...

thanks again, to you both ...|||list all users with sp_who2
and find out sid of all the db u r looking at

using sa , kill all sid

eg:- kill sid

then proceed with detach.

Note:-
Do not any sid doing updates...|||Take help from this link (http://www.sql-server-performance.com/q&a37.asp) which includes the script to kill are users that are connected to a database that needs to be dropped/detached etc. etc.:cool:|||there are 3 problems with the script:

- based on stored procedure. i wouldn't recommend leaving such tool so handy

- based on cursor, - simply no need

- does not take into account the possibility of attempting to kill yourself (not that you'll succeed though)

there is a simpler way:

declare @.cmd varchar(100)
while (select count(*)
from master.dbo.sysprocesses (nolock)
where spid != @.@.spid and db_name(dbid) = 'your_db_name') > 0 begin
set @.cmd = 'kill ' +(select cast(min(spid) as varchar(25))
from master.dbo.sysprocesses (nolock)
where spid != @.@.spid and db_name(dbid) = 'mci2k')
exec ( @.cmd )
end