Showing posts with label sqlserver. Show all posts
Showing posts with label sqlserver. Show all posts

Monday, March 26, 2012

Help on multiple date range on sql statement

Using SQLServer ver 7.0, two tables:
TableA = contains all inventory data
TableB = contains four fields: ID, source, date_from, date_to
This is where multiple range of dates are populated.
Sample 1:
1,'A','9/1/2004','9/30/2004'

Sample 2:
2,'A','1/1/2003','3/31/2003'
3,'A','10/1/2004','10/31/2004'

Data populated on TableB varies.

Sample SQL for Sample 1:
SELECT *
FROM TableA
WHERE inventory_date BETWEEN (select DATE_FROM from TableB) AND (select
DATE_TO from TableB)

Problem: How to approach sql statement based on Sample 2 above?B (no_spam@.no_spam.com) writes:
> Using SQLServer ver 7.0, two tables:
> TableA = contains all inventory data
> TableB = contains four fields: ID, source, date_from, date_to
> This is where multiple range of dates are populated.
> Sample 1:
> 1,'A','9/1/2004','9/30/2004'
> Sample 2:
> 2,'A','1/1/2003','3/31/2003'
> 3,'A','10/1/2004','10/31/2004'
> Data populated on TableB varies.
>
> Sample SQL for Sample 1:
> SELECT *
> FROM TableA
> WHERE inventory_date BETWEEN (select DATE_FROM from TableB) AND (select
> DATE_TO from TableB)

SELECT *
FROM TableA A
JOIN TableB B ON B.ID = A.ID
WHERE A.inventory_date BETWEEN B.date_from ABD B.date_to

But this is really a guess. If this does not answer your question, please
post:

o CREATE TABLE statements for your tables.
o INSERT statements with sample data.
o The expected result given the sample data.

That makes it possible to post a tested solution.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||On Mon, 8 Nov 2004 22:40:44 -0500, B wrote:

>Using SQLServer ver 7.0, two tables:
>TableA = contains all inventory data
>TableB = contains four fields: ID, source, date_from, date_to
>This is where multiple range of dates are populated.
>Sample 1:
>1,'A','9/1/2004','9/30/2004'
>Sample 2:
>2,'A','1/1/2003','3/31/2003'
>3,'A','10/1/2004','10/31/2004'
>Data populated on TableB varies.
>
>Sample SQL for Sample 1:
>SELECT *
>FROM TableA
>WHERE inventory_date BETWEEN (select DATE_FROM from TableB) AND (select
>DATE_TO from TableB)
>Problem: How to approach sql statement based on Sample 2 above?

Hi B,

If you want it to return all inventory details with an inventory_date
between 1/1/2003 and 3/31/2003 or with an inventory date between 10/1/2004
and 10/31/2004, try this query:

SELECT A.Column1, A.Column2, ..., A.ColumnN
FROM TableA AS A
INNER JOIN TableB AS B
ON A.inventory_date BETWEEN B.DATE_FROM and B.DATE_TO

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)|||This is exactly solution I needed.

Many thanks for your time!
Bob

> If you want it to return all inventory details with an inventory_date
> between 1/1/2003 and 3/31/2003 or with an inventory date between 10/1/2004
> and 10/31/2004, try this query:
> SELECT A.Column1, A.Column2, ..., A.ColumnN
> FROM TableA AS A
> INNER JOIN TableB AS B
> ON A.inventory_date BETWEEN B.DATE_FROM and B.DATE_TO
> Best, Hugo
> --
> (Remove _NO_ and _SPAM_ to get my e-mail address)

Monday, March 12, 2012

Help needed regarding the procedure

Hi All

I am new to sqlserver.I got the doubt when i want to perform a task.Need yours advice

In a table i am having a column email with mailids. most of the rows are with the value email@.email.com.
My requirement is i want to change the value email@.email.com as email1@.email.com,email2@.email.com,.....like that
with autoincrement.Here primarykey attribute name is id

Waiting for valuable suggestions

Baba

I take it you don't want to update ALL emails in your table, just the duplicate ones (email@.email.com)?

If so, it depends on whether the number is important or whether you just want to make each value distinct.

To just get distinct values you could just run:

Code Snippet

UPDATE table

SET email = 'email' + CAST(id AS VARCHAR(100)) + '@.email.com'

WHERE email = 'email@.email.com'

If the number is important and you want the values to go sequentially from 1-> n then you'll probably have to use some procedural code, such as a cursor though you'll still need an update statement similar to the one above.


HTH!

|||
Thank u for u r reply.

I applied cursors concept and i updated it.

Thank u

Baba
|||

You might want to show us what you come up with when you are done so that we can verify it for you; it is always a good idea to have another set of eyes to look at something.

|||

There's a way to get the numbers to be sequential without cursors etc:

Code Snippet

UPDATE table

SET email = 'email' + Convert(varchar(100), (select count(*) from table t2 where t2.id < t1.id and t2.email = 'email@.email.com')) + '@.email.com'

FROM table t1

WHERE email = 'email@.email.com'

It's late and I haven't tested it so there may be errors, but hopefully that gives you the general idea.

Sean

Help needed on SQLServer , Error 18456

Hi All,

I have tried accessing a remote database in one of by stored procs using linked servers and also using OpenDataSource method.
In both the cases , I am getting login failed error.

Following is the stored proc :

CREATE PROCEDURE TEST AS

SELECT *
FROM OPENDATASOURCE(
'SQLOLEDB',
'Data Source=blrkec3432s;User ID=xyz;Password=xyz').LMC.dbo.STATE
GO

It works fine if the userid is 'sa'

Could anyone please tell me the reason for this.

Thanks,
ShanthiResolution from SQLMAG link (http://www.winnetmag.com/SQLServer/Article/ArticleID/8992/8992.html)

Help needed on Full text Search

Hello,
we got a requirement where i hvae to implement a full text search in SQL
Server 2000/2005. Can some one help me Where/How to start ? Any links for
the articles is also good.
Thanks in Advance
Srinivas
have a look at the links in indexserverfaq.com for sql fts.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Srinivas Kollipara" <skollipara@.stratasolutions.com> wrote in message
news:eweiaU9FGHA.516@.TK2MSFTNGP15.phx.gbl...
> Hello,
> we got a requirement where i hvae to implement a full text search in SQL
> Server 2000/2005. Can some one help me Where/How to start ? Any links for
> the articles is also good.
> Thanks in Advance
> Srinivas
>

Help needed on Full text Search

Hello,
we got a requirement where i hvae to implement a full text search in SQL
Server 2000/2005. Can some one help me Where/How to start ? Any links for
the articles is also good.
Thanks in Advance
Srinivashave a look at the links in indexserverfaq.com for sql fts.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Srinivas Kollipara" <skollipara@.stratasolutions.com> wrote in message
news:eweiaU9FGHA.516@.TK2MSFTNGP15.phx.gbl...
> Hello,
> we got a requirement where i hvae to implement a full text search in SQL
> Server 2000/2005. Can some one help me Where/How to start ? Any links for
> the articles is also good.
> Thanks in Advance
> Srinivas
>

Friday, March 9, 2012

help needed ...to update the datatable

hi,

I have my database stored in the sqlserver 2005. Using the table name i am retrieving the table and it is displayed to the user in the form of datagridview.I am allowing the user to modify the contents of the table, including the headers. Is it possible for me to update the table straightway rather than giving a sql update command for each and every row of the table .

Pls reply asap....

-Sweety

Sure is.

Though this really isnt a SQL Issue you have. You also forgot to mention what programming language you are using (VB.NET, C# etc) If you are using the datagrid and a dataset, then its easily possible however, depending on what .net platform you are using (1.1, 2.0) if you tell us, we will be able to help further.|||

hi,

sorry for the duplicate posting.I am using VC# and .net 2.0..

bye

Sweety

Monday, February 27, 2012

Help me!

Hi Master!
I'm students in NIIT. I need info of Data management Strategies of SQL
Server to write Project and I dont' know Find Topic where. Pls send to me
Everything like i talk above.
I speak Eng not good, beacause I'm VietNamese. So sorry!!
Pls send back faster, i very need it.
Thanks for your Help!!
Hi
"Inside Microsoft SQL Server 2000" by Kalen Delaney
Hardcover: 1088 pages
Publisher: Microsoft Press; Book & CD edition (November 15, 2000)
Language: English
ISBN: 0735609985
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Thanh Hai" wrote:

> Hi Master!
> I'm students in NIIT. I need info of Data management Strategies of SQL
> Server to write Project and I dont' know Find Topic where. Pls send to me
> Everything like i talk above.
> I speak Eng not good, beacause I'm VietNamese. So sorry!!
> Pls send back faster, i very need it.
> Thanks for your Help!!
>
>
|||http://www.microsoft.com/technet/its.../smfstomg.mspx
"Thanh Hai" wrote:

> Hi Master!
> I'm students in NIIT. I need info of Data management Strategies of SQL
> Server to write Project and I dont' know Find Topic where. Pls send to me
> Everything like i talk above.
> I speak Eng not good, beacause I'm VietNamese. So sorry!!
> Pls send back faster, i very need it.
> Thanks for your Help!!
>
>

Help me!

Hi Master!
I'm students in NIIT. I need info of Data management Strategies of SQL
Server to write Project and I dont' know Find Topic where. Pls send to me
Everything like i talk above.
I speak Eng not good, beacause I'm VietNamese. So sorry!!
Pls send back faster, i very need it.
Thanks for your Help!!Hi
"Inside Microsoft SQL Server 2000" by Kalen Delaney
Hardcover: 1088 pages
Publisher: Microsoft Press; Book & CD edition (November 15, 2000)
Language: English
ISBN: 0735609985
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Thanh Hai" wrote:

> Hi Master!
> I'm students in NIIT. I need info of Data management Strategies of SQL
> Server to write Project and I dont' know Find Topic where. Pls send to me
> Everything like i talk above.
> I speak Eng not good, beacause I'm VietNamese. So sorry!!
> Pls send back faster, i very need it.
> Thanks for your Help!!
>
>|||http://www.microsoft.com/technet/it...f/smfstomg.mspx
"Thanh Hai" wrote:

> Hi Master!
> I'm students in NIIT. I need info of Data management Strategies of SQL
> Server to write Project and I dont' know Find Topic where. Pls send to me
> Everything like i talk above.
> I speak Eng not good, beacause I'm VietNamese. So sorry!!
> Pls send back faster, i very need it.
> Thanks for your Help!!
>
>

Friday, February 24, 2012

help me to solve this

hello,

i need to transfer (migrate ) the data from xl sheet to sqlserver but actually the thing is if the source excel file has different sheets, in each sheet i have the data

and i need to move the entire data( all the data that is present in all sheets of the excel file) to a single table into sql server

like wise i have many xl files ( which have many sheets ) .

for eg:

excel file 1:

-> sheet 1

-> sheet 2

-> sheet 3

excel file 2:

-> sheet 1

-> sheet 2

-> sheet 3

excel file 3:

-> sheet 1

-> sheet 2

-> sheet 3

now i need to get the data from all of the files and i need to insert into a single table ( sql server) in ssis package

so plz help me by giving the solution asap.

thanks

B L Rao

hello ,

while i am trying to transfer the data from xl file to table in sql server by using ssis package it is giving error saying that primary key violation and cant insert duplicate value.

i understood that there is some duplicate data but can i find where that duplicate data exists i mean in which row ? because it contains thousands of records.

thanks and regards

B L Rao.

|||You may accomplish this by using 2 nested Loops: One fairly simple, a foreach loop to iterate through all excel files; a second one to iterate through each excel sheet. I am not sure how to implement the second one; perhaps if the number and name of the sheets is always the same you could built a list of values in a variable and then have the excel component to get the table name from a variable. Just an Idea, you would need to figure out the details.

Sunday, February 19, 2012

help me get rid of the noise words please!

Hi,
I am a programmer with no SQLServer dba experience and have set up a full
text index on two columns in the same table. The index is working fine
except for when a noise word is used in a search. My problem is that I have
been unable to remove the noise words. I have searched the drive and deleted
everything from all of the noise.enu files - they are zero length. I have
gone to a command prompt and typed "net stop mssearch" and then "net start
mssearch". After stopping and starting mssearch, I have repopulated my
indexes by going to the table where the indexes are and using the
edit-full-text indexing wizard. I'm sure there is a better way but at the
completion of the wizard it drops the index and rebuilds it. I do have a
scheduled repopulation that runs every morning. When I open this job it has
the following code:
use [central] exec sp_fulltext_table N'[dbo].[Product]', N'start_full'.
This has been running successfully for quite a while.
What am I doing incorrectly that I can't get rid of the noise words?
Your help would be greatly appreciated!
[code generated from ASP page]
select * from Product where contains(Desc1, 'dvd AND r') or contains(Desc2,
'dvd AND r')
[System Summary]
Item Value
OS Name Microsoft Windows 2000 Advanced Server
Version 5.0.2195 Service Pack 4 Build 2195
OS Manufacturer Microsoft Corporation
System Manufacturer Hewlett-Packard
System Model HP NetServer
System Type X86-based PC
Processor x86 Family 6 Model 8 Stepping 10 GenuineIntel ~933 Mhz
BIOS Version 10/15/01
Windows Directory C:\WINNT
System Directory C:\WINNT\system32
Boot Device \Device\Harddisk0\Partition2
Locale United States
Time Zone Eastern Standard Time
Total Physical Memory 1,310,188 KB
Available Physical Memory 30,864 KB
Total Virtual Memory 4,435,520 KB
Available Virtual Memory 1,987,148 KB
Page File Space 3,125,332 KB
Page File C:\pagefile.sys
you have several options
1) use a freetext query, but this may return results that are too fuzzy for
you.
2) strip the noise words out by using a client side script - search this
newsgroup for searchpage1.htm
3) using tsql parsing on the server possibly a UDF
4) write an extended proc to parse them out
5) I'm wondering if you got the correct noise file. noise.eng is for British
English, noise.enu is for American English. Change the noise word lists you
find in
C:\Program Files\Microsoft SQL Server\MSSQL\FTDATA\SQLServer\Config
You will have to stop and start the mssearch service to make these changes.
"woodysapsucker" <woody@.rohland.org> wrote in message
news:OMbPJgoEEHA.3344@.tk2msftngp13.phx.gbl...
> Hi,
> I am a programmer with no SQLServer dba experience and have set up a full
> text index on two columns in the same table. The index is working fine
> except for when a noise word is used in a search. My problem is that I
have
> been unable to remove the noise words. I have searched the drive and
deleted
> everything from all of the noise.enu files - they are zero length. I have
> gone to a command prompt and typed "net stop mssearch" and then "net start
> mssearch". After stopping and starting mssearch, I have repopulated my
> indexes by going to the table where the indexes are and using the
> edit-full-text indexing wizard. I'm sure there is a better way but at the
> completion of the wizard it drops the index and rebuilds it. I do have a
> scheduled repopulation that runs every morning. When I open this job it
has
> the following code:
> use [central] exec sp_fulltext_table N'[dbo].[Product]', N'start_full'.
> This has been running successfully for quite a while.
> What am I doing incorrectly that I can't get rid of the noise words?
> Your help would be greatly appreciated!
>
> [code generated from ASP page]
> select * from Product where contains(Desc1, 'dvd AND r') or
contains(Desc2,
> 'dvd AND r')
>
> [System Summary]
> Item Value
> OS Name Microsoft Windows 2000 Advanced Server
> Version 5.0.2195 Service Pack 4 Build 2195
> OS Manufacturer Microsoft Corporation
> System Manufacturer Hewlett-Packard
> System Model HP NetServer
> System Type X86-based PC
> Processor x86 Family 6 Model 8 Stepping 10 GenuineIntel ~933 Mhz
> BIOS Version 10/15/01
> Windows Directory C:\WINNT
> System Directory C:\WINNT\system32
> Boot Device \Device\Harddisk0\Partition2
> Locale United States
> Time Zone Eastern Standard Time
> Total Physical Memory 1,310,188 KB
> Available Physical Memory 30,864 KB
> Total Virtual Memory 4,435,520 KB
> Available Virtual Memory 1,987,148 KB
> Page File Space 3,125,332 KB
> Page File C:\pagefile.sys
>
|||Thanks Hilary,
I am trying to still use the noise words in the queries. I would like the
query to be on "dvd r" not just "dvd". That is why I've been trying to empty
out the noise word files.
I am from the US but also emptied noise.eng files - just incase - and reran
the indexing.
Any other suggestions?
"Hilary Cotter" <hilaryk@.att.net> wrote in message
news:eYFPX1oEEHA.688@.tk2msftngp13.phx.gbl...
> you have several options
> 1) use a freetext query, but this may return results that are too fuzzy
for
> you.
> 2) strip the noise words out by using a client side script - search this
> newsgroup for searchpage1.htm
> 3) using tsql parsing on the server possibly a UDF
> 4) write an extended proc to parse them out
> 5) I'm wondering if you got the correct noise file. noise.eng is for
British
> English, noise.enu is for American English. Change the noise word lists
you
> find in
> C:\Program Files\Microsoft SQL Server\MSSQL\FTDATA\SQLServer\Config
> You will have to stop and start the mssearch service to make these
changes.
> "woodysapsucker" <woody@.rohland.org> wrote in message
> news:OMbPJgoEEHA.3344@.tk2msftngp13.phx.gbl...
full
> have
> deleted
have
start
the
> has
> contains(Desc2,
>