Я выполняю запрос, который выбирает данные из представления SQL Server.Когда данные возвращаются, они округляются, чтобы не иметь десятичных разрядов.Это не происходит с каждым столбцом, даже если в базовой таблице SQL все столбцы определены одинаково:
[whp] [numeric](10, 2) NULL,
[whp_si] [numeric](10, 2) NULL,
В этом случае в столбце запроса Access whp_si
всегда отображаются десятичные разряды, но whp
нет, никогда.
Глядя на данные whp_si
в SQL, большинство записей имеют десятичные разряды, в то время как большинство не для whp
, я не могу поверить, что это будет иметь какое-то значение, но вы никогда не знаете.
Когда я смотрю на связанную базовую таблицу SQL через Access в режиме разработки, она интерпретирует оба столбца как Число, Десятичное число, Точность 10, Масштаб 2, Десятичное число Авто.Когда я смотрю на представление SQL, оно показывает whp
как Long Integer и whp_si
как Double.
Представление почти аналогично представлению базовой таблицы, форматирование отсутствует.Пользователи не могут видеть базовые таблицы, они должны использовать представления.
Может ли кто-нибудь помочь мне с этим, пожалуйста, поскольку я искал всю всемирную сеть, я думаю.
Базовая таблица def:
CREATE TABLE [dbo].[test](
[id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[id_wellborecompl] [int] NULL,
[id_validation_level] [int] NULL,
[id_type_test] [int] NULL,
[id_status_test] [int] NULL,
[date] [datetime2](6) NOT NULL,
[duration] [numeric](10, 2) NULL,
[q_oil] [numeric](10, 2) NULL,
[q_gas] [numeric](10, 2) NULL,
[q_water] [numeric](14, 2) NULL,
[api] [numeric](10, 2) NULL,
[bsw] [numeric](10, 2) NULL,
[gor] [numeric](14, 2) NULL,
[glr] [numeric](14, 2) NULL,
[tds] [numeric](10, 2) NULL,
[choke] [numeric](10, 2) NULL,
[whp] [numeric](10, 2) NULL,
[whp_si] [numeric](10, 2) NULL,
[flp] [numeric](10, 2) NULL,
[flp_SI] [numeric](10, 2) NULL,
[wht] [numeric](10, 2) NULL,
[wht_SI] [numeric](10, 2) NULL,
[chp] [numeric](10, 2) NULL,
[chp_SI] [numeric](10, 2) NULL,
[p_sep] [numeric](10, 2) NULL,
[p_sep_si] [numeric](10, 2) NULL,
[t_sep] [numeric](10, 2) NULL,
[t_sep_si] [numeric](10, 2) NULL,
[chemical_inj] [numeric](10, 2) NULL,
[bhp_pip] [numeric](10, 2) NULL,
[bhp_pip_si] [numeric](10, 2) NULL,
[q_gl] [numeric](14, 2) NULL,
[q_jet] [numeric](10, 2) NULL,
[rpm] [numeric](10, 2) NULL,
[frequency] [numeric](10, 2) NULL,
[stroke] [numeric](10, 2) NULL,
[submergence] [numeric](10, 2) NULL,
[submergence_si] [numeric](10, 2) NULL,
[amp] [numeric](10, 2) NULL,
[pd] [numeric](10, 2) NULL,
[pd_si] [numeric](10, 2) NULL,
[volts] [numeric](10, 2) NULL,
[chole_gl] [numeric](10, 2) NULL,
[p_jet] [numeric](10, 2) NULL,
[p_jet_si] [numeric](10, 2) NULL,
[p_gl] [numeric](10, 2) NULL,
[p_gl_si] [numeric](10, 2) NULL,
[pump_eff] [numeric](10, 2) NULL,
[validity] [bit] NULL,
[comments] [nvarchar](255) NULL,
[last_update] [datetime2](6) NULL,
[user_update] [nvarchar](255) NULL,
[comment] [varchar](max) NULL,
[deletedAt] [datetime2](6) NULL,
[create_date] [datetime2](6) NULL,
[t_motor] [numeric](10, 2) NULL,
[t_motor_si] [numeric](10, 2) NULL,
[bh_temp] [numeric](10, 2) NULL,
[bh_temp_si] [numeric](10, 2) NULL,
[vibration] [numeric](10, 2) NULL,
[sand] [numeric](10, 2) NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Фрагмент данныхвозвращено из таблицы с оператором Select:
whp whp_si flp flp_SI
6.6 0.46 NULL NULL
120.6 8.32 88.9 6.13
128.5 8.87 NULL NULL
2 0.14 1.8 0.12
2.8 0.19 NULL NULL
7.1 0.49 NULL NULL
120.6 8.32 98.8 6.82
128.5 8.87 NULL NULL
3 0.21 NULL NULL
9 0.62 NULL NULL
9 0.62 NULL NULL
9 0.62 NULL NULL
7.1 0.49 NULL NULL
2 0.14 1.8 0.12
2.8 0.19 2.3 0.16
123.3 8.51 82.9 5.72
128.5 8.87 0 0
4 0.28 NULL NULL
9 0.62 NULL NULL
7.1 0.49 NULL NULL
Просмотр по умолчанию:
ALTER VIEW [dbo].[V_RAW_Test] AS
SELECT T.[id] AS id
,T.[id_wellborecompl] AS id_wellborecompl
,T.[id_validation_level] AS id_validation_level
,T.[id_type_test] AS id_type_test
,T.[id_status_test] AS id_status_test
,T.[date] AS date
,T.[duration] AS duration
,T.[q_oil] AS q_oil
,T.[q_gas] AS q_gas
,T.[q_water] AS q_water
,T.[api] AS api
,T.[bsw] AS bsw
,T.[gor] AS gor
,T.[glr] AS glr
,T.[tds] AS tds
,T.[choke] AS choke
,T.[whp] AS whp
,T.[whp_si] AS whp_si
,T.[flp] AS flp
,T.[flp_SI] AS flp_SI
,T.[wht] AS wht
,T.[wht_SI] AS wht_SI
,T.[chp] AS chp
,T.[chp_SI] AS chp_SI
,T.[p_sep] AS p_sep
,T.[p_sep_si] AS p_sep_si
,T.[t_sep] AS t_sep
,T.[t_sep_si] AS t_sep_si
,T.[chemical_inj] AS chemical_inj
,T.[bhp_pip] AS bhp_pip
,T.[bhp_pip_si] AS bhp_pip_si
,T.[q_gl] AS q_gl
,T.[q_jet] AS q_jet
,T.[rpm] AS rpm
,T.[frequency] AS frequency
,T.[stroke] AS stroke
,T.[submergence] AS submergence
,T.[submergence_si] AS submergence_si
,T.[amp] AS amp
,T.[pd] AS pd
,T.[pd_si] AS pd_si
,T.[volts] AS volts
,T.[chole_gl] AS chole_gl
,T.[p_jet] AS p_jet
,T.[p_jet_si] AS p_jet_si
,T.[p_gl] AS p_gl
,T.[p_gl_si] AS p_gl_si
,T.[pump_eff] AS pump_eff
,T.[validity] AS validity
,T.[comments] AS comments
,T.[last_update] AS last_update
,T.[user_update] AS user_update
,T.[comment] AS comment
,T.[deletedAt] AS deletedAt
,(SELECT TOP 1 A.id FROM [dbo].[activation] AS A WITH (NOLOCK) WHERE A.id_wellstring = WS.id AND T.date >= A.date_run AND (T.date < A.date_end OR A.date_end IS NULL) AND A.deletedAt IS NULL) AS id_activation
FROM [dbo].[test] AS T WITH (NOLOCK)
INNER JOIN [dbo].[wellbore_compl] WC ON WC.id = T.id_wellborecompl
INNER JOIN [dbo].[wellstring] WS ON WS.id = WC.id_wellstring
Фрагмент данных из оператора Select Select:
whp whp_si flp flp_SI wht wht_SI
6.6 0.46 NULL NULL NULL NULL
120.6 8.32 88.9 6.13 71.4 4.93
128.5 8.87 NULL NULL NULL NULL
2 0.14 1.8 0.12 NULL NULL
2.8 0.19 NULL NULL NULL NULL
7.1 0.49 NULL NULL NULL NULL
120.6 8.32 98.8 6.82 70.9 4.89
128.5 8.87 NULL NULL NULL NULL
3 0.21 NULL NULL NULL NULL
9 0.62 NULL NULL NULL NULL
9 0.62 NULL NULL NULL NULL
9 0.62 NULL NULL NULL NULL
7.1 0.49 NULL NULL NULL NULL
2 0.14 1.8 0.12 NULL NULL
2.8 0.19 2.3 0.16 39 2.69
123.3 8.51 82.9 5.72 65.5 4.52
128.5 8.87 0 0 NULL NULL
4 0.28 NULL NULL NULL NULL
9 0.62 NULL NULL NULL NULL
7.1 0.49 NULL NULL NULL NULL
Запрос доступа:
SELECT dbo_V_RAW_Test.id, dbo_V_RAW_Test.q_gas, dbo_V_RAW_Test.q_water, dbo_V_RAW_Test.whp, dbo_V_RAW_Test.whp_si, dbo_test.whp, dbo_test.whp_si, dbo_V_RAW_Test.flp, dbo_V_RAW_Test.flp_SI, dbo_V_RAW_Test.wht, dbo_V_RAW_Test.wht_SI, dbo_V_RAW_Test.chp, dbo_V_RAW_Test.chp_SI, dbo_V_RAW_Test.p_sep, dbo_V_RAW_Test.p_sep_si, dbo_V_RAW_Test.t_sep, dbo_V_RAW_Test.t_sep_si, dbo_V_RAW_Test.chemical_inj, dbo_V_RAW_Test.bhp_pip, dbo_V_RAW_Test.bhp_pip_si, dbo_V_RAW_Test.q_gl, dbo_V_RAW_Test.q_jet, dbo_V_RAW_Test.rpm, dbo_V_RAW_Test.frequency, dbo_V_RAW_Test.stroke, dbo_V_RAW_Test.submergence, dbo_V_RAW_Test.submergence_si, dbo_V_RAW_Test.amp, dbo_V_RAW_Test.pd, dbo_V_RAW_Test.pd_si, dbo_V_RAW_Test.volts, dbo_V_RAW_Test.chole_gl, dbo_V_RAW_Test.p_jet, dbo_V_RAW_Test.p_jet_si, dbo_V_RAW_Test.p_gl, dbo_V_RAW_Test.p_gl_si, dbo_V_RAW_Test.pump_eff, dbo_V_RAW_Test.validity, dbo_V_RAW_Test.comments, dbo_V_RAW_Test.last_update, dbo_V_RAW_Test.user_update, dbo_V_RAW_Test.comment, dbo_V_RAW_Test.deletedAt, dbo_V_RAW_Test.id_activation
FROM dbo_V_RAW_Test
WHERE (((dbo_V_RAW_Test.validity)=False) AND ((dbo_V_RAW_Test.deletedAt) Is Null));
Фрагмент из запроса Access, просто прямой Выберите:
id date q_oil q_gas q_water api bsw gor glr tds choke whp whp_si flp flp_SI wht wht_SI
52001 2017-02-03 60 133 781 92.87 2216 158 192 6 0.46
52002 2017-02-03 306 20000 27.7 75 8.11 65359 60060 87 120 8.32 88 6.13 71 4.93
52003 2017-02-03 0 0 0 128 8.87
52004 2017-02-04 595 274 465 43.87 460 258 2 0.14 1 0.12
52005 2017-02-04 372 66 2754 88.1 177 21 2 0.19
52006 2017-02-04 26 127 4 13.33 4884 4233 55 7 0.49
52007 2017-02-04 272 19724 11.16 75 3.89 72514 69696 85 120 8.32 98 6.82 70 4.89
52008 2017-02-04 0 0 0 128 8.87
52009 2017-02-04 71 194 1405 95 2732 131 3 0.21
52010 2017-02-04 458 290 40 8 634 583 9 0.62
52011 2017-02-04 39 20 31 44 511 286 9 0.62
52012 2017-02-04 67 639 24 26 9543 7030 9 0.62
52013 2017-02-05 29 141 1 3.33 4862 4700 55 7 0.49
52014 2017-02-05 585 280 470 44.55 478 265 192 2 0.14 1 0.12
52015 2017-02-05 380 66 2743 87.83 173 21 192 2 0.19 2 0.16 39 2.69
52016 2017-02-05 247 16714 14.26 75 5.36 67668 64038 88 123 8.51 82 5.72 65 4.52
52017 2017-02-05 0 0 0 0 128 8.87 0 0
52018 2017-02-05 151 43 394 72 286 79 4 0.28
52019 2017-02-05 367 247 61 14 673 577 9 0.62
52020 2017-02-06 32 128 2 5.88 4000 3764 55 7 0.49