Viewing 15 posts - 13,651 through 13,665 (of 15,381 total)
Like this:
create table InsertTest
(
ID int identity not null,
SomeValue varchar(10)
)
go
create procedure IdentityTest
as begin
set identity_insert InsertTest on
insert InsertTest (ID, SomeValue) Values (10, 'MyValue')
set identity_insert InsertTest on
end
go
exec IdentityTest
select * from InsertTest
For...
October 20, 2011 at 9:04 am
You can use that in your stored proc withOUT the need for a GO or dynamic sql. Just make sure to set it off again before you exit. 😉
--edit correction...
October 20, 2011 at 8:58 am
It all has to do with the inner workings of the sql compiler. When you try to execute your example it can't compile because the table doesn't exist. It is...
October 20, 2011 at 8:53 am
Something like this help you get started?
insert xref
select c.contact_id, [All other data columns here]
from contact c
left join xref x on c.contact_id = x.contact_id
where x.contact_id is null
If you want actual code...
October 20, 2011 at 8:47 am
October 20, 2011 at 8:06 am
OK put yourself in my shoes. Do you think you have provided enough information for me to be able to help? I have asked for ddl, sample data (insert statements)...
October 20, 2011 at 7:08 am
I assumed you were on 2008 since you posted in the 2008 forum. 😉 Search the forums on here. There have been a number of string split functions posted. Some...
October 20, 2011 at 6:57 am
Sure.
declare @Codes varchar(25) = '14, 8, 21458'
;with cte(n) as (select 1
union all select 14
union all select 214
union all select 314
union all select 15
union all select 8)
select *
from cte
where @Codes...
October 19, 2011 at 3:49 pm
Actually I just noticed that is fairly safe from sql injection but it does not get you the values you want.
Declare @Type_Code varchar(50)
set @Type_Code = '4,11,12'
Select * from table_Type_Codes...
October 19, 2011 at 2:56 pm
Todd's example will also work. If you take that approach make sure you read up on sql injection because that would be vulnerable.
October 19, 2011 at 2:49 pm
a trace is pretty much the only way you can capture all queries. You can pare down the result in profiler fairly easily. You can dial it in for a...
October 19, 2011 at 2:32 pm
Can you provide an example of the query your are running? If possible and execution plan would help too.
October 19, 2011 at 2:28 pm
You need a splitter.
Here is how the code for you case might look.
Select * from table_Type_Codes t
join DelimitedSplit8K([column_name], ',') s on s.Item = t.[column_name]
For an explanation of the logic take...
October 19, 2011 at 2:04 pm
If I understand correctly, something like this should work:
update employee_file
set first_name = isnull(d.first_name, f.first_name),
last_name = ISNULL(d.last_name, f.last_name),
[rest of your columns...]
from employee_file f
join employee_demographics d
October 19, 2011 at 9:53 am
Amy.G (10/19/2011)
October 19, 2011 at 9:21 am
Viewing 15 posts - 13,651 through 13,665 (of 15,381 total)