Viewing 14 posts - 1 through 14 (of 14 total)
oops.. second part of previos script
OPEN i
FETCH NEXT FROM i INTO @table_name, @constraint_name
WHILE @@fetch_status=0
BEGIN
--EXEC('ALTER TABLE '+@table_name+' DROP CONSTRAINT '+@constraint_name)
PRINT 'ALTER TABLE '+@table_name+' DROP CONSTRAINT '+@constraint_name
FETCH NEXT FROM i INTO @table_name,@constraint_name
END
CLOSE...
May 31, 2011 at 2:39 am
--Drop all FKs in the database for the selecting tables
DECLARE
@table_name sysname,
@constraint_name sysname
DECLARE i CURSOR STATIC
FOR
SELECT
c.table_name,...
May 31, 2011 at 2:38 am
one scan table [Result] only
select total_res, [subject]
from
(
select total_res = SUM(CAST(res AS Int)), [subject]
from
(
select *
...
May 30, 2011 at 8:13 am
set @sql1 = 'SELECT COUNT(*) FROM "HRDATAMART_DAILY"."dbo"."EMPLOYEE" WHERE EMP_MOST_RECT_HIRE_DT IS NULL AND SOURCE_NM = '''+@constant1+''''
🙂
May 30, 2011 at 7:38 am
another way
put into job (named 'test' ) step procedure execution only
DECLARE
@job_id uniqueidentifier
SELECT
@job_id = sv.job_id
FROM
msdb.dbo.sysjobs_view AS sv
where name ='test'
ORDER BY
[Name] ASC
declare @tmp_sp_help_jobhistory table
(
...
February 22, 2011 at 7:03 am
put procedure execution into job's step
/*
CREATE PROCEDURE test
AS SELECT 1/0
GO
*/
BEGIN TRY
EXEC test
END TRY
BEGIN CATCH
--INSERT [Your Table]
SELECT
ERROR_NUMBER() ...
February 22, 2011 at 6:47 am
BEGIN TRY
RaisError...
END TRY
BEGIN CATCH
INSERT [Your Table]
SELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
...
February 22, 2011 at 4:59 am
FOR XML RAW (''), ELEMENTS , ROOT ('Item')
?
February 22, 2011 at 4:55 am
declare @table table (rowid int,value1 varchar(2),value2 varchar(2))
declare @table1 table (value varchar(220))
declare @first_Letter varchar(2)= 'A'
declare @last_Letter varchar(2)= 'F'
insert into @table
Select 1,'A','B'
union Select 2,'C','D'
union Select 3,'E','F'
union Select 4,'G','H'
;with t2 as(
select
...
October 11, 2010 at 5:40 am
Check variables type
declare @d int /*datetime*/ --<<-- datetime wrong variable type
declare @m int /*datetime*/
declare @y int /*datetime*/
declare @result varchar(50)
set @d= datediff(dd,'01/01/2010','01/03/2010')
set @m=datediff(mm,'01/01/2010','01/03/2010')
set @y=datediff(yy,'01/01/2010','01/03/2010')
set @result=right('00'+convert(varchar,@d,102),2) + ''...
August 10, 2010 at 2:35 am
mega solution 🙂
SELECT [Tarief], [Tarief2]= cast(0.01*[Tarief] as varchar) FROM @TABLE
August 10, 2010 at 2:25 am
use tempdb
go
if OBJECT_ID('[dbo].[Menu]', 'U') is null begin
create table [dbo].[Menu]
(
menu_id int primary key,
menu_name varchar(100)
)
...
August 6, 2010 at 2:17 am
;WITH s as (SELECT id=row_number()over(order by (select 0))
FROM(SELECT 1a,1b,1c,1d,1z,1f,1g,1h,1i,1j,1k)E
...
June 29, 2010 at 8:54 am
canuzun (6/28/2010)
Thanks for the tip.Only curious, is it possible to create the second table, from the first one with single query?
Possible
SELECT
CUSTOMER_ID ...
June 29, 2010 at 7:58 am
Viewing 14 posts - 1 through 14 (of 14 total)