Tuesday, March 27, 2012
determine if value in field is number
345, ABC, or CDF
I want to do a select statement on the table to return records where this
field could be number (123, 345) and exclude those that are not (ABC, CDF).
Is there an IsNum function or something like that?
hi matt,
make use of isnumeric function, which returns 1 for valid numeric value.
ex:
select *
from
<table>
where isnumeric(col) = 1
Vishal Parkar
vgparkar@.yahoo.co.in
Wednesday, March 21, 2012
detect log file size
Is there a SQL statement I can use to get the current size of a database's
log file?
Thanks,
DaveEXEC sp_helpfile '<database>_log'
--
Aaron Bertrand, SQL Server MVP
http://www.aspfaq.com/
Please reply in the newsgroups, but if you absolutely
must reply via e-mail, please take out the TRASH.
"David Reynolds" <david_m_reynolds@.hotmail.com> wrote in message
news:9JeQa.21491$lJd1.15720@.news01.bloor.is.net.cable.rogers.com...
> Hello,
> Is there a SQL statement I can use to get the current size of a database's
> log file?
> Thanks,
> Dave
>|||This is a good one too, it gives you the sizes and percentage used for
the log files.
dbcc sqlperf('logspace')
HTH
Ray Higdon MCSE, MCDBA, CCNA
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!sql
Friday, February 24, 2012
Design T-SQL WHERE
I have following statement :
SELECT * FROM Table WHERE Col1>=@.Col1L AND Col1<=@.Col1H AND Col2>=@.Col2L AND Col2<=@.Col2LH AND ... AND ColN>=@.ColNL AND ColN<=@.ColNH
But sometimes variables e.g. @.Col1L and @.Col1H may cover whole range of available values so they will be there for nothing
E.g. It may happen my query will be sufficient if I will have
SELECT * FROM Table WHERE Col1>=@.Col1L AND Col1<=@.Col1H -- and no other columns, because @.Col2L will be lowest possible assignable value and @.Col2H highest possible value, etc.
How should I design this type of query ?
Should I dynamically create WHERE clause e.g.:
IF @.Col2L<>@.MinPossibleValue OR @.Col2H<>@.MaxPossibleValue
SET @.WHERE=@.WHERE + 'Col2>=' + @.Col2L + ' AND Col2<=' + @.Col2LH
...
EXEC(@.Query)
Got any other suggestion for designing query ? Or improving performance ...
Thank you for your opinion.You could use dynamic SQL but it is not worth the effort and complexity to do that. It also depends on the indexes and your search conditions. Below are some links that you should check out:
Dynamic Search Conditions in T-SQL
http://www.sommarskog.se/dyn-search.html
The Curse and Blessings of Dynamic SQL
http://www.sommarskog.se/dynamic_sql.html