Simple (i Hope) SQL Help Needed

Sep 20, 2004

I was looking for a way to "globally" set my FROM database value. Is this possible?, or does the "FROM" syntax always require the database name? I would like to just state my table names in the FROM statement

BEFORE Example:
select T1.id, FROM PT.ptuser.tblRequest T1, where etc....

Can the "PT.ptuser" be declared somehow 1 time so my SQL code could look like...

AFTER Example:
select T1.id, FROM tblRequest T1, where etc....

hope this makes sense.... I'm trying to run SQL via Microsoft Query

View 4 Replies


ADVERTISEMENT

Simple Question (Hope Simple Answer Too)

May 26, 2004

Hey,

I have MS SQL database.
I have procedure:



code:--------------------------------------------------------------------------------
CREATE PROCEDURE dbo.Reg_DropTable
@ModuleId varchar(10)
AS
declare @TableName varchar, @kiek numeric
set @TableName = 'reg_'+@ModuleId

begin
DROP TABLE @TableName <- HERE I GOT ERROR
end
GO
--------------------------------------------------------------------------------


I got error when using variable with tables names.
How to do this?

Ps. Number is send to this function and it must drop table with name Reg_[That number]

View 1 Replies View Related

Two Simple (I HOPE) SQL Insert() Follow Up Questions:

Apr 28, 2007

1. Let's say I have a SqlDataSource named Fred. Say I have a string variable, call it Barney. If I call Fred.Insert(Barney) HOW Does the insert command GET the Barney value and pass it to the SQL Insers string? 2. Lets say also in this same insert, I want the user Lets say Batty, who is logged in, to have her username automatically inserted into the table along with her Barney value. What is the method to get a hold of user name that is magically floating around in the session somewhere? All said and done, I'd love for it to work like this: "INSERT INTO [BedRock] ([UserName], [Character] ) VALUES (SomethingThatResolvesToSignedInUserName, SomehtingThatResolvesToStringValueofVariable) Table BedrockUserName               CharacterBettyRubble            'Bam-Bam'  THANKS inadvance fro ANY HelpDan-Simple and sleepless-Harper

View 3 Replies View Related

Filtering By Attributes In MDX (simple Question I Hope!)

May 28, 2007

i have an Instrument dimension which consists of the following attributes:



RIC (Key)

Name

ExpiryDate



I can run the following query:



select {} on 0, [INSTRUMENT].[RIC].Children on 1

from [Itdev1 Hk]



which lists out the members of the RIC attribute hierarchy of the instrument dimension.



How do I modify the mdx to list only those instruments where Expiry date > today?



cheers,



JG

View 6 Replies View Related

Simple SQL Help Needed

Jul 23, 2005

I'm looking for SQL code to do the following.TableAGrpID,IndID,Locked50001,10001,050001,10002,050002,10003,050002,10004,150002,10005,050003,10006,050003,10007,050003,10008,050004,10009,050004,10010,050004,10011,150004,10012,1I would like to return GrpID's where All IndID have Locked = 0RecordsetGrpID5000150003Email me at the following:Join Bytes!

View 2 Replies View Related

Simple Query Help Needed!

Aug 15, 2007

Hi I'm new to SQL and I'm stuggling with a simple query in MS-server 2005 and wondered if anyone can help me.

I'm trying to devide the ansewrs of two seperate queries, but both the queries use the same coloumn in the where clause to get the answer. Please can some one help!


eg.

select Sum(column1)

where column1 = 'x'

devided by

select Sum(column1)

where column1 = 'y'

View 2 Replies View Related

Simple SUM Function Needed

Jul 19, 2006

Hello all. I have an Access table with EmpName, JobTask, and Hours. Multiple lines can contain the same Employee with the same JobTask. What I need to do is to list the Employee, JobTasks (grouped), and summed hours for each JobTask.

DB Ex:

John Doe Welding 8
John Doe Cleaning 4
Bubba Smith Fork Lift 3
John Doe Welding 7
Steve Johnson Welding 5
Bubba Smith Fork Lift 6


Page output:

John Doe
Welding 15 hrs.
Cleaning 4 hrs.

Bubba Smith
Fork Lift 9 hrs.

Steve Johnson
Welding 5 hrs.

This is how I figured it should be, but it's not working for me:

SELECT EmpName, SUM (Hours), JobTask
FROM tblEmpTime
Group By JobTask

Any suggestions would be greatly appreciated.

Thanks,

Parallon

View 4 Replies View Related

Help Needed With Simple Case Statement In SQL

Mar 1, 2007

Hello,
 
I am looking to modify this Case Statement.  Where it says ELSE '' I need it to display the actual contents of the cell.  1 = Yes , 0 = No, (any other integer) = actual value. 
Right now if the value is anything other than 1 or 0,  it will leave the cell blank.
CASE dbo.Training.TrainingStatus WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END AS TrainingStatus
Thank You.

View 1 Replies View Related

Help Needed With Simple Stored Procedure

Mar 31, 2007

Hey all,
Can anyone tell me why this stored procedure doesn't work?
 
ALTER PROCEDURE [dbo].[RemoveLocation]
@Id int,
@Name varchar
AS
DELETE FROM Classifieds_Terminals
WHERE [Id] = @Id and [Name] = @Name
 
 
I try exeuting it like this:
USE [CLASSIFIEDSDB2.MDF]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[RemoveLocation]
@Id = 18,
@Name = N'Terminal A'
SELECT 'Return Value' = @return_value
GO
 
 
It returns 0 and nothing happens....???
 
Here is the table:
id | Name 
18 Terminal A18 Terminal B18 Terminal C

View 2 Replies View Related

Fast Help Needed On Simple Linked SQL Server Select

Jan 11, 2002

I have 2 SQL 2000 servers. One has been added as a linked server.
They both have a db called claims. If I am on server 1 and want to write a sql statement I am stuck with the write syntax

I tried select patient.* from testedi..claims.

The server is linked using the sa user. I know this is simple but in a hurry and stuck. THe servers are on same domain.
Thanks

View 1 Replies View Related

I Hope Its The Right Forum...

Sep 12, 2005

how to use MSSQL in asp.net?

View 2 Replies View Related

Hope That You Can Help Me In This.Need Someones Advice.

Dec 14, 2006

I am doing a system for my project.I have three tables and they are
1. Hote Table which contains the hotelID as the primary key and other attributes of a hotel in the table
2.Room Table which contains the roomType of the hotels.The table conist the rmId as the primary key and the hId asthe foreign key from the hotel table.The table consist of an attribute standard price of the hotel roomType standard price.
3.The third table is the room type priceList table where all the prices of the roomsType is inserted inside.
  For e.g
  HotelID| RMTypeID | Price | dateStart | dateEnd    
    1         1        200    28 jan 07   30 jan 07            1         1        300    28 dec 06   30th dec 07     1         2        400    28 jan 07   30 jan 07
How do i get the the current price List of the hotel.I tried various sql statement and i am unable to fix ? If there are not latest price of the room Type i have to display the standard price.Do you have any idea how can i do this ?How can i display them in a dataList/datagrid/repeater as i have to show all the room types in the hotel.
If my database has some ammendments in my database,please do suggest.Thank you for your help.  
 
 

View 4 Replies View Related

Complete NOOB Hope Someone Can Point Me In The Right Direction

Apr 20, 2007

I have been programming access databases for 8 years.Well today I find out that I need to know SQL.HUH LOLwell I don't have a clue as to how people even enter data intoa sql database or how to manipulate or retrieve data.Can someone please recommend a book to get me started?thank you very much for any and all help with this.

View 2 Replies View Related

A Couple Of, I Hope Basic Questions RE SqlDataSource's And Scripting

Jan 9, 2007

Greetings!
 I am writing a proof of concept ASP.net application for my employer and I have run into a couple perplexing issues.  First off, In my Page_Load event I have the following code.
txOTHrs.Attributes["onBlur"] = "return calculateTotal(this)";
The onblur event handler is coded as follows
function calculateTotal(tb)
{
    var regHrs = document.getElementById ("txRegHrs").value;
    var otHrs = document.getElementById("txOtHrs").value;
    var rate = document.getElementById("txRate").value;
    var regAmt = rate * regHrs;
    var otAmt= rate * ( otHrs * 1.5 );
    var total = otAmt + regAmt;
    document.getElementById("txTotal").value = total;
}
Everything seems to work fine. The onBlur event is handled and, as I expect the value in the txTotal text box is updated correctly.  The problem occurs when I try to access that value in the codebehind page. When ever I look at txTotal.Text in the debugger it is always blank. This has left me scratching my head as I can clearly see a value on the web page. Have I missed some step where I have to notify the server that a value in the control has changed ?
 
My second question is, I hope a very easy one to answer.  In WinForms when I have a dataset I can access the individual rows ( in an untyped dataset ) by speficying dataset.tables["tableName"].Rows[index]. Is there any similar mechanism for accessing the individual rows, and fields in the SqlDataSource object in ASP.net ?
 
Any help anyone can provide is greatly appreciated!!

View 2 Replies View Related

Simple Simple Linking Tables & Perform Calculation

Mar 22, 2007

found it

View 3 Replies View Related

Simple Join Not So Simple

Feb 21, 2007

I am receiving funny results from a query. To simplify, I have 2 tables (todayyesterday). Each tbl has the same 8 columns. My query joins the two tables then looks where either of two columns has changed. What is happening is that when checking one of the columns it seems as though sql is flipping the column, causing it to be returned in error.

result set

colA colB colC colD colE colF colG colG (from yesterday)
1 1 a b c d e m
1 1 a b c d m e

So what's happening is that the record above is actually the same record and should not be returned. There is a daily pmt column that changes but I am not using that in the query. Aside from that the two records are identicle.

Any help is appreciated.

View 7 Replies View Related

Simple Join Not So Simple

Aug 19, 2006

Hi,

I have the following situation (with a site that already works and i cannot modify the database architecture and following CrossRef tables -- you will see what i mean by CrossRef tables below)

I have:


Master table Hotel

table AddressCrossRef (with: RefID = Hotel.ID, RefType = 'Hotel', AddrID)
joins
table Address (key = AddrID)


table MediaCrossRef (with RefID = Hotel.ID, RefType= 'Hotel', MediaID)
joins
table Media (with MediaID,mediaType = 'thumbnail')


foreach hotel, there definitely is a crossRef entry in AddressCrossRef and Address tables respectively (since every hotel has an address)

however not all hotels have thumbnail image

hence i have hotel inner join AddressXReff inner join Address ..... however i must have
left outer join mediaXref left outer join media


the problem is that if there is no entry in Media or mediaXref, I don't get any results

i tried to get over it by using
where (media.mediaTyple like 'thumbnail' or media.mediaType is null)
but then i started getting multiple results for each hotel because media's of type movie or full_image or etc... all got returned


any clue?

thanks

View 5 Replies View Related

Sp Help Needed

Sep 24, 2006

Im new to stored procedure, but here's what I want, if someone can get me started and provide this as an example it would be VERY welcome!I have the following, a SP with parameter IsMale. This parameter may be empty. If it's not empty I want to add some text to my selection query: AND IsMale=paramvalueHere's the SP so far:ALTER PROCEDURE [dbo].[spFindUsersAdvanced] --declare parameters here@IsMale bitASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON;   SELECT DISTINCT BirthDate,IsMale, FROM aspnet_Users INNER JOIN tblUserData ON aspnet_Users.UserId = tblUserData.UserID WHERE tblUserData.Username<>''IF @IsMale THENBEGIN  AND IsMale='True'ENDELSEBEGIN  AND IsMale='False'ENDEND IFEND1. How do I check if the parameter is empty?2. How do I add the text to my selection query?

View 3 Replies View Related

Help Needed

Oct 30, 2007

Hi all,I am trying to write a stored procedure, which has two insert statements.the first insert statement, is simple which inserts data into a table and returns the primary key for the new row added. using this primary key, i am writing another insert statement, which passes a list of elements which would be then entered into another table, with the primary key of the first table.Is this possible to do in a single stored procedure? I have implemented this using two different sp, but am wondering if it can be done other way?thanks for your help! 

View 10 Replies View Related

Help Needed

Dec 1, 2004

Hi,

For many to many relationship, what is the minimum number of tables required.

View 1 Replies View Related

Hep Needed!!!

Oct 17, 2005

Hi plz read below is my scenarioI have two diff tables which stores passwords (don't ask why b'coz it was there).Now to make data in both table consistance what I need to do?plz provide optimized solution.Thanks in advance.bye bye.happy coding!!!

View 1 Replies View Related

Help Needed.

Dec 20, 2000

Experts,

I've few questions regarding SQL Server. Appreciated, If any one out there help me with it.

I would like to do T-SQL Programing and would like to know some good book. I'll mostly be doing Stored procedures,Triggers and views programming. Any advice?

On my sql server I've 10 logins. But, I cannot view these logins from the Enterprise GUI. But, When i run a query against the syslogin table, those all 10 logins shows up. Why is that?

any help would be greatly appreciated.

View 1 Replies View Related

SQL Help Needed.......

Mar 25, 2004

Access 97.................

I'm trying to construct the following SQL statement but am missing something somewhere.

I get a syntax error with the 1st FROM highlighted.

If i construct a query out of the bit that works and then construct a query on that query then i can get it to work no problem but how to mimic that in SQL ? I can't simply view the SQL of the queries because the query names replace the SQL statements.

I'm trying to SUM the 5 volumes that get returned by the TOP 5 SQL statement. The VotingUniverse_TotalVolumeByType query returns the TotalVolume which will enable me to divide the SUMmed 5 volumes by the TotalVolume to obtain a %age.



SELECT
Type,
Sum(Volume) AS Volume,
TotalVolume
FROM
>>>>>>>>>>this following bit works............
(SELECT TOP 5
VotingUniverse_TopFirmsVolumeByType.Type,
VotingUniverse_TopFirmsVolumeByType.Volume
FROM
VotingUniverse_TopFirmsVolumeByType
WHERE
(((VotingUniverse_TopFirmsVolumeByType.Volume)
In (SELECT TOP 5 VotingUniverse_TopFirmsVolumeByType.Volume
FROM
VotingUniverse_TopFirmsVolumeByType
ORDER BY Volume DESC)))
ORDER BY
VotingUniverse_TopFirmsVolumeByType.Volume;)
>>>>>>>>>>>end of bit that works
INNER JOIN
VotingUniverse_TotalVolumeByType
ON
Type = VotingUniverse_TotalVolumeByType.Type
GROUP BY
Type,
TotalVolume;



hope this makes sense to someone anyway

thanks


====
Paul

View 5 Replies View Related

Immediate Help Needed!! Thanks A Lot!

Aug 15, 2002

I have a xxx.exe running on SQL 2000 server as a sql job every hour. For some reason this job sometime just hung in the middle and never finish. But
if I stop it and rerun it, it will be down within 10 seconds. I am wondering
if we can set up something so that the job aborts automatically if it ran more than 10 minutes.

View 1 Replies View Related

Help Needed!!!

Feb 22, 2001

Hi everyone.

We are running Sql 6.5 sp5 on a Pentium II 350 Mhz with 512 Mb. RAM, 1 ScSi 4 Gb hd, one 8Gb ScSi hd and 2 IDE hd (13,6 Gb and 8Gb) computer running windows NT 4.0 sp 6 without any problems.
Now have bought a new computer. The new one is a Pentium III 733 Mhz 512 Mb Ram with 2 ScSi ultra wide 2 18Gb each and one 40 Gb Ide Hd. We have installed windows NT 4.0 sp 6 and Sql 6.5 sp 5. We have restored our database to make some tests to it. The database is 7 Gb big.
The results of our test are that the old computer is between 20% and 30% faster than the new one when doing sql instructions and using the database even knowing that the hd´s of the new computers are 4 times faster than the old ones.

Would you please give us any help or clue that would make the new computer go faster?
We know that upgrading to sql 7 will work but we need first to make this computer work better with the 6.5.
Thank you.

View 3 Replies View Related

Help Needed

Jun 18, 2004

Hello,
When I try to run my asp file it gives me this error. :mad:

Technical Information (for support personnel)

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E07)
Syntax error converting datetime from character string.
/conOpen_inc.asp, line 10


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

Page:
GET /Default.asp


Anyone can tell me whats happening ? thank you

View 5 Replies View Related

DTS Help Needed!

Oct 12, 2004

I often use DTS to move databases between the servers. When you choose "Transform" data and “Column Mappings and Transformation” window opens, the default option is “Append rows to destination table”.
Question: Is there a way to change the default option to “Delete rows in destination table”, so I wouldn’t have to go thru the transformation of dozens of tables every time I move databases around.

P.S. I know that I can save DTS package with my settings and use it later. The problem is that every time it might be different database or objects might change. So, it is not a solution for me.

Thanks

View 8 Replies View Related

SQL DB Help Needed!!!

Jul 25, 2007

Dear All,

I have a client requirement. We are integrating two applications. So the problem is that, whenever some updates (meaning to say "create" , "delete" , "update") happens in the SQL DB Tables, i needed to track that data and send it to a different system.

What I have thought abt is that if SQL could generate a file with all the values deleted/updated/created in the DB, then I could take those values and do the needful. Please help me..

Thanks,
Sanjo

View 2 Replies View Related

Help Needed!!

Feb 28, 2004

Hello guys,
I'm new to the forum and to MS SQL 2K.
I'm trying to a merge similar rows in a table into a single row and put them in a new table.

Example:-
This is my input table
TableA
ID A B C
------------------------
1 jk kl bj
2 sd we op
3 io po kl
1 ui gh ew
2 kl re op
1 qw kj nn

My output table should look like this
TableB
ID A1 B1 C1 A2 B2 C2 A3 B3 C3
-----------------------------------------------------
1 jk kl bj ui gh ew qw kj nn
2 sd we op kl re op
3 io po kl

Please help me on how to create my output.
Thanks in advance,

Sid.

View 11 Replies View Related

Help NEeded!!

Mar 26, 2004

Hi,
I have a table structure like this

TableName: Common

Columns
PartnerId: int
NativeId: int
FirstName: nvarchar(50)
LastName:nvarchar(50)

1)I should get the records with a minimum native id for a particular PartnerId,
2) if duplicates exists in the above condition i should select top 1 (first record)


How can i do it??

TIA,
sudheer

View 5 Replies View Related

Help Needed!!

Apr 12, 2004

Hi,
I have been SQL developer for past 2 yrs, want to get into Administration(DBA) can any one suggest me some good articles on net and good books for this.

TIA,

sudheer.

View 14 Replies View Related

Is It Needed?

Feb 26, 2008

Hi experts,

I am upgrading my database from SQL Server 2000, SP4 to SQL server 2005, SP2.

1) Is it required to recreated my user defined functions? I mean drop them and recreate them again?

2) Do I need to recreate the views and Stored procedure?


3) Do we have a checklist from Micorosoft for upgradation?


Thanks in advance

Regards
Sachin

Don't sit back because of failure. It will come back to check if you still available. -- Binu

View 2 Replies View Related

Help Needed!!

Jul 23, 2005

Hey all, I need some help to build some data bases and maybe some morestuff. Please reply only if you can do it volunteerly or very cheap please;but there is incentives in time..TIA

View 4 Replies View Related







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