DB_NAME Anomaly

Dec 7, 2004

On my SP3 db_name(0) and db_name(1) are returning the same thing. Can anybody else try this? Beta of Yukon is doing the same thing...But the following code returns 1:

select db_id(db_name(0))

View 3 Replies


ADVERTISEMENT

Cannot Run Dynamic Sql Using 'USE DB_Name' Statement

Feb 4, 2002

For whatever reason, the following when executed does not take the context of the supplied Database name. Any ideas as to why? More importantly is there a work around. I am trying to create a database level batch job.

declare @sql nvarchar(100)
set @sql = 'USE Northwind'
print @sql
EXEC sp_executesql @sql


Thanks,

Mark

View 1 Replies View Related

How Submit Db_name() As Default Parameter ?

Mar 8, 2006

Hi,
I want to submit db name as as default parameter when calling procedure WITHOUT using variables

Example
use master
go

create procedure get_caller_db @s sysname = DB_NAME() --produce error
as
select @s as [caller db name]

go
use mySuperDB
exec master.dbo.get_caller_db
--
caller db name
--------------
mySuperDB -- result I want

View 2 Replies View Related

URGENT HELP PLS: Select Substring('NY',status/1024&&1+1,1) From Master..sysdatabases Where Name=DB_NAME()

Jul 20, 2005

Hi Everyone,All the very best for 2004!!i need urgent help with this problem, the users are about to skin mealive!!we have an access front end with linked to sql server 2k tables.when a user tries to insert a record into one of the tables it"randomly" returns a generic ODBC error and fails to save. on otheroccasions the same record will save.a trace was applied and the following select seemed to appear rightafter the insert statement whenever it failed:select substring('NY',status/1024&1+1,1) from master..sysdatabaseswhere name=DB_NAME()i had a look at other articles in the groups re this select statement,but could not find a clear answer.i have tried the insert statements as both SQL pass throughs and justplain docmd.runsql'scan someone help me with the following:* what is the purpose of the select?* what other investigations can i do to get more info on why thisshould be happening?* how can i stop it?the table i am doing the inserts into is showing as have a numericdata type field in sqlserver, but the linked table shows this numericfield as text - could this be the problem?? this field is not used inthe insert statement.i could not find any references in the MS knowledge base.any and all help would very gratefully received.Edwinah63

View 2 Replies View Related

Anomaly With NULL

Dec 26, 2014

why these two SQL codes return same result 0?

select CASE WHEN NULL IN ('123') THEN 1 ELSE 0 END AS Test
select CASE WHEN NOT NULL IN ('123') THEN 1 ELSE 0 END AS Test

View 2 Replies View Related

Interesting Peculiarity (another Anomaly?)

Dec 8, 2004

Run the following: declare @s1 varchar(10), @s2 varchar(10) declare @t table( recordid int identity(1,1)not null,field char(1)not null) insert @t (field) select 'a' union select 'b'select @s1 = '', @s2 = ''select @s1 = @s1 + field +',' from @t order by 1select @s2 = @s2 + field +','from @t order by recordidselect[Weird]=substring(@s1, 1,(datalength(@s1)-1)),[Not]=substring(@s2, 1,(datalength(@s2)-1))

View 2 Replies View Related

SQL 2000 Install Anomaly

Jul 20, 2005

Hi allIn a new installation, if the data directory is stipulated as d:data, itinstalls alldata in d:dataMSSQLdata.I need to place the data in d:mssql7data to incorporate backsup from olddata backuspAny ideas ?CheersRay

View 4 Replies View Related

Unallocated Space Anomaly

Jul 20, 2005

At my current workplace, whenever I check table sizes using the'reserved' column from sysindexes, or sp_spaceused, I get a total forall user tables which exceeds the physical size of the database.Running sp_spaceused with no parameteres, I get a NEGATIVE value forunallocated space in the database, but only see this if I return theresults in GRID format in QA (text format gives less output):DatabaseName DatabaseSize Unallocated Spacexxxxx_xxxxx11502.38 MB-4874.80 MBReserved Data index_size unused16602800 KB7013752 KB2381904 KB7207144 KBIf I re-run sp_spaceused with the @updateusage='TRUE' option, thisoutput gets corrected to:DatabaseName DatabaseSize Unallocated Spacexxxxx_xxxxx11502.38 MB2773.76 MBReserved Data index_size unused8770680 KB6928168 KB1808096 KB34416 KBwhich shows a substantial difference in the Reserved/Data/Index/Unusedsizes.This happens every day - any ideas about:1) Why this might be happening on such a large scale, and2) Is it conceivable that these discrepancies in space allocationinformation could be causing performance problems? I can imagine thatif the database is trying to locate free pages on extents yet itsinternal view of these doesn't match reality then this could impededata insertion.Offers anybody?

View 2 Replies View Related

SQL 2005 SSIS Anomaly

Jun 4, 2007

I've sure I have a problem that hasn't been addressed on the forum exactly. I have a SQL 2000 database that the SSIS designer sees, meaning it is a member of the 'Server Explorer' group. I am trying to update my SQL 2005 database based on values from a SQL 2000 database table using an OLE DB Command data flow transformation. I use a SELECT query in the OLE DB Source control to get the required columns. I use an UPDATE statement to identify where to place the columns retrieved from the source. I get an error that tells me that the update statement fails because it can't identify the SQL 2000 database I am trying to use. The highlighted part of the error is something I haven't seen in the similar posts I've read. And, it's ironic because the server is actually 'linked'.

Error 1
Validation error. Import Moving Averages and Open Interest Data: OLE DB Command [3411]: An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Could not find server 'SIR-Research' in sysservers. Execute sp_addlinkedserver to add the server to sysservers.". Prices_MA_OI.dtsx 0 0

Here is the SELECT statement:
SELECT
Equity_Moving_Averages.m_d_y,
Equity_Moving_Averages.Ticker_symbol,
Equity_Moving_Averages.MA_10, Equity_Moving_Averages.MA_20, Equity_Moving_Averages.MA_30, Equity_Moving_Averages.MA_40,
Equity_Moving_Averages.MA_50, Equity_Moving_Averages.MA_80, Equity_Moving_Averages.MA_100, Equity_Moving_Averages.MA_160,
Equity_Moving_Averages.MA_200, OI_Data.OI_Call, OI_Data.OI_Call_Pricewgt, OI_Data.OI_Put, OI_Data.OI_Put_Pricewgt, OI_Data.PCRatio,
OI_Data.pcratio_pricewgt, OI_Data.PctRank365, OI_Data.PC_Diff
FROM Equity_Moving_Averages INNER JOIN
OI_Data ON Equity_Moving_Averages.m_d_y = OI_Data.m_d_y AND Equity_Moving_Averages.Ticker_symbol = OI_Data.Ticker_Symbol
--

Here is the UPDATE statement:
UPDATE [dbo].[Equity_Price_DIM]
SET [10day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_10
, [100day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_100
, [160day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_160
, [20day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_20
, [200day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_200
, [30day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_30
, [40day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_40
, [50day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_50
, [80day_moving_average] = [SIR-Research].internet.dbo.Equity_Moving_Averages.MA_80
, open_interest_call = [SIR-Research].internet.dbo.OI_Data.OI_Call
, oi_call_priceweight = [SIR-Research].internet.dbo.OI_Data.OI_Call_Pricewgt
, open_interest_put = [SIR-Research].internet.dbo.OI_Data.OI_Put
, oi_put_priceweight = [SIR-Research].internet.dbo.OI_Data.OI_Put_Pricewgt
, oi_put_call_difference = [SIR-Research].internet.dbo.OI_Data.PC_Diff
, oi_put_call_ratio = [SIR-Research].internet.dbo.OI_Data.PCRatio
, oi_pcratio_priceweight = [SIR-Research].internet.dbo.OI_Data.pcratio_pricewgt
, oi_percent_rank365 = [SIR-Research].internet.dbo.OI_Data.PctRank365
FROM [dbo].[Equity_Price_DIM] INNER JOIN [SIR-Research].internet.dbo.Equity_Moving_Averages
ON [dbo].[Equity_Price_DIM].prices_market_date = [SIR-Research].internet.dbo.Equity_Moving_Averages.m_d_y
AND [dbo].[Equity_Price_DIM].prices_ticker_symbol = [SIR-Research].internet.dbo.Equity_Moving_Averages.Ticker_symbol
LEFT OUTER JOIN [SIR-Research].internet.dbo.OI_Data
ON [dbo].[Equity_Price_DIM].prices_market_date = [SIR-Research].internet.dbo.OI_Data.m_d_y
AND [dbo].[Equity_Price_DIM].prices_ticker_symbol = [SIR-Research].internet.dbo.OI_Data.Ticker_Symbol
--

Any help will be greatly appreciated.

Dave W.

View 3 Replies View Related

Clustering For Anomaly Detection

Mar 14, 2008

Hi,

I have been trying to use the Clustering algorithm for Anomaly Detection, but it has been quite difficult to get correct results for PredictCaseLikelihood.
Using a very large number of clusters helped, but there are other problems.
The algorithm does not take into account all the columns in my nested table, but only uses Exists/Not Exists for the nested table key column. In my case the nested table contains also a column with a count of key attribute.

I am about to abandon the Sql Data Mining.

Does anyone have more insights into tuning the Clustering algorithm for anomaly detection?

Thanks

View 1 Replies View Related

Real Time Anomaly Detection

Jan 20, 2008



Hi,
I'm would like know if the analysis service data mining enables to detect anomalies from "normal" behavior/patterns of data (1), and alert about such anomalies when detected (2). both above sql server relational DB (3).

Thanks,
Eyal

View 5 Replies View Related

Dateadd Date Calculation Anomaly

Apr 3, 2008

I am doing monthly reporting for whole months, all starting on the 1st of each month and finishing on the last day of the month
I use dateAdd to calculate the end of the month - so I add 1 month and subtract 1 second (start time is always 00:00:00).

--dFrom is Jan 01 2008 00:00:00
select @dTo=dateadd(ss,-1,dateadd(mm,1, @dFrom))


when I print dTo it is not Jan 31 2008 23:59:59 but Feb 01 2008.
Why is this?
Only starts to behave when I set the number of seconds I am adding from -1 to -31.

Time of date is unimportant: as storing all dates as midday (any data type which ONLY supports date? not interested in the time really).


Subtracting one minute from midnight works fine, but that said: I am curious to understand why I am getting the funny behaviour above.

View 8 Replies View Related

1. Maintenance Cleanup. 2. 'View History' Anomaly

Mar 31, 2008

Hi. I'm very new to SQL Server and would greatly appreciate any advice with regard to my two questions below.

I've recently been given responsibility for a pair of clustered Windows 2003 servers running SQL Server 2005. Looking through SQL Server Management Studio, I found the following three maintenance plans:

- System Maintenance Plan (all system databases)
- Plan 1 (1 database)
- Plan 2 (4 databases).

All three maintenace plans had the following elements configured, in the following order:
- Check Database Integrity
- Backup Database (Full)
- Shrink Database
- Update statistics
- Clean Up History

with the exception that Plan 1 doesn't have a 'Shrink Database' task (because, I'm told, its data is pretty static), but none had a Maintenance Cleanup Task, so I added one to each plan specifying 14 days of old backups to be kept in all cases except Plan 1, where I limited it to 2 days, the database being over 7 GB in size. All links between tasks in all plans are AND constraints, value 'Completion'. All .BAKs are written to tape by Symantec Backup Exec as part of the daily backup.

Two questions from this:

1. Since .BAKs are written to separate folders for each database, do I need, for example, four Maintenance Cleanup Tasks for the Plans covering four databases - one for each folder/database? I can't see a way of specifying that a Maintenance Cleanup Task should apply to multiple databases or search subfolders based on database name, so I assume I need four consecutive Maintenance Cleanup Tasks within a single plan? Is this the way to do it?

2.The data displayed when I right-click a maintenance plan and choose View History shows:

date and time run
plan name
task name
duration
log type
log source

Since I added a Maintenance Cleanup Task to each plan, the only task shown in the Task Name column is Cleanup History (set to 'Older than 7 days'), and the duration is 00:00:00, where previously all tasks were shown and the overall duration was over a minute.

However, the .BAK files are being created (size looks OK), the application log contains entries suggesting the backups and other tasks completed successfully, and if I expand the SQL Server Logs node and view the current file I can see entries which give the same 'success' messages (presumably this log is the source of the 'success' messages in the application log?).

Why does there appear to be an anomaly between the 'View History' display and the SQL Server Log and application log? Should I be worried, or is what I can see in the SQL Server Logs and application log sufficient grounds for a good night's sleep?

Thanks,

Ed

View 4 Replies View Related

Strange Date/time Anomaly, Or Am I Just Stoopid?

Aug 30, 2005

To set up the problem, paste this into QA:if exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[WorkOTRate]') and OBJECTPROPERTY(id, N'IsUserTable')= 1)drop table [dbo].[WorkOTRate]GOCREATE TABLE [dbo].[WorkOTRate] ([TimeFrom] [smalldatetime] NOT NULL ,[TimeTo] [smalldatetime] NOT NULL ,[RateMultiplier] [float] NOT NULL) ON [PRIMARY]GOINSERT INTO dbo.WorkOTRate (TimeFrom, TimeTo, RateMultiplier)VALUES ('18:00:00', '23:59:59', 1.2)SELECT TimeFrom, TimeTo, RateMultiplier FROM dbo.WorkOTRateThis gives the following result:1900-01-01 18:00:001900-01-02 00:00:001.2So, it's storing the time 23:59:59 as midnight. That's odd.(NOTE: If you rescript the table using datetime instead ofsmalldatetime types, the data are stored correctly.)It gets worse (or better, if you like perversity).If I go to Enterprise Manager, right-click on WorkOTRate and select"Open Table" -> "Return All Rows" I get:01/01/1900 18:00:0002/01/19001.2So, I bite the bullet and change the two column types to datetime,clear out the old data and run the INSERT again. The data looks betternow.Go back to the view in EM.If I put the cursor in a new row, and type into the TimeFrom column18:30:00 and the TimeTo column 19:30:00 and the RateMultiplier column1.3, and refresh the data by pressing the red shriek !, I get this:01/01/1900 18:00:0001/01/1900 23:59:591.218:30:0019:30:001.3If I re-run the SELECT from the QA, I get this:1900-01-01 18:00:00.0001900-01-01 23:59:59.0001.21899-12-30 18:30:00.0001899-12-30 19:30:00.0001.3Is it just me, or does this seem to be remarkably inconsistent?Edward

View 2 Replies View Related

1. Maintenance Cleanup. 2. 'View History' Anomaly

Mar 31, 2008

Hi. I'm very new to SQL Server and would greatly appreciate any advice with regard to my two questions below.

I've recently been given responsibility for a pair of clustered Windows 2003 servers running SQL Server 2005. Looking through SQL Server Management Studio, I found the following three maintenance plans:

- System Maintenance Plan (all system databases)
- Plan 1 (1 database)
- Plan 2 (4 databases).

All three maintenace plans had the following elements configured, in the following order:
- Check Database Integrity
- Backup Database (Full)
- Shrink Database
- Update statistics
- Clean Up History

with the exception that Plan 1 doesn't have a 'Shrink Database' task (because, I'm told, its data is pretty static), but none had a Maintenance Cleanup Task, so I added one to each plan specifying 14 days of old backups to be kept in all cases except Plan 1, where I limited it to 2 days, the database being over 7 GB in size. All links between tasks in all plans are AND constraints, value 'Completion'. All .BAKs are written to tape by Symantec Backup Exec as part of the daily backup.

Two questions from this:

1. Since .BAKs are written to separate folders for each database, do I need, for example, four Maintenance Cleanup Tasks for the Plans covering four databases - one for each folder/database? I can't see a way of specifying that a Maintenance Cleanup Task should apply to multiple databases or search subfolders based on database name, so I assume I need four consecutive Maintenance Cleanup Tasks within a single plan? Is this the way to do it?

2.The data displayed when I right-click a maintenance plan and choose View History shows:

date and time run
plan name
task name
duration
log type
log source

Since I added a Maintenance Cleanup Task to each plan, the only task shown in the Task Name column is Cleanup History (set to 'Older than 7 days'), and the duration is 00:00:00, where previously all tasks were shown and the overall duration was over a minute.

However, the .BAK files are being created (size looks OK), the application log contains entries suggesting the backups and other tasks completed successfully, and if I expand the SQL Server Logs node and view the current file I can see entries which give the same 'success' messages (presumably this log is the source of the 'success' messages in the application log?).

Why does there appear to be an anomaly between the 'View History' display and the SQL Server Log and application log? Should I be worried, or is what I can see in the SQL Server Logs and application log sufficient grounds for a good night's sleep?

Thanks,

Ed

View 4 Replies View Related

Execution Time Anomaly In Stored Procedures In SQL Server 2005

Dec 3, 2006

Background: We have SQL Server 2005 x64 running on a quad-core (dual dual-core) machine with 16GB of RAM. The database is about 10GB in size and we execute around a million stored procedures a day on it. Our application uses about 1000 different stored procedures on this machine. The application is a transactional B2B web-app with about 2000 users.
The problem we have is a really odd one that I can't seem to find much information on. We have a small number (3-4) of stored procedures that's exibiting this problem.
The stored proc in question takes on average 100ms CPU time to execute. It's a fairly complex stored proc, about 300 lines long, 6-7 select statements and it uses temp tables. No updates / inserts except for on the temp tables. It's executed about 5000 times per day. About once a week, though, execution times will suddenly jump up to 3000 ms average. This happens randomly during the day, although it seems to happen more often on Monday mornings (the DB is mostly unutilized over the weekend)
To fix this, I force the DB to recalculate the execution plan by adding / removing (depending what I did last time around) the line 'set arithabort on' at the top of the stored procedure. I have no idea why this works, but it does. Within seconds of changing it, the stored proc execution time will go back to it's normal range of 60-150ms.
I've tried setting the execution plan of the stored procedure but I can't get it to work - the execution plan is very long and I don't know how to debug the error I get.
What is happening? This happens with a couple of stored procedures - usually the more complex ones. Has anyone seen anything like this?

View 4 Replies View Related

SQL Search :: Full Text Search Anomaly

Jun 24, 2015

I'm experiencing an anomaly with my Full text index.

Setup : SQL Server 2005
Indexed Table:
Assets
ID - int (PK, auto increment)
Ref - varchar(50)

[code]....

I have re-built the full-text index, no change.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved