please help me solve the problem in query
following is the query
CREATE TABLE [ISMMDM] (
[MDMRFNUM] [BIGINT] NOT NULL IDENTITY (1, 1) NOT NULL ,
[NAME] [NVARCHAR] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[CONTENT] [VARCHAR] (10000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[TDMRFNUM] [BIGINT] NULL ,
[SUBJECT] [NVARCHAR] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FROM] [NVARCHAR] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[TO] [NVARCHAR] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[TOQDMRFNUM] [BIGINT] NULL ,
[CC] [NVARCHAR] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CCQDMRFNUM] [BIGINT] NULL ,
[BCC] [NVARCHAR] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[BCCQDMRFNUM] [BIGINT] NULL ,
[LOG] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[CREATEDATE] [datetime] NULL,
[MODIDATE] [datetime] NULL,
[FLDSTR1] [NVARCHAR] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FLDSTR2] [NVARCHAR] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FLDSTR3] [NVARCHAR] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DELETED] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL WITH DEFAULT 'N',
[CREATEDBY] [BIGINT] NOT NULL WITH DEFAULT 0,
CONSTRAINT [PK_ISMMDM] PRIMARY KEY CLUSTERED
(
[MDMRFNUM]
) ON [PRIMARY]
) ON [PRIMARY]
what changes should I doThe error messages are clues :)
10000 is too big for the datatype and there is no "With" when defining a default value.|||I dont want alter 10000 so which data type I should use and how
so what would be the correct syntax for this query|||instead of VARCHAR(10000) which is too big, use TEXT (with no number in parentheses after it)|||Or, if you are using SQL Server 2005, VARCHAR(MAX).|||it looks like you are using 2005 since you are using SSMS. in that case use varchar(max) as pootle suggests. text, ntext, image are deprecated in 2005.|||Call me Mr Picky if you like but also... that ain't a query :)|||it looks like you are using 2005 since you are using SSMS. Good spot. One of us is paying attention to the picture clues then :)|||text, ntext, image are deprecated in 2005.ta very much
didn't know that
:)|||:) My problem is solved Thanks to you all for giving suggestion
BUT I heard that using TEXT data type decreases performance so can we
use VARCHAR(MAX) upto how much character it stores and what is the synatax|||varchar(max) has the same size limitation as TEXT. 2gb worth of text as I recall.
just to be clear: do not use TEXT. use nvarchar(max) - text suffers from certain limitations that nvarchar(max) does not.|||can any one tell the correct syntax for using VARCHAR(MAX)
with example
name VARCHAR(MAX) (10000) not working how we use|||drop the (10000).|||drop the (10000).
i have to 10000 with VARCHAR (MAX) but how ?|||how? by leaving it out ;)|||no hablo inglis.|||create table bleh
(
int id identity(1,1) primary key,
someText varchar(max) not null
)|||spot the differences:
create table meh
(
id int identity(1,1) primary key,
someText varchar(max) not null
)
;)|||whoops. ;)
Showing posts with label null. Show all posts
Showing posts with label null. Show all posts
Wednesday, March 28, 2012
Monday, March 26, 2012
query problem
hi i have the following query and 2 problems with it.
EventView is a view.
1. if pregnancy.dischargedate is null i want to display EventValue.
(Select ISNULL(pregnancy.dischargedate, EventValue)
works fine when discharge date is null it takes the value of dischargedate1.
but the problem is if discharge date has a value, it still displays null.
2. and i want to use dischargedate1 Between '1.12.1990' AND '12.12.2004'
it says invalid columnname dischargedate1.
select
Pregnancy.DischargeDate,
(Select ISNULL(pregnancy.dischargedate, EventValue)
From EventView
--I have a lot of where clauses and processing here.
))AS DischargeDate1
From Patient INNER JOIN Pregnancy ON Patient.Patientid = Pregnancy.Patientid
INNER JOIN Baby ON Baby.Pregnancyno = Pregnancy.Pregnancyno
where DischargeDate1 Between '1.1.1990' AND '1.1.2004'
thnx.Frazer,
if you do Select ISNULL(pregnancy.dischargedate,
EventValue), pregnancy.dischargedate, EventValue you
should see that when dischargedate is null then the
EventValue is returned, otherwise the dischargedate is
returned. Is this what you require? Your message is a
little confusing: 'it takes the value of dischargedate1' -
which is the expression alias.
For your second point, you can't refer to the expression
alias dischargedate1 in a where clause - you'll need to
repeat the expression instead.
HTH,
Paul Ibison
EventView is a view.
1. if pregnancy.dischargedate is null i want to display EventValue.
(Select ISNULL(pregnancy.dischargedate, EventValue)
works fine when discharge date is null it takes the value of dischargedate1.
but the problem is if discharge date has a value, it still displays null.
2. and i want to use dischargedate1 Between '1.12.1990' AND '12.12.2004'
it says invalid columnname dischargedate1.
select
Pregnancy.DischargeDate,
(Select ISNULL(pregnancy.dischargedate, EventValue)
From EventView
--I have a lot of where clauses and processing here.
))AS DischargeDate1
From Patient INNER JOIN Pregnancy ON Patient.Patientid = Pregnancy.Patientid
INNER JOIN Baby ON Baby.Pregnancyno = Pregnancy.Pregnancyno
where DischargeDate1 Between '1.1.1990' AND '1.1.2004'
thnx.Frazer,
if you do Select ISNULL(pregnancy.dischargedate,
EventValue), pregnancy.dischargedate, EventValue you
should see that when dischargedate is null then the
EventValue is returned, otherwise the dischargedate is
returned. Is this what you require? Your message is a
little confusing: 'it takes the value of dischargedate1' -
which is the expression alias.
For your second point, you can't refer to the expression
alias dischargedate1 in a where clause - you'll need to
repeat the expression instead.
HTH,
Paul Ibison
Subscribe to:
Posts (Atom)