Viewing 15 posts - 31 through 45 (of 46 total)
BTW, I was using 5409045121009 table structure. Also I didnt put in the leading zeros but that would be easy enough if you need it.
May 21, 2003 at 9:44 am
One more solution using derived table
update t1
set somethingiwant = t2.somethingiwant
from test as t1
join(SELECTid,
code+CAST((select count(*)
from test b
where a.code = b.code
and a.id >=b.id)
as varchar(10)) as somethingiwant
from test a
)as t2
on t1.id = t2.id
...
May 21, 2003 at 9:42 am
I noticed you mentioned sysfiles in your earlier post. Usually stored procedures created in master and prefixed with sp_ will run in the context of the database they are called...
May 20, 2003 at 8:29 am
Yes, if the dynamic sql is set based then you will need to put it into a temp table to be able to work with the data. If all you...
May 19, 2003 at 4:16 pm
Ahhh, I didn't look at your code that closely. Now I see what you were talking about.
May 19, 2003 at 4:09 pm
Antares answered the coalesce question.
Antares,
In the original query, rows with a NULL ErrorID would not have been returned if his @ErrNumStart was not null.
It would have evaluated...
May 19, 2003 at 3:51 pm
Have you tried using a coalesce with a number that isn't valid for the variable like a negative number. e.g
AND(ErrorID >= COALESCE(@errNumStart,-1))
May 19, 2003 at 3:25 pm
That will work just fine, but the variables scope is in the exec statment and it will go away as soon as it completes. You will not be able to...
May 19, 2003 at 1:46 pm
That still does not change the database context except for during the exec statement.
May 19, 2003 at 1:40 pm
The use is only for the duration of the execution.
You can see that by running this
declare @db nvarchar(50)
declare @db2 nvarchar(50)
set @db = 'use tempdb select db_name()'
set @db2 = 'select...
May 19, 2003 at 12:39 pm
You can't. I'm pretty sure since I said that someone on here will figure out a way.
May 19, 2003 at 12:35 pm
You really dont have to loop although you do have to build dynamic sql.
Here is an example.
CREATE TABLE Tests (name varchar(50))
GO
INSERT INTO Tests
SELECT 'Test1'
GO
INSERT INTO Tests
SELECT 'Test2'
GO
INSERT INTO Tests
SELECT...
May 14, 2003 at 9:35 pm
This works... Notice how I doubled up on the single quotes. I think that may be your problem.
CREATE TABLE test (col1 char(1), col2 char(1))
go
CREATE PROC test_it @sqlVals varchar(10)
as
...
May 9, 2003 at 9:01 pm
Here is a view I created similar to Antares without the huge IN clause...
It does require a numbers (sequence) table though.
CREATE VIEW dbo.PK_Columns_View
AS
selecto.nameASname,
o.idASid,
c.nameAScolumn_name,
n.idASsequence_number
FROMsysobjectsASo
JOINsysindexesASi
ONo.id =...
May 8, 2003 at 12:19 pm
Viewing 15 posts - 31 through 45 (of 46 total)