Showing posts with label table. Show all posts
Showing posts with label table. Show all posts

Friday, March 30, 2012

query question

I have shopping cart and the items are stored in a
StoreCart table. I'm trying to write a query that
returns the items in the cart in certain way but I don't
know how to do it. Say for example that I have the
following items:
Product Qty
-- --
Toy_1 3
Toy_2 1
Toy_3 2
I want to write a query that will return the item the
number of times that the Qty field has.
Product
--
Toy_1
Toy_1
Toy_1
Toy_2
Toy_3
Toy_3
How can I do this?
TIA,
Vic"Vic" <vduran@.specpro-inc.com> wrote in message
news:0e4201c53fcc$350cb270$a501280a@.phx.gbl...
>I have shopping cart and the items are stored in a
> StoreCart table. I'm trying to write a query that
> returns the items in the cart in certain way but I don't
> know how to do it. Say for example that I have the
> following items:
> Product Qty
> -- --
> Toy_1 3
> Toy_2 1
> Toy_3 2
> I want to write a query that will return the item the
> number of times that the Qty field has.
> Product
> --
> Toy_1
> Toy_1
> Toy_1
> Toy_2
> Toy_3
> Toy_3
>
create table N(i int primary key)
go
set nocount on
declare @.i int
set @.i = 0
while @.i < 10000
begin
insert into N(i) values (@.i)
set @.i = @.i + 1
end
go
create table cart(product varchar(50) not null, Qty int not null, primary
key (Product,qty))
insert into cart(product,qty)values('Toy_1',3)
insert into cart(product,qty)values('Toy_2',1)
insert into cart(product,qty)values('Toy_3',2)
go
select product
from
cart
join N on n.i < cart.qty
order by product
David

Query Question

Greetings,
I am new to SQL Server and am trying to write a query for an application I
am working on. The table I am working with has three dollar amounts in
seperate columns that are prices on the same product from multiple
distributors. I am having trouble building a query that does a comparison on
these fields and returns a list of records based upon the lowest dollar amount
The results would be then used to populate a new table using only the lowest
price as returned from the SELECT statement
Is there someone who might be able to point me to some sample code that I
could use to help me figure out how this could be written
Thanks,
Joe.SELECT col1, col2, col3, ...
(SELECT MIN(price)
FROM
(SELECT price1 AS price UNION ALL
SELECT price2 UNION ALL
SELECT price3) AS T) AS min_price
FROM YourTable
The three price columns collectively represent a "repeating group". In
relational design this is a serious error and the difficulty you are having
is a consequence of the design problem. Hopefully your intention is to fix
this.
--
David Portas
SQL Server MVP
--|||David,
I assume that MIN will still work in the same manner if the price values
being compared are in seperate tables. I am working on different ways to get
rid of the repeating problem.
Thanks for your help
Joe.
"David Portas" wrote:
> SELECT col1, col2, col3, ...
> (SELECT MIN(price)
> FROM
> (SELECT price1 AS price UNION ALL
> SELECT price2 UNION ALL
> SELECT price3) AS T) AS min_price
> FROM YourTable
> The three price columns collectively represent a "repeating group". In
> relational design this is a serious error and the difficulty you are having
> is a consequence of the design problem. Hopefully your intention is to fix
> this.
> --
> David Portas
> SQL Server MVP
> --
>
>|||MIN retrieves the lowest non-NULL value of a set. If you can join the
additional table into the query then you should be able to make use of MIN.
My point about your design was that it would be easier and more efficient to
do this if your design was correctly normalized.
--
David Portas
SQL Server MVP
--

Query Question

Greetings,
I am new to SQL Server and am trying to write a query for an application I
am working on. The table I am working with has three dollar amounts in
seperate columns that are prices on the same product from multiple
distributors. I am having trouble building a query that does a comparison on
these fields and returns a list of records based upon the lowest dollar amou
nt
The results would be then used to populate a new table using only the lowest
price as returned from the SELECT statement
Is there someone who might be able to point me to some sample code that I
could use to help me figure out how this could be written
Thanks,
Joe.SELECT col1, col2, col3, ...
(SELECT MIN(price)
FROM
(SELECT price1 AS price UNION ALL
SELECT price2 UNION ALL
SELECT price3) AS T) AS min_price
FROM YourTable
The three price columns collectively represent a "repeating group". In
relational design this is a serious error and the difficulty you are having
is a consequence of the design problem. Hopefully your intention is to fix
this.
David Portas
SQL Server MVP
--|||David,
I assume that MIN will still work in the same manner if the price values
being compared are in seperate tables. I am working on different ways to get
rid of the repeating problem.
Thanks for your help
Joe.
"David Portas" wrote:

> SELECT col1, col2, col3, ...
> (SELECT MIN(price)
> FROM
> (SELECT price1 AS price UNION ALL
> SELECT price2 UNION ALL
> SELECT price3) AS T) AS min_price
> FROM YourTable
> The three price columns collectively represent a "repeating group". In
> relational design this is a serious error and the difficulty you are havin
g
> is a consequence of the design problem. Hopefully your intention is to fix
> this.
> --
> David Portas
> SQL Server MVP
> --
>
>|||MIN retrieves the lowest non-NULL value of a set. If you can join the
additional table into the query then you should be able to make use of MIN.
My point about your design was that it would be easier and more efficient to
do this if your design was correctly normalized.
David Portas
SQL Server MVP
--

query question

I have shopping cart and the items are stored in a
StoreCart table. I'm trying to write a query that
returns the items in the cart in certain way but I don't
know how to do it. Say for example that I have the
following items:
Product Qty
-- --
Toy_1 3
Toy_2 1
Toy_3 2
I want to write a query that will return the item the
number of times that the Qty field has.
Product
--
Toy_1
Toy_1
Toy_1
Toy_2
Toy_3
Toy_3
How can I do this?
TIA,
Vic"Vic" <vduran@.specpro-inc.com> wrote in message
news:0e4201c53fcc$350cb270$a501280a@.phx.gbl...
>I have shopping cart and the items are stored in a
> StoreCart table. I'm trying to write a query that
> returns the items in the cart in certain way but I don't
> know how to do it. Say for example that I have the
> following items:
> Product Qty
> -- --
> Toy_1 3
> Toy_2 1
> Toy_3 2
> I want to write a query that will return the item the
> number of times that the Qty field has.
> Product
> --
> Toy_1
> Toy_1
> Toy_1
> Toy_2
> Toy_3
> Toy_3
>
create table N(i int primary key)
go
set nocount on
declare @.i int
set @.i = 0
while @.i < 10000
begin
insert into N(i) values (@.i)
set @.i = @.i + 1
end
go
create table cart(product varchar(50) not null, Qty int not null, primary
key (Product,qty))
insert into cart(product,qty)values('Toy_1',3)
insert into cart(product,qty)values('Toy_2',1)
insert into cart(product,qty)values('Toy_3',2)
go
select product
from
cart
join N on n.i < cart.qty
order by product
David

query question

I have a table where one of the fields is named SHIPPER
in the field, it will have the names of various shippers. ShipperA,
ShipperB ShipperC and ShipperD as an example
I need to make a query where it will return all the records where the
SHIPPER is ShipperA, ShipperB, ShipperD
All help would be great!
ThanksSELECT *
FROM YourTable
WHERE Shipper IN ('ShipperA', 'ShipperB', ShipperD')
?
If this doesn't work, please post DDL and sample data (
http://www.aspfaq.com/etiquette.asp?id=5006 )
"johnfli" <john@.here.com> wrote in message
news:OTiQIf8rEHA.3588@.tk2msftngp13.phx.gbl...
> I have a table where one of the fields is named SHIPPER
> in the field, it will have the names of various shippers. ShipperA,
> ShipperB ShipperC and ShipperD as an example
> I need to make a query where it will return all the records where the
> SHIPPER is ShipperA, ShipperB, ShipperD
> All help would be great!
> Thanks
>|||Thank you for the quick reply.
I wasn't able to get it to work, I am sure it has something to do with the
wildcards.
I modified your line to read:
WHERE Shipper IN ('%ShipperA%', '%ShipperB%', '%ShipperD%')
as for some reason, the names were inputted with partial address
thanks again if you're able to fix this.
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:%23i6goi8rEHA.3848@.TK2MSFTNGP14.phx.gbl...
> SELECT *
> FROM YourTable
> WHERE Shipper IN ('ShipperA', 'ShipperB', ShipperD')
> ?
> If this doesn't work, please post DDL and sample data (
> http://www.aspfaq.com/etiquette.asp?id=5006 )
>
> "johnfli" <john@.here.com> wrote in message
> news:OTiQIf8rEHA.3588@.tk2msftngp13.phx.gbl...
>|||Sorry, IN does not support wild cards. You'll have to use LIKE with OR:
WHERE Shipper LIKE '%ShipperA%'
OR Shipper LIKE '%ShipperB%'
OR Shipper LIKE '%ShipperD%'
"johnfli" <john@.here.com> wrote in message
news:uz2VMo8rEHA.1644@.tk2msftngp13.phx.gbl...
> Thank you for the quick reply.
> I wasn't able to get it to work, I am sure it has something to do with the
> wildcards.
> I modified your line to read:
> WHERE Shipper IN ('%ShipperA%', '%ShipperB%', '%ShipperD%')
> as for some reason, the names were inputted with partial address
> thanks again if you're able to fix this.
>|||perfect!
thank you
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:OWbQUr8rEHA.556@.tk2msftngp13.phx.gbl...
> Sorry, IN does not support wild cards. You'll have to use LIKE with OR:
> WHERE Shipper LIKE '%ShipperA%'
> OR Shipper LIKE '%ShipperB%'
> OR Shipper LIKE '%ShipperD%'
>
> "johnfli" <john@.here.com> wrote in message
> news:uz2VMo8rEHA.1644@.tk2msftngp13.phx.gbl...
the[vbcol=seagreen]
>

Query Q

Hi,
In a table I've Cust_ID, Date_IN, Order_Num.
I'd like to list the Cust_ID who have not placed an order for the last 5
months.
HOWTO?
TIA
Ana
SQL2005, Acc03
Try:
select *
from dbo.customer as c
where not exists (
select *
from dbo.order as oh
where oh.cust_id = c.cust_id
and oh.date_in >= convert(varchar(6), dateadd(month, -4, getdate()), 112) +
'01'
)
go
AMB
"AnaT" wrote:

> Hi,
> In a table I've Cust_ID, Date_IN, Order_Num.
> I'd like to list the Cust_ID who have not placed an order for the last 5
> months.
> HOWTO?
> TIA
> Ana
>
> SQL2005, Acc03
>
|||On Jun 26, 10:19 pm, "AnaT" <ananos...@.yahoo.es> wrote:
> Hi,
> In a table I've Cust_ID, Date_IN, Order_Num.
> I'd like to list the Cust_ID who have not placed an order for the last 5
> months.
> HOWTO?
> TIA
> Ana
> SQL2005, Acc03
Hi, try something like followig:
select cust_id
from some_table
group by cust_id
having datediff(month,max(date_in),getdate()) >= 5
HTH

Query Q

Hi,
In a table I've Cust_ID, Date_IN, Order_Num.
I'd like to list the Cust_ID who have not placed an order for the last 5
months.
HOWTO?
TIA
Ana
SQL2005, Acc03Try:
select *
from dbo.customer as c
where not exists (
select *
from dbo.order as oh
where oh.cust_id = c.cust_id
and oh.date_in >= convert(varchar(6), dateadd(month, -4, getdate()), 112) +
'01'
)
go
AMB
"AnaT" wrote:
> Hi,
> In a table I've Cust_ID, Date_IN, Order_Num.
> I'd like to list the Cust_ID who have not placed an order for the last 5
> months.
> HOWTO?
> TIA
> Ana
>
> SQL2005, Acc03
>|||On Jun 26, 10:19 pm, "AnaT" <ananos...@.yahoo.es> wrote:
> Hi,
> In a table I've Cust_ID, Date_IN, Order_Num.
> I'd like to list the Cust_ID who have not placed an order for the last 5
> months.
> HOWTO?
> TIA
> Ana
> SQL2005, Acc03
Hi, try something like followig:
select cust_id
from some_table
group by cust_id
having datediff(month,max(date_in),getdate()) >= 5
HTHsql

Query Q

Hi,
In a table I've Cust_ID, Date_IN, Order_Num.
I'd like to list the Cust_ID who have not placed an order for the last 5
months.
HOWTO?
TIA
Ana
SQL2005, Acc03Try:
select *
from dbo.customer as c
where not exists (
select *
from dbo.order as oh
where oh.cust_id = c.cust_id
and oh.date_in >= convert(varchar(6), dateadd(month, -4, getdate()), 112) +
'01'
)
go
AMB
"AnaT" wrote:

> Hi,
> In a table I've Cust_ID, Date_IN, Order_Num.
> I'd like to list the Cust_ID who have not placed an order for the last 5
> months.
> HOWTO?
> TIA
> Ana
>
> SQL2005, Acc03
>|||On Jun 26, 10:19 pm, "AnaT" <ananos...@.yahoo.es> wrote:
> Hi,
> In a table I've Cust_ID, Date_IN, Order_Num.
> I'd like to list the Cust_ID who have not placed an order for the last 5
> months.
> HOWTO?
> TIA
> Ana
> SQL2005, Acc03
Hi, try something like followig:
select cust_id
from some_table
group by cust_id
having datediff(month,max(date_in),getdate()) >= 5
HTH

Query programmable

Hi,
I need to create a stored procedures that can pass table parameters in
varchar format.
for example:
CREATE FUNCTION MyFunc (@.table varchar(200)
AS
UPDATE @.table + 'aaa' -> How can I do this?
SET field1=tbl2.field2
FROM tbl2
WHERE tbl2.field3>10Use Dynamic SQL
Madhivanan|||You can try using dynamic SQLs
like this ..
declare @.t nvarchar(1000)
set @.t = 'UPDATE ' +@.table + 'aaa ' +
'SET field1=tbl2.field2 FROM tbl2 WHERE tbl2.field3>10 '
exec sp_executeSQL @.t|||UPDATE statements are not allowed in functions. Dynamic SQL is also
disallowed in functions. Perhaps a stored procedure will address your
needs.
Check out http://www.sommarskog.se/dynamic_sql.html for dynamic SQL
considerations.
Hope this helps.
Dan Guzman
SQL Server MVP
"Dario Concilio" <DarioConcilio@.discussions.microsoft.com> wrote in message
news:F6C4572F-6306-47CB-9087-5C3E2204C824@.microsoft.com...
> Hi,
> I need to create a stored procedures that can pass table parameters in
> varchar format.
> for example:
> CREATE FUNCTION MyFunc (@.table varchar(200)
> AS
> UPDATE @.table + 'aaa' -> How can I do this?
> SET field1=tbl2.field2
> FROM tbl2
> WHERE tbl2.field3>10|||I can't see why that would make sense as a requirement unless your
tables duplicated lots of non-key columns. In that case it's really a
design problem rather than something to solve with a parameterized
UPDATE.
Dynamic SQL is one way you can do this but in a well-designed database
it should rarely be necessary.
David Portas
SQL Server MVP
--|||>> I need to create a stored procedures that can pass table parameters
in varchar format. <<
The short answer is use slow, proprietrary dynamic SQL to kludge a
query together on the fly with your table name in the FROM clause.
The right answer is never pass a table name as a parameter. You need
to understand the basic idea of a data model and what a table means in
implementing a data model. Go back to basics. What is a table? A
model of a set of entities or relationships. EACH TABLE SHOULD BE A
DIFFERENT KIND OF ENTITY. What having a generic procedure works
equally on automobiles, octopi or Britney Spear's discology is saying
that your applications a disaster of design.
1) This is dangerous because some user can insert pretty much whatever
they wish -- consider the string 'Foobar; DELETE FROM Foobar; SELECT *
FROM Floob' in your statement string.
2) It says that you have no idea what you are doing, so you are giving
control of the application to any user, present or future. Remember
the basics of Software Engineering? Modules need weak coupling and
strong cohesion, etc. This is far more fundamental than just SQL; it
has to do with learning to programming at all.
3) If you have tables with the same structure which represent the same
kind of entities, then your schema is not orthogonal. Look up what
Chris Date has to say about this design flaw. Look up the term
attribute splitting.
4) You might have failed to tell the difference between data and
meta-data. The SQL engine has routines for that stuff and applications
do not work at that level, if you want to have any data integrity.
Yes, you can write a program with dynamic SQL to kludge something like
this. It will last about a year in production and then your data
integrity is shot.sql

Query Processor Error after SP4

Hi All
We have a database with approx. 460 tables linked to a foreign key (UserID)
in a table called Users. After installing SQL SP4, when trying to delete an
unreferenced entry in the Users table (even using Enterprise Manager), we get
the following error: "[Microsoft][ODBC SQL Server Driver][SQL Server]Internal
Query Processor Error: The query processor encountered an unexpected error
during execution."
Using the same database on a SP3a SQL server, it works fine.
Thanks in advance
Johan Fourie
Hi,
Johan Fourie,
Did u restarted ur sql services after installation of sp4.
hope this help
from
killer
|||Hi Johan,
Thanks for your post.
From your descriptions, I understood you SELECT statements will report the
error message after applied SP4. If I have misunderstood your concern,
please feel free to point it out.
Based on my knowledge, SQL Server SP4 should fix a related error message.
Please refer the KB for more detailed information.
FIX: Internal Query Processor Error 8623 When Microsoft SQL Server Tries to
Compile a Plan for a Complex Query
http://support.microsoft.com/kb/818729
Is it possible for you to reproduce it on Northwind database? Would you
please generate a sample table, with which I could reproduct it on my side?
Any more error logs on your side? I understand the information may be
sensitive to you, my direct email address is v-mingqc@.online.microsoft.com
(please remember to remove "online" before click SEND as it's only for
SPAM), you may send the sample script file to me directly and I will keep
secure.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.
|||Yes, we did many reboots since the upgrade to SP4
Thanks
Johan Fourie
"doller" wrote:

> Hi,
> Johan Fourie,
> Did u restarted ur sql services after installation of sp4.
> hope this help
> from
> killer
>
|||Hi Michael
Ok, from SQL Query Analyzer the following command "DELETE FROM Users WHERE
UserID = 19" returns the following error: "Server: Msg 8630, Level 17, State
34, Line 1
Internal Query Processor Error: The query processor encountered an
unexpected error during execution."
I do not think it would be possible to simulate this problem on the
Northwind database as you need many FK links to the affected table. As you
can see, it is actually not a complex query, but SQL must determine whether
the entry being deleted is in use by one of the FK relationships (>460)
Thanks and much appreciated
Johan Fourie
"Michael Cheng [MSFT]" wrote:

> Hi Johan,
> Thanks for your post.
> From your descriptions, I understood you SELECT statements will report the
> error message after applied SP4. If I have misunderstood your concern,
> please feel free to point it out.
> Based on my knowledge, SQL Server SP4 should fix a related error message.
> Please refer the KB for more detailed information.
> FIX: Internal Query Processor Error 8623 When Microsoft SQL Server Tries to
> Compile a Plan for a Complex Query
> http://support.microsoft.com/kb/818729
> Is it possible for you to reproduce it on Northwind database? Would you
> please generate a sample table, with which I could reproduct it on my side?
> Any more error logs on your side? I understand the information may be
> sensitive to you, my direct email address is v-mingqc@.online.microsoft.com
> (please remember to remove "online" before click SEND as it's only for
> SPAM), you may send the sample script file to me directly and I will keep
> secure.
> Thank you for your patience and cooperation. If you have any questions or
> concerns, don't hesitate to let me know. We are always here to be of
> assistance!
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ================================================== ===
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
|||Hi Johan,
Thanks for the quick response.
It is very strange the SP4 enroll this new error message. I would like to
check it further. Is it possible for you to send me sample tables or sample
databases? (mdb file or the scripts with your tables)
I understand the information must be sensitive to you. Alternatively, to
efficiently troubleshoot a this issue, we recommend that you contact
Microsoft Customer Service and Support and open a support incident and work
with a dedicated Support Professional.
Please be advised that contacting phone support will be a charged call.
However, if it turn out to be a bug in SP4 then charges are usually
refunded or waived.
To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default...S;PHONENUMBERS
If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.
|||Hi Michael
Thanks for the quick response. We took the database again to a SP3a SQL
server and it works fine there, must be a SP4 problem. I'll be sending you
the database via e-mail shortly. Please treat the data and structure of the
database as very sensitive. Hope to hear from you soon.
Regards and many thanks.
Johan Fourie
"Michael Cheng [MSFT]" wrote:

> Hi Johan,
> Thanks for the quick response.
> It is very strange the SP4 enroll this new error message. I would like to
> check it further. Is it possible for you to send me sample tables or sample
> databases? (mdb file or the scripts with your tables)
> I understand the information must be sensitive to you. Alternatively, to
> efficiently troubleshoot a this issue, we recommend that you contact
> Microsoft Customer Service and Support and open a support incident and work
> with a dedicated Support Professional.
> Please be advised that contacting phone support will be a charged call.
> However, if it turn out to be a bug in SP4 then charges are usually
> refunded or waived.
> To obtain the phone numbers for specific technology request please take a
> look at the web site listed below.
> http://support.microsoft.com/default...S;PHONENUMBERS
> If you are outside the US please see http://support.microsoft.com for
> regional support phone numbers.
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ================================================== ===
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
|||Hi Johan,
Thanks for your kindly sending me the database files.
After looking into the execution plan, I believe this is a known issue of
SQL Server service pack 4.
Since we add stack overflow checks in SP4, it raise this new problem. For
now, we do not have a pretty workaround for this issue.
However, if you want to apply SP4 and this issue has big business impact to
you. I would like to recommand you opening a grace case with Microsoft
Customer Service and Support (CSS). Please understand that we could not
share you the QFE request in the newsgroup.
Please be advised that contacting phone support will be a charged call.
However, if the support engineer confirmed this is a bug and no other
support then charges are usually refunded or waived.
To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default...S;PHONENUMBERS
If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.
You could share the information below with the CSS support engineer
Bug# SQL Server 8.0 20000179
I do apologized for this new known issue that caused to you and thanks so
much for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.
|||Hi Michael
Thanks. Is there a quick fix available for this problem? We've advised all
our customers to go to SP4 (when it was released) and they wont be happy if
we tell them to go back to SP3a (as they all have this problem). Can you also
supply us with the KB number for this problem. Would it be possible for you
to send the QFE via e-mail to me?
Thanks in advance.
Johan Fourie
"Michael Cheng [MSFT]" wrote:

> Hi Johan,
> Thanks for your kindly sending me the database files.
> After looking into the execution plan, I believe this is a known issue of
> SQL Server service pack 4.
> Since we add stack overflow checks in SP4, it raise this new problem. For
> now, we do not have a pretty workaround for this issue.
> However, if you want to apply SP4 and this issue has big business impact to
> you. I would like to recommand you opening a grace case with Microsoft
> Customer Service and Support (CSS). Please understand that we could not
> share you the QFE request in the newsgroup.
> Please be advised that contacting phone support will be a charged call.
> However, if the support engineer confirmed this is a bug and no other
> support then charges are usually refunded or waived.
> To obtain the phone numbers for specific technology request please take a
> look at the web site listed below.
> http://support.microsoft.com/default...S;PHONENUMBERS
> If you are outside the US please see http://support.microsoft.com for
> regional support phone numbers.
> You could share the information below with the CSS support engineer
> Bug# SQL Server 8.0 20000179
> I do apologized for this new known issue that caused to you and thanks so
> much for your patience and cooperation. If you have any questions or
> concerns, don't hesitate to let me know. We are always here to be of
> assistance!
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ================================================== ===
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
|||Hi Johan,
Thanks for your update.
Unfortunately, I am so sorry to say that there is temporarily no public
Knowledge Base articles and document describing this issue. This issue only
occurs in SQL Server 2000 SP4, SQL Server 2000 SP3 and SQL Server 2005 do
not have this issue.
Unfortunately, I am unable to process the delivery of QFEs via email
directly. However, you should be able to quickly get this QFE by opening
the grace case with CSS.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.

Query Processor Error after SP4

Hi All
We have a database with approx. 460 tables linked to a foreign key (UserID)
in a table called Users. After installing SQL SP4, when trying to delete an
unreferenced entry in the Users table (even using Enterprise Manager), we ge
t
the following error: "[Microsoft][ODBC SQL Server Driver][SQL Se
rver]Internal
Query Processor Error: The query processor encountered an unexpected error
during execution."
Using the same database on a SP3a SQL server, it works fine.
Thanks in advance
--
Johan FourieHi,
Johan Fourie,
Did u restarted ur sql services after installation of sp4.
hope this help
from
killer|||Hi Johan,
Thanks for your post.
From your descriptions, I understood you SELECT statements will report the
error message after applied SP4. If I have misunderstood your concern,
please feel free to point it out.
Based on my knowledge, SQL Server SP4 should fix a related error message.
Please refer the KB for more detailed information.
FIX: Internal Query Processor Error 8623 When Microsoft SQL Server Tries to
Compile a Plan for a Complex Query
http://support.microsoft.com/kb/818729
Is it possible for you to reproduce it on Northwind database? Would you
please generate a sample table, with which I could reproduct it on my side?
Any more error logs on your side? I understand the information may be
sensitive to you, my direct email address is v-mingqc@.online.microsoft.com
(please remember to remove "online" before click SEND as it's only for
SPAM), you may send the sample script file to me directly and I will keep
secure.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||Yes, we did many reboots since the upgrade to SP4
Thanks
--
Johan Fourie
"doller" wrote:

> Hi,
> Johan Fourie,
> Did u restarted ur sql services after installation of sp4.
> hope this help
> from
> killer
>|||Hi Michael
Ok, from SQL Query Analyzer the following command "DELETE FROM Users WHERE
UserID = 19" returns the following error: "Server: Msg 8630, Level 17, State
34, Line 1
Internal Query Processor Error: The query processor encountered an
unexpected error during execution."
I do not think it would be possible to simulate this problem on the
Northwind database as you need many FK links to the affected table. As you
can see, it is actually not a complex query, but SQL must determine whether
the entry being deleted is in use by one of the FK relationships (>460)
Thanks and much appreciated
--
Johan Fourie
"Michael Cheng [MSFT]" wrote:

> Hi Johan,
> Thanks for your post.
> From your descriptions, I understood you SELECT statements will report the
> error message after applied SP4. If I have misunderstood your concern,
> please feel free to point it out.
> Based on my knowledge, SQL Server SP4 should fix a related error message.
> Please refer the KB for more detailed information.
> FIX: Internal Query Processor Error 8623 When Microsoft SQL Server Tries t
o
> Compile a Plan for a Complex Query
> http://support.microsoft.com/kb/818729
> Is it possible for you to reproduce it on Northwind database? Would you
> please generate a sample table, with which I could reproduct it on my side
?
> Any more error logs on your side? I understand the information may be
> sensitive to you, my direct email address is v-mingqc@.online.microsoft.com
> (please remember to remove "online" before click SEND as it's only for
> SPAM), you may send the sample script file to me directly and I will keep
> secure.
> Thank you for your patience and cooperation. If you have any questions or
> concerns, don't hesitate to let me know. We are always here to be of
> assistance!
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
=============
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>|||Hi Johan,
Thanks for the quick response.
It is very strange the SP4 enroll this new error message. I would like to
check it further. Is it possible for you to send me sample tables or sample
databases? (mdb file or the scripts with your tables)
I understand the information must be sensitive to you. Alternatively, to
efficiently troubleshoot a this issue, we recommend that you contact
Microsoft Customer Service and Support and open a support incident and work
with a dedicated Support Professional.
Please be advised that contacting phone support will be a charged call.
However, if it turn out to be a bug in SP4 then charges are usually
refunded or waived.
To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/defaul...US;PHONENUMBERS
If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi Michael
Thanks for the quick response. We took the database again to a SP3a SQL
server and it works fine there, must be a SP4 problem. I'll be sending you
the database via e-mail shortly. Please treat the data and structure of the
database as very sensitive. Hope to hear from you soon.
Regards and many thanks.
--
Johan Fourie
"Michael Cheng [MSFT]" wrote:

> Hi Johan,
> Thanks for the quick response.
> It is very strange the SP4 enroll this new error message. I would like to
> check it further. Is it possible for you to send me sample tables or sampl
e
> databases? (mdb file or the scripts with your tables)
> I understand the information must be sensitive to you. Alternatively, to
> efficiently troubleshoot a this issue, we recommend that you contact
> Microsoft Customer Service and Support and open a support incident and wor
k
> with a dedicated Support Professional.
> Please be advised that contacting phone support will be a charged call.
> However, if it turn out to be a bug in SP4 then charges are usually
> refunded or waived.
> To obtain the phone numbers for specific technology request please take a
> look at the web site listed below.
> http://support.microsoft.com/defaul...US;PHONENUMBERS
> If you are outside the US please see http://support.microsoft.com for
> regional support phone numbers.
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
=============
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>|||Hi Johan,
Thanks for your kindly sending me the database files.
After looking into the execution plan, I believe this is a known issue of
SQL Server service pack 4.
Since we add stack overflow checks in SP4, it raise this new problem. For
now, we do not have a pretty workaround for this issue.
However, if you want to apply SP4 and this issue has big business impact to
you. I would like to recommand you opening a grace case with Microsoft
Customer Service and Support (CSS). Please understand that we could not
share you the QFE request in the newsgroup.
Please be advised that contacting phone support will be a charged call.
However, if the support engineer confirmed this is a bug and no other
support then charges are usually refunded or waived.
To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/defaul...US;PHONENUMBERS
If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.
You could share the information below with the CSS support engineer
Bug# SQL Server 8.0 20000179
I do apologized for this new known issue that caused to you and thanks so
much for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi Michael
Thanks. Is there a quick fix available for this problem? We've advised all
our customers to go to SP4 (when it was released) and they wont be happy if
we tell them to go back to SP3a (as they all have this problem). Can you als
o
supply us with the KB number for this problem. Would it be possible for you
to send the QFE via e-mail to me?
Thanks in advance.
--
Johan Fourie
"Michael Cheng [MSFT]" wrote:

> Hi Johan,
> Thanks for your kindly sending me the database files.
> After looking into the execution plan, I believe this is a known issue of
> SQL Server service pack 4.
> Since we add stack overflow checks in SP4, it raise this new problem. For
> now, we do not have a pretty workaround for this issue.
> However, if you want to apply SP4 and this issue has big business impact t
o
> you. I would like to recommand you opening a grace case with Microsoft
> Customer Service and Support (CSS). Please understand that we could not
> share you the QFE request in the newsgroup.
> Please be advised that contacting phone support will be a charged call.
> However, if the support engineer confirmed this is a bug and no other
> support then charges are usually refunded or waived.
> To obtain the phone numbers for specific technology request please take a
> look at the web site listed below.
> http://support.microsoft.com/defaul...US;PHONENUMBERS
> If you are outside the US please see http://support.microsoft.com for
> regional support phone numbers.
> You could share the information below with the CSS support engineer
> Bug# SQL Server 8.0 20000179
> I do apologized for this new known issue that caused to you and thanks so
> much for your patience and cooperation. If you have any questions or
> concerns, don't hesitate to let me know. We are always here to be of
> assistance!
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
=============
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>|||Hi Johan,
Thanks for your update.
Unfortunately, I am so sorry to say that there is temporarily no public
Knowledge Base articles and document describing this issue. This issue only
occurs in SQL Server 2000 SP4, SQL Server 2000 SP3 and SQL Server 2005 do
not have this issue.
Unfortunately, I am unable to process the delivery of QFEs via email
directly. However, you should be able to quickly get this QFE by opening
the grace case with CSS.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

Query Processor Error after SP4

Hi All
We have a database with approx. 460 tables linked to a foreign key (UserID)
in a table called Users. After installing SQL SP4, when trying to delete an
unreferenced entry in the Users table (even using Enterprise Manager), we get
the following error: "[Microsoft][ODBC SQL Server Driver][SQL Server]Internal
Query Processor Error: The query processor encountered an unexpected error
during execution."
Using the same database on a SP3a SQL server, it works fine.
Thanks in advance
--
Johan FourieHi,
Johan Fourie,
Did u restarted ur sql services after installation of sp4.
hope this help
from
killer|||Hi Johan,
Thanks for your post.
From your descriptions, I understood you SELECT statements will report the
error message after applied SP4. If I have misunderstood your concern,
please feel free to point it out.
Based on my knowledge, SQL Server SP4 should fix a related error message.
Please refer the KB for more detailed information.
FIX: Internal Query Processor Error 8623 When Microsoft SQL Server Tries to
Compile a Plan for a Complex Query
http://support.microsoft.com/kb/818729
Is it possible for you to reproduce it on Northwind database? Would you
please generate a sample table, with which I could reproduct it on my side?
Any more error logs on your side? I understand the information may be
sensitive to you, my direct email address is v-mingqc@.online.microsoft.com
(please remember to remove "online" before click SEND as it's only for
SPAM), you may send the sample script file to me directly and I will keep
secure.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.|||Yes, we did many reboots since the upgrade to SP4
Thanks
--
Johan Fourie
"doller" wrote:
> Hi,
> Johan Fourie,
> Did u restarted ur sql services after installation of sp4.
> hope this help
> from
> killer
>|||Hi Michael
Ok, from SQL Query Analyzer the following command "DELETE FROM Users WHERE
UserID = 19" returns the following error: "Server: Msg 8630, Level 17, State
34, Line 1
Internal Query Processor Error: The query processor encountered an
unexpected error during execution."
I do not think it would be possible to simulate this problem on the
Northwind database as you need many FK links to the affected table. As you
can see, it is actually not a complex query, but SQL must determine whether
the entry being deleted is in use by one of the FK relationships (>460)
Thanks and much appreciated
--
Johan Fourie
"Michael Cheng [MSFT]" wrote:
> Hi Johan,
> Thanks for your post.
> From your descriptions, I understood you SELECT statements will report the
> error message after applied SP4. If I have misunderstood your concern,
> please feel free to point it out.
> Based on my knowledge, SQL Server SP4 should fix a related error message.
> Please refer the KB for more detailed information.
> FIX: Internal Query Processor Error 8623 When Microsoft SQL Server Tries to
> Compile a Plan for a Complex Query
> http://support.microsoft.com/kb/818729
> Is it possible for you to reproduce it on Northwind database? Would you
> please generate a sample table, with which I could reproduct it on my side?
> Any more error logs on your side? I understand the information may be
> sensitive to you, my direct email address is v-mingqc@.online.microsoft.com
> (please remember to remove "online" before click SEND as it's only for
> SPAM), you may send the sample script file to me directly and I will keep
> secure.
> Thank you for your patience and cooperation. If you have any questions or
> concerns, don't hesitate to let me know. We are always here to be of
> assistance!
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> =====================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>|||Hi Johan,
Thanks for the quick response.
It is very strange the SP4 enroll this new error message. I would like to
check it further. Is it possible for you to send me sample tables or sample
databases? (mdb file or the scripts with your tables)
I understand the information must be sensitive to you. Alternatively, to
efficiently troubleshoot a this issue, we recommend that you contact
Microsoft Customer Service and Support and open a support incident and work
with a dedicated Support Professional.
Please be advised that contacting phone support will be a charged call.
However, if it turn out to be a bug in SP4 then charges are usually
refunded or waived.
To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS
If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi Michael
Thanks for the quick response. We took the database again to a SP3a SQL
server and it works fine there, must be a SP4 problem. I'll be sending you
the database via e-mail shortly. Please treat the data and structure of the
database as very sensitive. Hope to hear from you soon.
Regards and many thanks.
--
Johan Fourie
"Michael Cheng [MSFT]" wrote:
> Hi Johan,
> Thanks for the quick response.
> It is very strange the SP4 enroll this new error message. I would like to
> check it further. Is it possible for you to send me sample tables or sample
> databases? (mdb file or the scripts with your tables)
> I understand the information must be sensitive to you. Alternatively, to
> efficiently troubleshoot a this issue, we recommend that you contact
> Microsoft Customer Service and Support and open a support incident and work
> with a dedicated Support Professional.
> Please be advised that contacting phone support will be a charged call.
> However, if it turn out to be a bug in SP4 then charges are usually
> refunded or waived.
> To obtain the phone numbers for specific technology request please take a
> look at the web site listed below.
> http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS
> If you are outside the US please see http://support.microsoft.com for
> regional support phone numbers.
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> =====================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>|||Hi Johan,
Thanks for your kindly sending me the database files.
After looking into the execution plan, I believe this is a known issue of
SQL Server service pack 4.
Since we add stack overflow checks in SP4, it raise this new problem. For
now, we do not have a pretty workaround for this issue.
However, if you want to apply SP4 and this issue has big business impact to
you. I would like to recommand you opening a grace case with Microsoft
Customer Service and Support (CSS). Please understand that we could not
share you the QFE request in the newsgroup.
Please be advised that contacting phone support will be a charged call.
However, if the support engineer confirmed this is a bug and no other
support then charges are usually refunded or waived.
To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS
If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.
You could share the information below with the CSS support engineer
Bug# SQL Server 8.0 20000179
I do apologized for this new known issue that caused to you and thanks so
much for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi Michael
Thanks. Is there a quick fix available for this problem? We've advised all
our customers to go to SP4 (when it was released) and they wont be happy if
we tell them to go back to SP3a (as they all have this problem). Can you also
supply us with the KB number for this problem. Would it be possible for you
to send the QFE via e-mail to me?
Thanks in advance.
--
Johan Fourie
"Michael Cheng [MSFT]" wrote:
> Hi Johan,
> Thanks for your kindly sending me the database files.
> After looking into the execution plan, I believe this is a known issue of
> SQL Server service pack 4.
> Since we add stack overflow checks in SP4, it raise this new problem. For
> now, we do not have a pretty workaround for this issue.
> However, if you want to apply SP4 and this issue has big business impact to
> you. I would like to recommand you opening a grace case with Microsoft
> Customer Service and Support (CSS). Please understand that we could not
> share you the QFE request in the newsgroup.
> Please be advised that contacting phone support will be a charged call.
> However, if the support engineer confirmed this is a bug and no other
> support then charges are usually refunded or waived.
> To obtain the phone numbers for specific technology request please take a
> look at the web site listed below.
> http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS
> If you are outside the US please see http://support.microsoft.com for
> regional support phone numbers.
> You could share the information below with the CSS support engineer
> Bug# SQL Server 8.0 20000179
> I do apologized for this new known issue that caused to you and thanks so
> much for your patience and cooperation. If you have any questions or
> concerns, don't hesitate to let me know. We are always here to be of
> assistance!
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> =====================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>|||Hi Johan,
Thanks for your update.
Unfortunately, I am so sorry to say that there is temporarily no public
Knowledge Base articles and document describing this issue. This issue only
occurs in SQL Server 2000 SP4, SQL Server 2000 SP3 and SQL Server 2005 do
not have this issue.
Unfortunately, I am unable to process the delivery of QFEs via email
directly. However, you should be able to quickly get this QFE by opening
the grace case with CSS.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Thanks. I'll open a case with CSS.
Regards.
--
Johan Fourie
"Michael Cheng [MSFT]" wrote:
> Hi Johan,
> Thanks for your update.
> Unfortunately, I am so sorry to say that there is temporarily no public
> Knowledge Base articles and document describing this issue. This issue only
> occurs in SQL Server 2000 SP4, SQL Server 2000 SP3 and SQL Server 2005 do
> not have this issue.
> Unfortunately, I am unable to process the delivery of QFEs via email
> directly. However, you should be able to quickly get this QFE by opening
> the grace case with CSS.
> Thank you for your patience and cooperation. If you have any questions or
> concerns, don't hesitate to let me know. We are always here to be of
> assistance!
>
> Sincerely yours,
> Michael Cheng
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> =====================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>|||Hi Johan,
Thanks for your cooperation.
I just wanted to follow up to let you know that the Support Engineer that
you are working with in CSS has contacted me directly to let me know that
the hotfix I recommended is not currently available to the public. I
apologize that I was not previously aware of this situation.
Please continue to work with the CSS Support Engineer for a workaround or
resolution to your issue.
Again, I am sorry that I was unaware that this hotfix is not available to
the public.
Thank you for your patience and cooperation.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================Business-Critical Phone Support (BCPS) provides you with technical phone
support at no charge during critical LAN outages or "business down"
situations. This benefit is available 24 hours a day, 7 days a week to all
Microsoft technology partners in the United States and Canada.
This and other support options are available here:
BCPS:
https://partner.microsoft.com/US/technicalsupport/supportoverview/40010469
Others: https://partner.microsoft.com/US/technicalsupport/supportoverview/
If you are outside the United States, please visit our International
Support page: http://support.microsoft.com/common/international.aspx
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.

Query Processor Error

I get the following message when I'm inserting a row into a table. The
statement is very simple, but there is a large amount of data going into one
column.
Internal Query Processor Error: The query processor ran out of stack space
during query optimization
All the KB articles I've found so far refer to queries that have a large
number of elements in an IN clause, or a CASE statement with a large number
of WHEN clauses - niether of which fit this scenario.
Has anyone else had this problem and found a way around it. I can't
replicate the problem on any of our development or test servers - it only
happens on the production server. All servers are the same spec - W2K
Server and SQL Server 2000 - all service packed up.
Any help appreciated.
Cheers,
CameronCameron,
Can you provide more information? What is the structure of the table,
and what is the insert statement, or at the least, what form does it have -
insert .. values, insert into .. select? Are there any triggers on the
table?
What indexes are on the table? Are any of the tables involved actually
views?
It's hard to suggest a way around a problem with this little information
about what you are trying to do.
-- Steve Kass
-- Drew University
-- Ref: 20CAE9D5-49D4-43CF-A330-EE3EB766EF1A
cj wrote:
>I get the following message when I'm inserting a row into a table. The
>statement is very simple, but there is a large amount of data going into one
>column.
>Internal Query Processor Error: The query processor ran out of stack space
>during query optimization
>All the KB articles I've found so far refer to queries that have a large
>number of elements in an IN clause, or a CASE statement with a large number
>of WHEN clauses - niether of which fit this scenario.
>Has anyone else had this problem and found a way around it. I can't
>replicate the problem on any of our development or test servers - it only
>happens on the production server. All servers are the same spec - W2K
>Server and SQL Server 2000 - all service packed up.
>Any help appreciated.
>Cheers,
>Cameron
>
>|||even though the statement may be simple, inserts could
have complex parsing for NULL conditions etc
the standard windows program defaults to 1MB stack size.
however, i believe this is reduced to 256K on sql server
for performance reasons.
in either Visual Studio C/C++ or the Windows Server EE
Customer Support Diagnostic, there are the utilities
editbin.exe and imagecfg.exe that lets you reconfigure the
stack size (sizes are in hex)
but i would try modifying your insert statement before
modifying the sql server binary, since this needs to be
redone every hotfix, sp etc
>--Original Message--
>I get the following message when I'm inserting a row into
a table. The
>statement is very simple, but there is a large amount of
data going into one
>column.
>Internal Query Processor Error: The query processor ran
out of stack space
>during query optimization
>All the KB articles I've found so far refer to queries
that have a large
>number of elements in an IN clause, or a CASE statement
with a large number
>of WHEN clauses - niether of which fit this scenario.
>Has anyone else had this problem and found a way around
it. I can't
>replicate the problem on any of our development or test
servers - it only
>happens on the production server. All servers are the
same spec - W2K
>Server and SQL Server 2000 - all service packed up.
>Any help appreciated.
>Cheers,
>Cameron
>
>.
>|||I would try DBCCs on the database in question, and if that didn't help, I
would call product support services and get them to help you out if you can
afford it. That sounds bad.
And don't cross post!
--
----
--
Louis Davidson (drsql@.hotmail.com)
Compass Technology Management
Pro SQL Server 2000 Database Design
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are
interested in consulting services. All other replies will be ignored :)
"cj" <smuffnstuff@.hotmail.com> wrote in message
news:O7Ptg8aoDHA.3612@.TK2MSFTNGP11.phx.gbl...
> I get the following message when I'm inserting a row into a table. The
> statement is very simple, but there is a large amount of data going into
one
> column.
> Internal Query Processor Error: The query processor ran out of stack space
> during query optimization
> All the KB articles I've found so far refer to queries that have a large
> number of elements in an IN clause, or a CASE statement with a large
number
> of WHEN clauses - niether of which fit this scenario.
> Has anyone else had this problem and found a way around it. I can't
> replicate the problem on any of our development or test servers - it only
> happens on the production server. All servers are the same spec - W2K
> Server and SQL Server 2000 - all service packed up.
> Any help appreciated.
> Cheers,
> Cameron
>|||What is this 1MB stack space ?
"joe chang" <anonymous@.discussions.microsoft.com> wrote in message
news:059e01c3a1bf$bba5da20$a401280a@.phx.gbl...
> even though the statement may be simple, inserts could
> have complex parsing for NULL conditions etc
> the standard windows program defaults to 1MB stack size.
> however, i believe this is reduced to 256K on sql server
> for performance reasons.
> in either Visual Studio C/C++ or the Windows Server EE
> Customer Support Diagnostic, there are the utilities
> editbin.exe and imagecfg.exe that lets you reconfigure the
> stack size (sizes are in hex)
> but i would try modifying your insert statement before
> modifying the sql server binary, since this needs to be
> redone every hotfix, sp etc
> >--Original Message--
> >I get the following message when I'm inserting a row into
> a table. The
> >statement is very simple, but there is a large amount of
> data going into one
> >column.
> >
> >Internal Query Processor Error: The query processor ran
> out of stack space
> >during query optimization
> >
> >All the KB articles I've found so far refer to queries
> that have a large
> >number of elements in an IN clause, or a CASE statement
> with a large number
> >of WHEN clauses - niether of which fit this scenario.
> >
> >Has anyone else had this problem and found a way around
> it. I can't
> >replicate the problem on any of our development or test
> servers - it only
> >happens on the production server. All servers are the
> same spec - W2K
> >Server and SQL Server 2000 - all service packed up.
> >
> >Any help appreciated.
> >
> >Cheers,
> >
> >Cameron
> >
> >
> >.
> >|||Have you got an insert trigger on the table? What are your settings for
nested and recursive triggers?
HTH,
Greg Low (MVP)
MSDE Manager SQL Tools
www.whitebearconsulting.com
"cj" <smuffnstuff@.hotmail.com> wrote in message
news:O7Ptg8aoDHA.3612@.TK2MSFTNGP11.phx.gbl...
> I get the following message when I'm inserting a row into a table. The
> statement is very simple, but there is a large amount of data going into
one
> column.
> Internal Query Processor Error: The query processor ran out of stack space
> during query optimization
> All the KB articles I've found so far refer to queries that have a large
> number of elements in an IN clause, or a CASE statement with a large
number
> of WHEN clauses - niether of which fit this scenario.
> Has anyone else had this problem and found a way around it. I can't
> replicate the problem on any of our development or test servers - it only
> happens on the production server. All servers are the same spec - W2K
> Server and SQL Server 2000 - all service packed up.
> Any help appreciated.
> Cheers,
> Cameron
>

Query problems - Group By and Latest date

Hi all,

hopefully someone can suggest the best way of implementing the problem i am trying to resolve. We have a table which contains rows relating to tests run on our product. This table is populated from an SSIS job which parses CSV files.

There are multiple rows per serial number relating to multiple tests. The only tests i am interested in are the ones with an ID of T120. Here is the query i have so far which should make it a little easier to explain:

SELECT [SerialNumber]
,Param1
,[TimeStamp]
FROM [Build Efficiency System].[dbo].[SSIS_SCANNERDATA_TBL]
WHERE Test = 'T120'
GROUP BY SerialNumber, Param1, [TimeStamp]
ORDER BY SerialNumber

What i have above is fine to a point. The problem i am encountering is that in test T120 it specifies a part which can be be one of about 6 in field Param1. If during testing there is a problem with the part then it is replaced and the test run a second time up until the whole product passes the test. The query above returns all instances of replacements so i may have the out put as follows:

SerialNumber Param1 TimeStamp
0 Part1 15/03/07
0 Part2 15/03/07
0 Part2 16/03/07
0 Part3 15/03/03

What i really need is to only list the last part that is installed, hence the one with the latest timestamp:

SerialNumber Param1 TimeStamp

0 Part1 15/03/07

0 Part2 16/03/07

0 Part3 15/03/03

Can someone please help me to alter the above query so that it will show only those Param1 fields that have the latest date for each part.

Many thanks in advance,

Grant

This should do the trick:

SELECT [SerialNumber]
,Param1
,MAX([TimeStamp])
FROM [Build Efficiency System].[dbo].[SSIS_SCANNERDATA_TBL]
WHERE Test = 'T120'
GROUP BY SerialNumber, Param1
ORDER BY SerialNumber

You only need to take the max of your timestamp field (and remove it from the group by). The group by all fields is a bit extreme in the previous query (you could use the distinct keyword instead if you had apparent duplicate rows (i.e. replaced the part 3 times in a day).

|||Thats sorted it.
I wasn't as far of the mark in the first place as i'd thought. Thank's very much for the assistance, its much appreciated.

Cheers,

Grant|||Hi, apologies but i need one more piece of advice on this subject.

If i want to include a column with a serial number of the part that has been replaced, how would i do that. As soon as i add it, it needs to be part of an aggregate function or the group by clause. When it becomes part of the group by clause it then duplicates the part again.

Any ideas?

Thanks,

Grant|||

Is the serial number of the part in the same table - if so presumably it is different for each time that part is replaced. You can use a nested query to get that - however it will run into a problem if there are multiple records with the same date. As it stands at the moment you could not distinuish between them.

If you had records:

SerialNumber Param1 TimeStamp Part_SN
0 Part1 15/03/07 1234
0 Part2 15/03/07 1235
0 Part2 16/03/07 1236
0 Part2 16/03/07 1237
0 Part3 15/03/03 1238

How would you know which of the two Part2 items fitted on 16 Mar to give the serial number of? If there are additional fields to determine this then we need to use them

If this does not arise then the query below should serve (substitute correct fieldname for Part_SN):

SELECT B.[SerialNumber]
,B.Param1
,B.[TimeStamp]
,B.Part_SN
FROM (
SELECT [SerialNumber]
,Param1
,MAX([TimeStamp]) AS TimeStamp
FROM [Build Efficiency System].[dbo].[SSIS_SCANNERDATA_TBL]
WHERE Test = 'T120'
GROUP BY SerialNumber, Param1
) A
INNER JOIN [Build Efficiency System].[dbo].[SSIS_SCANNERDATA_TBL] B
ON (A.[SerialNumber] = B.[SerialNumber]) AND
(A.Param1 = B.Param1) AND
(A.[TimeStamp] = B.[TimeStamp]) AND
(B.Test = 'T120')
ORDER BY B.[SerialNumber]

If this is a problem then you will get multiple records in that case - one for each serial number. If the TimeStamp is a datetime which includes the time of the replacement then this will not be an issue (as long as the required serial number is the last record.

|||Thanks,

That is exactly what i wanted to do. Works like a charm.

Grantsql

Wednesday, March 28, 2012

Query Problem!

Hello!
I am using Visual Studio 2005 and Microsoft SQL Server 2005 Express Edition.
I have a table like this in my db:

-- MyTable ------------------------

id name
1 ??????????
?????????? ??? 2

-----------------------------

You can see non-english characters under name.
Now it is my query:
SELECT *
FROM MyTable
WHERE (name LIKE '%??????????%')

But it doesn't bring up any results... I have used = sign, but it doesn't do anything...

Why?

Sorry for my poor EnglishWhat is your data type andcollation setting for the Name column?|||

Try LIKE N'%....'

Sorry if it doesn't work, I don't usually work with foreign characters that way, I would use a parameter and let the user type whatever they needed.

|||It works! Thanks.

Query Problem in Access

hi friends i need help in this sql query

i have table like,

id fid
__ _____
autonumber text

and i am storing values like

id fid
___________________________________
1 1,2,3,4,5

2 11,12,13,14,15

now to find values i am using query

sql = SELECT * FROM test12 WHERE `fid` LIKE ('%1%')

only problem in this query is it is selecting 1 and 11 and i require
only 1 as i am giving one in %1%

now from this group some one give me the answer of this query

select *
from test
where fid = '1' -- singleton
or fid like '1,%' -- beginning of line
or fid like '%,1,%' -- middle of line
or fid like '%,1' -- end of line

now this query is running perfectly in other database except msaccess
2000. can anyone solve this problem. this query is not giving any
answer. it checks all those records which are singleton but not middle
of line records. and it seems to be problem in access only not in
mysql. it is working perfectly in mysql but not in access and as access
is my database in application i have to use access and i am really
irritate when i find in help that either i can use ' * ' or ' % ' in
expression on any one side like '%,1' or '%1,' but not like middle of
line that i am using '%,1,%'

here is example of my problem

sample table:=

id fid
___________________________________
1 1,2,3,4,5

2 11,12,13,14,15

query like

select *
from test
where fid = '1' -- singleton
or fid like '1,%' -- beginning of line
or fid like '%,1,%' -- middle of line
or fid like '%,1' -- end of line

will result id=1 perfectly but when i search

select *
from test
where fid = '2' -- singleton
or fid like '2,%' -- beginning of line
or fid like '%,2,%' -- middle of line
or fid like '%,2' -- end of line

it will not give me no output. plz help me i dont know what is the
problem if anyone can solve this i will be really thankful.On 19 Oct 2006 00:57:20 -0700, hardik wrote:

Quote:

Originally Posted by

>hi friends i need help in this sql query
>
>i have table like,
>
>id fid
>__ _____
>autonumber text
>
>and i am storing values like
>
>id fid
>___________________________________
>1 1,2,3,4,5
>
>2 11,12,13,14,15
>
>now to find values i am using query
>
>sql = SELECT * FROM test12 WHERE `fid` LIKE ('%1%')


(snip)

Hi hardik,

You should really change this design. The fid column violates the
principle of first normal form. That makes many queries needlessly
complex and slow. A proper design would split the comma-delimited list
in fid into seperate rows:

id fid
1 1
1 2
1 3
1 1
1 1
2 11
2 12
2 13
2 14
2 15

Then, you'd just use SELECT * FROM better_table WHERE fid = '1'

(snip)

Quote:

Originally Posted by

>now from this group some one give me the answer of this query
>
>select *
>from test
>where fid = '1' -- singleton
>or fid like '1,%' -- beginning of line
>or fid like '%,1,%' -- middle of line
>or fid like '%,1' -- end of line


Works, but there is a shorter kludge possible:
SELECT * FROM test WHERE ',' + fld + ',' LIKE '%,1,%'

Quote:

Originally Posted by

>now this query is running perfectly in other database except msaccess
>2000.


Access doesn't use the ANSI standard wildcards for LIKE searches. In
Access, you have t replace the '%' character with '*'.

But the best solution is: fix the design!!

--
Hugo Kornelis, SQL Server MVP

query problem (lack of knowledge on my part)

Hello,

I've been trying for a couple of days now with the following problem in SQL

Ive a table called tblRresults that has the following

Date - just a regular date

OfficeLocation - just a unique id such as a zip code

SampleType - contains things like wall, floor, beam

SampleResult - "Detected" or "NotDetected"

When populated the table can look like

12/12/05 99505 Wall Detected

12/12/05 99505 Wall NotDetected

10/04/05 99211 Beam Detected

10/04/05 99211 Beam Detected

10/04/05 99111 Floor NotDetected

10/04/05 99111 Floor NotDetected

What I want is (I guess) a crosstab query that produces the following

Date Location SampleType CountDetected CountNotDetected

12/12/05 99505 Wall 1 1

10/04/05 99211 Beam 2 0 (or null would be ok)

10/04/05 99111 Floor 0 2

Any help gratefully accepted, this has been driving me mental!

thanks

Select Date,Location,SampleType,SUM(CASE WHEN SampleResult='Detected' THEN 1 ELSE 0 END) AS CountDetected,SUM(CASE WHEN SampleResult='NotDetected' THEN 1 ELSE 0 END) AS CountNotDetected

FROM table

GROUP BY Date,Location,SampleType

|||thanks very much! - I had no idea CASE existed

Query problem - top 5 validation

Hi,
I have a problem to run a query like this scenario:
i have players in a table who have scored in many matches and i want to take
the 5 latest.
The latest i want to multiply with 1.0 and then after with 0.8, 0.6, 0.4 and
finally 0.2.
playerid round score
1, 10, 122
1, 9, 123
1, 8, 222
1, 7, 333
1, 6, 222
And i want to multiply 122 * 1 + 123*0,8 + 222*0,6 + 333*0,4 + 222*0,2
Even handle if there are only 3 score.
Help, who can i do that in sql?
Regards
TWHi
It is always better to post DDL and example data see
http://www.aspfaq.com/etiquett?e.asp?id=5006
If the relationship between rounds is constant then you can use something
like:
CREATE TABLE #scores ( playerid int, [round] int, score decimal(8,3))
INSERT INTO #scores ( playerid, [round], score )
SELECT 1, 10, 122
UNION ALL SELECT 1, 9, 123
UNION ALL SELECT 1, 8, 222
UNION ALL SELECT 1, 7, 333
UNION ALL SELECT 1, 6, 222
INSERT INTO #scores ( playerid, [round], score )
SELECT 2, 9, 111
UNION ALL SELECT 2, 8, 222
UNION ALL SELECT 2, 7, 333
SELECT p.playerid,SUM(p.score*(1-(0.2*p.rank)))
FROM ( SELECT playerid,score,
(SELECT COUNT(*) FROM #scores s where s.[round] > r.[round] AND s.playerid =
r.playerid) as Rank
from #scores r ) p
where p.rank < 6
GROUP BY p.playerid
Alternatively use a table to store the multiplying factor.
John
"tw" <tw@.tactics.se> wrote in message
news:uyI$86lTFHA.616@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I have a problem to run a query like this scenario:
> i have players in a table who have scored in many matches and i want to
> take the 5 latest.
> The latest i want to multiply with 1.0 and then after with 0.8, 0.6, 0.4
> and finally 0.2.
> playerid round score
> 1, 10, 122
> 1, 9, 123
> 1, 8, 222
> 1, 7, 333
> 1, 6, 222
> And i want to multiply 122 * 1 + 123*0,8 + 222*0,6 + 333*0,4 + 222*0,2
> Even handle if there are only 3 score.
> Help, who can i do that in sql?
> Regards
> TW
>|||Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are. Sample data is also a good idea, along with clear
specifications. Here is my guess
CREATE TABLE Scorecards
(player_id INTEGER NOT NULL,
round_nbr INTEGER NOT NULL,
PRIMARY KEY (player_id, round_nbr),
score INTEGER NOT NULL);
INSERT INTO Scorecards VALUES (1, 10, 122);
INSERT INTO Scorecards VALUES (1, 9, 123);
INSERT INTO Scorecards VALUES (1, 8, 222);
INSERT INTO Scorecards VALUES (1, 7, 333);
INSERT INTO Scorecards VALUES (1, 6, 222);
INSERT INTO Scorecards VALUES (1, 5, 222);
SELECT W.player_id, SUM(W.weighted_score)
FROM (
SELECT S1.player_id,
(S1.score
* CASE WHEN round_nbr
= (SELECT MAX(round_nbr)
FROM Scorecards AS S2
WHERE S1.player_id = S2.player_id)
THEN 1.0
WHEN round_nbr
= (SELECT MAX(round_nbr)-1
FROM Scorecards AS S2
WHERE S1.player_id = S2.player_id)
THEN 0.8
WHEN round_nbr
= (SELECT MAX(round_nbr)-2
FROM Scorecards AS S2
WHERE S1.player_id = S2.player_id)
THEN 0.6
WHEN round_nbr
= (SELECT MAX(round_nbr)-3
FROM Scorecards AS S2
WHERE S1.player_id = S2.player_id)
THEN 0.4
WHEN round_nbr
= (SELECT MAX(round_nbr)-4
FROM Scorecards AS S2
WHERE S1.player_id = S2.player_id)
THEN 0.2 ELSE 0.0 END)
FROM Scorecards AS S1)
AS W(player_id, weighted_score)
GROUP BY W.player_id;
Put this in a VIEW so the system will update it for you. You can also
use the proprietary, non-portable TOP option if you do not care about
standards. It might be faster in SQL Server, but a good optimizer
would pull out the common expressions in the WHEN clauses and compute
each MAX() only once, probably getting it from an index on the
primarykey. TOP has to do a partition or sort under the covers.|||Hi John,
Im very thankful of your sql code, it works perfect.
Sorry about not post dll, it was new for me.
How should the sql string look if i have a table with multiplying
factor?
tw
*** Sent via Developersdex http://www.examnotes.net ***|||Hi
You would need to add table (this one if temporary for demonstration)
CREATE TABLE #Multipliers ( Rank int, factor decimal(8,3) )
INSERT INTO #Multipliers ( Rank, factor )
SELECT 1, 1
UNION ALL SELECT 2, 0.8
UNION ALL SELECT 3, 0.6
And change the query to something like:
SELECT p.playerid,SUM(p.score*m.factor)
FROM ( SELECT playerid,score,
(SELECT COUNT(*) FROM #scores s where s.[round] > r.[round] AND s.playerid =
r.playerid) as Rank
from #scores r ) p
JOIN #Multipliers m ON p.rank = m.rank -- restricted by number of entries
in #Multipliers
GROUP BY p.playerid
You could also fit this into Joes solution.
John
"t w" <tw@.tactics.se> wrote in message
news:uVASgDnTFHA.3980@.TK2MSFTNGP12.phx.gbl...
> Hi John,
> Im very thankful of your sql code, it works perfect.
> Sorry about not post dll, it was new for me.
> How should the sql string look if i have a table with multiplying
> factor?
> tw
> *** Sent via Developersdex http://www.examnotes.net ***

Query problem

Hi,

I've got the following problem:

In a table named "Commission" are all commissions of sales people per month listed.
Now I have to calculate and update the following:
I have to sum up the commissions (data type money) by month (smallint) and salesmanID(int). If the monthly sum is getting negative (yes, can happen!), I have to set it back to "0" for any sales record in the table "Commission".

I tried with views and subsets of select - statements, but I did not find a solution and I don't want to use MDX-statements instead in a cube later.

Has any brain a solution for me available ?

Thx a lot

dajmSummarizing Data Using COMPUTE and COMPUTE BY

In books online

Basically you can follow pretty much any select with a COMPUTE directive and pull up any aggregate you want.|||Originally posted by HanafiH
Summarizing Data Using COMPUTE and COMPUTE BY

In books online

Basically you can follow pretty much any select with a COMPUTE directive and pull up any aggregate you want.

Sorry, but COMPUTE is not helping me as I have to compare the result with `0`and to update the same fact table . Any ideas ?

Thx.|||use a cursor

Originally posted by dajm
Hi,

I've got the following problem:

In a table named "Commission" are all commissions of sales people per month listed.
Now I have to calculate and update the following:
I have to sum up the commissions (data type money) by month (smallint) and salesmanID(int). If the monthly sum is getting negative (yes, can happen!), I have to set it back to "0" for any sales record in the table "Commission".

I tried with views and subsets of select - statements, but I did not find a solution and I don't want to use MDX-statements instead in a cube later.

Has any brain a solution for me available ?

Thx a lot

dajm|||set based solutions are almost always better than cursor solutions

update the Commission table for each month/salesman where total commissions for the month are negative:update Commission
set commissions = 0
from Commission as table1
inner
join (
select themonth
, salesmanID
from Commission
group
by themonth
, salesmanID
having sum(commissions) < 0
) as table2
on table1.themonth = table2.themonth
and table1.salesmanID = table2.salesmanID(caution: untested, but it should work)

rudy
http://r937.com/|||try CASE along with COMPUTE statement.|||Super solution. Thx a lot...

dajm

Originally posted by r937
set based solutions are almost always better than cursor solutions

update the Commission table for each month/salesman where total commissions for the month are negative:update Commission
set commissions = 0
from Commission as table1
inner
join (
select themonth
, salesmanID
from Commission
group
by themonth
, salesmanID
having sum(commissions) < 0
) as table2
on table1.themonth = table2.themonth
and table1.salesmanID = table2.salesmanID(caution: untested, but it should work)

rudy
http://r937.com/

query problem

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. ;)