I have tables say tbl1, tbl2, tbl3
I am joing this table to get back some recordsets
select a.col1
b.col2
c.col3
from tbl1 a inner join tbl2 b
on a.col1 = b.col2
inner join tbl3 c
on b.col1 = c.col2
the resultset will teturn
col1 col2 col3
1370 1446 aa...
I have two tables, @tmpTable4 and @ReportTable,
I wrote this script to update the last two fields of table @tmpTable4 i.e. ISDEL and REMARK with the last two fields of @ReportTable
but it is not updating what will be the reason
here is the script
SET ANSI_NULLS OFF
GO
DECLARE @ReportTable...
I wrote a query which can be run on different servers
I want to pass the server name and database name as a parameter to my query.
how can I do that
can I do
select * from @servername.@databasename.dbo.tbl
Thanks
I want to update a table tbl on serer svr1 and database db1
update tmp
set tmp.col = case when tmp.col1 = 1 then tmp.col1 + 1
else tmp.col1 + 2
end
from OPENROWSET('SQLOLEDB','svr1';'uid';'pwd','select * from db1.dbo.tbl') tmp
but it is erroring
the...
I have a table called tbl on server svr1, database db1, owner is dbo
I want to update it from server svr2, database db2
I wrote a query
update svr1.db1.dbo.tbl
set col1 = case when col1 = 1 then 1.0
else 2.0
end
where col2 = 'aa'
but it is complaining
what should...
I am trying to get the max employee change number
for some reason when an employee doesn't have change number i.e when it is null, my query doesn't pick that specific record. below is the query I wrote
what is the problem with my query
create table #tmp (ID int, EMP_ID int, EMP_VER_NUMBER...
Here ia another query problem, I know for most of you guys it is easy.
I have a table say
tbl
id Catagory values
1 Min 0
1 Max 8
2 MIN 18
2 Max NULL
3 MIN NULL
3 Max 60
NB if min or max value is not given for min we take 0 for max we take 1000
each id has min and...
Here is my problem
I have a table say
trialId country
1 USA
1 canada
1 Jamaica
2 USA
3 Afganistan
4 India
4 S. Africa
I want to get trials conducted in US but nowhere else
resultset should look like
trialId country
2...
I have a table say
tbl
col1 col2
1 aa
2 aabc
3 bb
4 bbkk
5 cc
6 dd
I want to select all records from tbl1 excluding records that have col2 values starting aa and bb
therefore my result set should look like
col1 col2
5 cc
6 dd
thanks
I have a table say
tbl1
col1 col2
1 aa
2 bb
3 cc
4 dd
I would like to select all records and the total number of records in single statemet here is what the recordset I want
noRecords col1 col2
4 1 aa
4 2 bb
4 3 cc
4...
Here is my question, please tell me whether we can do it or not.
can we cache a resultset of a query for later use, like we cache an execution plan of a query to be reused later.
The reason I am asking is
I want to catch a resukt of a query and reuse it later unless the result set is changed...
declare @name varchar(1000)
set @name = ''
1 select @name = @name + convert(varchar(1000),id)+ ', '
from tbl
2 select @name
How can I combile statement 1 and 2 so that I can do it in a single statement
select (select @name = @name + convert(varchar(1000),id)+ ', '
from tbl)
gives me an...
I was replacing a cursor with a while loop and I am facing one minor problem but its impact is so big.
see the code
//variables declared here
select @id = min(id) from table1
while @id is not null
begin
select @name = name
@date = date
from table1
where id = @id
//do some thing...
I am working on sql server 2000,
I am facing an exceeding max row size problem, Is there a way, I can mitigate this problem?
I am selecting certain columns, and when I am tring to sort them, it is complaing that it is not sorting because it exceeded the 8K limit.
what should I do
thanks,
I have two table say
tbl1
col1 col2
1 xx
2 yy
3 zz
4 dd
and tbl2
col1 col2
1 rr
3 kk
4 ll
now I want to select record from tbl1, if tbl2 doesn't have any record I will select all records from tbl1 otherwise
I will select those records...
Hello everyone
Hope you have a great easter weekend
I have one que
I have a table say tbl1
col1 col2
a xx
a yy
b zz
c ff
c gg
I want to add an indentity column to this existing table
so that it will be like this after I will have added the identity...
I always think replacing all the cursors defined in all my procedures.
I was able to do it for those that have column (primary key or unique key) to identify each row uniquely with the while loop
but I can't do it for those who don't have a uniue key.
how can I replace those cursors defined...
Hello everyone,
We are moving from source save to TEam foundation.
can anybody tell me what can a sql server developer do for this process (for the migration). That will help me to specifically study and prepare myself.
I am totally new to it.
Thanks,
Teddy
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.