Sql Query Per Column Number
Sep 8, 2006is there a way to sql query via a spesific column number
'get from table A row 1 column 1' and then 'get from table A row 2 column 3'
and so on
thanx
is there a way to sql query via a spesific column number
'get from table A row 1 column 1' and then 'get from table A row 2 column 3'
and so on
thanx
I’m okay with simple queries but as I’m no expert and have failed to find perhaps the correct wording to describe this method, if at all possible to do, so I have come to ask here.
What I would like to do is take a column from a query and then break down that column into separate results.
So the full query results:
36,18/09/2007 10:00:00,NULL,000102000304,NULL
The column I would like to brake down is (Unique Reference Number):
000102000304
And I would like to break it down to get the last 2 parts (0003 and 04):
0001 | 02 | 0003 | 04
Is this possible to do?
If so where should I be looking or what should I be looking at?
Many Thanks
I need a column in my query results that just numbers the rows sequentially (i.e. 1, 2, 3). How can I do that?
View 6 Replies View RelatedUsing c# in the compact framework, is there a way to do a parameterized query for counting the number of records where a specified column is null. I tried all of these, but none of them work:
cmd.Add(new SqlCeParameter("@IntColumn", SqlInt32.Null));
cmd.CommandText = "select count(*) from TableName where IntColumn is not @IntColumn";
cmd.Add(new SqlCeParameter("@IntColumn", DBNull.Value));
cmd.CommandText = "select count(*) from TableName where IntColumn is not @IntColumn";
cmd.Add(new SqlCeParameter("@IntColumn", SqlInt32.Null));
cmd.CommandText = "select count(*) from TableName where not IntColumn = @IntColumn";
cmd.Add(new SqlCeParameter("@IntColumn", DBNull.Value));
cmd.CommandText = "select count(*) from TableName where not IntColumn = @IntColumn";
cmd.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Int32));
cmd.Parameters["@IntColumn"].Value = SqlInt32.Null;
cmdGetNumRead.CommandText = "select count(*) from TableName where IntColumn is not @IntColumn";
cmd.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Int32));
cmd.Parameters["@IntColumn"].Value = SqlInt32.Null;
cmdGetNumRead.CommandText = "select count(*) from TableName where not IntColumn = @IntColumn";
cmd.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Int32));
cmd.Parameters["@IntColumn"].Value = DBNull.Value;
cmdGetNumRead.CommandText = "select count(*) from TableName where IntColumn is not @IntColumn";
cmd.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Int32));
cmd.Parameters["@IntColumn"].Value = DBNull.Value;
cmdGetNumRead.CommandText = "select count(*) from TableName where not IntColumn = @IntColumn";
cmd.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Variant));
cmd.Parameters["@IntColumn"].Value = SqlInt32.Null;
cmd.CommandText = "select count(*) from Meter where IntColumn is not @IntColumn";
cmd.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Variant));
cmd.Parameters["@IntColumn"].Value = SqlInt32.Null;
cmd.CommandText = "select count(*) from Meter where not IntColumn = @IntColumn";
md.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Variant));
cmd.Parameters["@IntColumn"].Value = DBNull.Value;
cmd.CommandText = "select count(*) from Meter where IntColumn is not @IntColumn";
cmd.Parameters.Add(new SqlCeParameter("@IntColumn", SqlDbType.Variant));
cmd.Parameters["@IntColumn"].Value = DBNull.Value;
cmd.CommandText = "select count(*) from Meter where not IntColumn = @IntColumn";
Whenever I use a "is not" in the query I get an exception, otherwise it returns a count of 0 which is not accurate. Any help will be appreciated.
I have a table in which a non-primary key column has a unique index on it.
If I am inserting a record into this table with a duplicate column value for the indexed column, then what will be the error number of the error in above scenario? OR How could I find this out?
Hello All,Is there a way to run sql select statements with column numbers inplace of column names in SQLServer.Current SQL ==> select AddressId,Name,City from AddressIs this possible ==> select 1,2,5 from AddressThanks in Advance,-Sandeep
View 1 Replies View RelatedI have a table that has a street number field.
if the user types in a street number of '2' i would like to return all street numbers the begin with 2 (2,20,21, 200, 201,205,2009,...)
how can this be done.
I want to add $ symbol to column values and convert the column values to western number system
Column values
Dollar
4255
25454
467834
Expected Output:
$ 4,255
$ 25,454
$ 467,834
My Query:
select ID, MAX(Date) Date, SUM(Cost) Dollars, MAX(Funded) Funding from Application
COST is the int datatype and needs to be changed.
Hi. Is it possible to select the columns you want given the column number instead of column name like the 3rd and 5th column?
Thanks!
Hello,How should I create a column to save data with the folowing format 10.10 or 10.20 or 10.30 or 150.30 or 10 or 150.It is basically process step in a diagram flow.I tried with decimal but with 10.10 , it removes automatically the 0.Thanks
View 2 Replies View Relatedhi
I am using sql Server as database what value should I send for the autonumber field
Thanks
I swear I have done this before and can't remember how.
I want to select columns in a SELECT statement by their number instead of name.
I have looked everywhere for the syntax.
Also, is there a function to 'count' the number of columns in a table?
Thanks.
I want to select with column order without field name .
Is it possible ?
SQL2000 db
...
I want to select a field by its order in table, but without naming it to have a constant name of it, like :
select (column01) as L1 from myTable
Hi,
I have several INT columns in a table that I need to update.
For example, in column 'aa' I need to add 2 to all of the values in that column.
I'm using Query Analyzer - what update statement should I write?
I have a ACTION column. i.e Its only disply SELL/BUY.
ACTION
BUY
BUY
BUY
SELL
SELL
SELL
SELL
BUY
BUY
SELL
SELL
SELL
BUY
How to create another column display like this
ACTION
BUY 1
BUY 2
BUY 3
SELL 1
SELL 2
SELL 3
SELL 4
BUY 1
BUY 2
SELL 1
SELL 2
SELL 3
BUY 1
Help me anyone...
I have a ACTION column. i.e Its only disply SELL/BUY.
ACTION
BUY
BUY
BUY
SELL
SELL
SELL
SELL
BUY
BUY
SELL
SELL
SELL
BUY
How to create another column display like this
ACTION
BUY 1
BUY 2
BUY 3
SELL 1
SELL 2
SELL 3
SELL 4
BUY 1
BUY 2
SELL 1
SELL 2
SELL 3
BUY 1
Help me anyone...
I have table
id, series, seriesnr
and data
65557,AS,0
74443,AS,0
how to update table so seriesnr would be incremental , like
65557,AS,1
74443,AS,2
if i use
update x set seriesnr=select max(seriesnr) from x
then i got same seriesnr for all rows like max was calculated only one time on the begining not on each row update(why is that itseem so illogical)
65557,AS,1
74443,AS,1
A want to user a procedure to decrease a number in a col. by 1 each day.
I need some type of operation
then a job has to run the procedure to decrease a number once a day.
I don't know how to go about the operation? I am going to the SQL Query Anylizer to help me run the script to test it. I have in a col. of 201 numbers, and I will subtract 1 from each day from all recorders. I guess you could call this a count down or timer. Does this code work for me?
Thank You,
Insert into newusers (Timer-1)
Select Timer
From newuses
GO
HI,
Can I come to know Column number of particular cell.The way we get rownumber().
-Thanks,
Digs
Hello, I have a field of type the Var, the stored data makes about 700 characters.
During a select through the query analyser, it tronque in about 200 or 300 characters.
How to explain it?
thank in advance
Pascal
When I try to import a Pervasive table into SQL Server 2K, I get the error msg of 'Invalid column number'.
Is that because SQL Server cant handle more than 1024 columns ?
I think my Pervasive table has more than 2000 columns
Thanks in advance
Hi,
I have the following two tables:
Code:
create table RECORD
(
ID int not null,
Issue_descr varchar(256) not null,
Priority varchar(5) not null,
Status varchar(12) not null,
Date_add varchar(10) not null,
Date_due varchar(10) not null,
Date_complete varchar(10),
PName varchar(32),
primary key(ID),
foreign key(PName) references PROJECT(PName)
);
and
Code:
create table STEPS
(
ID int not null,
Num int not null,
Descr varchar(256),
Date_due varchar(10) not null,
Date_complete varchar(10),
Status varchar(12),
primary key(ID, Num),
foreign key(ID) references RECORD(ID)
);
I have set PK "ID" in table RECORD to auto identity(1,1). I have done the same for PK "num" in table STEPS.
However I am seeking this behavior in STEPS:
ID num
-- ----
19 1
19 2
19 3
20 1
20 2
21 1
but what I'm getting is PK num doesn't "reseed" or reset to 1 as "ID" changes. PK num just auto-increments regardless of ID. Is there a workaround?
Thanks.
I am having following data:
c1c2c3
122401
1221072
122833
122793
122813
122314
[code]....
I want to count number of occurrence in column c3. i.e., count 1 occurred value 9 times, count 2 occurred value 3 times, count 3 occurred value 3 times.
Output
c1p1p2p3
122933
I have a table like this (a small section of the table)
Cu_id |Tr_id |Date
1234 |1 |12/3/2006
1234 |2 |12/18/2006
1234 |3 |1/5/2007
1234 |4 |1/9/2007
1234 |5 |2/21/2007
9999 |91 | 1/3/2006
9999 |81 |1/10/2006
9999 |71 |1/18/2007
9999 |61 |2/1/2007
I have to find the number of days between the dates for the same cu_id and add the number as a new column. The new table should look like this.
Cu_id |Tr_id |Date| Days_between
1234 |1 |12/3/2006 |0
1234 |2 |12/18/2006 |15
1234 |3 |1/5/2007 |18
1234 |4 |1/9/2007 |4
1234 |5 |2/21/2007 | 43
9999 |91 |1/3/2006 |0
9999 |81 |1/10/2006 |7
9999 |71 |1/18/2007 |8
9999 |61 |2/1/2007 |14
Please let me know how I can find the number of days between two dates in the same column for the same cu_id (customer_id).
Thanks
I am migrating a web application I wrote from ASP to ASP.Net, and fromAccess to MS SQL server.In the Access version, I did not use the auto number for creatinginvoices and other documents, because I heard somewhere (perhapsincorrectly) that if the db was ever compacted or otherwise changed,it could change the values of the auto-numbers. Not a good thing.So I wrote a routine that, just before creating a new record, wouldlook for the highest value in the table and create the new record withthe next number.So my question is, am I safe in assuming that in MS SQL that I can seta starting number for the next, let's say, invoice and that newnumbers will be issued in sequence, and that these numbers will neverchange? What happens if an invoice is deleted? is the number goneforever? Just wondering how others deal with these issues...thanks.Larry- - - - - - - - - - - - - - - - - -"Forget it, Jake. It's Chinatown."
View 2 Replies View Related
Hi all,
I have a table with artikels and count, sample:
Art Count
------------
12A 3
54G 2
54A 4
I would like to query this table and for each 'count' retrieve one row:
query result:
Art Count
------------
12A 3
12A 3
12A 3
54G 2
54G 2
54A 4
54A 4
54A 4
54A 4
Is this possible?
Thanks, Perry
I have a Users Table. It is full of users already and I would like to start using the UserPIN in the software (this is an nvarchar column).
I would like to update the UserPIN column with the row_number. All of my efforts have resulted in setting the UserPIN to 1 for every record. Â I just want an update query that fill the UserPIN column in sequential order.
Is there any way to retrieve partial contents of a database column? For example, say a column holds 5,000 characters, but I only wish to retrieve the first 50.
Thanks
Hi ,,
How to write the Sql Query to return the next generated Identity from the Sql server database.
I try to set up a testing sample table which contain one integer project_ID field for table Sample around 500 records, and want the project_ID to be random number within 1 to 99, how to implement script todo it?
thanks!
I have a column of phone numbers that have formatting such as (xxx)xxx-xxxx,
or xxx.xxx.xxxx or xxx.xxx-xxxx; however, not all phone numbers are formatted in this fashion. I need to remove all characters and only leave behind numeric digits to look like xxxxxxxxxx. I have tried select replace(colname,'-','') from table. This does the trick but does not actually change the values in the column. Any help in accomplishing this would be helpful. Thanks in advance.
Paul
Add sno 1 to end of the coloum
I have table like ...
400000 laks rows in my table
name address id location
raju hyd 6789 hyd
vamshi vizag 9876 hashinapur
o/p like
I want insert sno coloum and sno 1 to 400000
sno name address id location
1 raju hyd 6789 hyd
2 vamshi vizag 9876 hasthinapur
3
4
5
6
..
.
.
.
.
40000
What i want to do is count how many times the [Omnipay_Account] column is populated with a number per parentid.
In the [Omnipay_Account] column you can either have a null or a 15 digit number
Idea result layout would be three columns these columns would be
Every row, would need to be grouped via the parentid number
ParentId Omnipay MSIP
My query is
SELECT
[ParentID]
,[Omnipay_Account]
FROM [FDMS].[dbo].[Dim_Outlet]