Viewing 15 posts - 2,551 through 2,565 (of 3,543 total)
SELECT *
INTO tableone
FROM tablezero
NOTE
1. Select into/Bulk copy option must be set for database
2. Primary Keys and Indexes will not be created for new table
Alternatively
CREATE TABLE tableone (col1,...
September 1, 2004 at 6:46 am
Not that I know of but you could write one like this
CREATE FUNCTION fn_hextovarchar
(@input varchar(8000), @startoffset int = 1)
RETURNS varchar(4000)
AS
BEGIN
DECLARE @hex char(16),@output varchar(4000),@ptr int,@val int
SET @hex...
August 6, 2004 at 7:09 am
Divide by zero always returns null, the combination of ANSI_WARNINGS, ARITHABORT and ARITHIGNORE determines whether an error is produced or at what level the abort takes place (see BOL)
So
SET ANSI_WARNINGS OFF
SET...
August 6, 2004 at 6:36 am
Use a FormatFile to specify the order and type of input data and in which columns to place the data. Note that any column not specified must be nullable.
BOL has...
August 4, 2004 at 7:15 am
In ExecuteSQL task, RAISERROR will cause the 'On Failure' workflow to trigger. eg
IF NOT EXISTS (SELECT 1 FROM [sometable] WHERE [sometest])
RAISERROR 'Record Does Not Exist',16,1
August 3, 2004 at 7:13 am
If the data is sorted on a column with unique values then you can do the following (uses pubs for example)
select (select count(*)
from pubs.dbo.stores s2
where s2.stor_id...
August 3, 2004 at 7:05 am
Increase the size of @Courses. It must be large enough to hold all the database names (including a comma) plus the final comma.
This is how I do .NET
Public...
August 2, 2004 at 9:29 am
Try this
alter procedure sp_GetUserValidation
(
@UserName varchar(50),
@Courses varchar(50),
@Return varchar(150) OUTPUT
)
AS
SET NOCOUNT ON
DECLARE @CourseName varchar(100), @UserValArray varchar(200), @Pos int
DECLARE @sql nvarchar(500)
DECLARE @Result char(1)
SET @Return = ''
SET @Courses = LTRIM(RTRIM(@Courses))
IF @Courses = '' RETURN
SET...
August 2, 2004 at 7:03 am
Yes I would be interested as well. The OR method is the way I do it, the ISNULL I got from other threads on this site and seemed a simpler neater...
August 2, 2004 at 2:49 am
If you have SQL2000, create a function
CREATE Function dbo.fn_table1 (@col1 int)
RETURNS varchar(1000)
AS
BEGIN
DECLARE @result varchar(1000)
SELECT @result = COALESCE(@result + ', ','') + CAST(NewCol1 as varchar)
FROM...
July 30, 2004 at 7:21 am
where col1 = isnull(@p1,col1)
and col2 = isnull(@p2,col2)
and col3 = isnull(@p3,col3)
But beware this will invoke a table or index scan.
July 28, 2004 at 7:23 am
UPDATE p
SET p.EmployeeNo = i.EmployeeNo
FROM [primary] p
INNER JOIN [import] i
ON i.LastName = p.LastName
AND i.Initial = LEFT(p.FirstName,1)
WHERE p.EmployeeNo IS NULL
BUT BEWARE! This will...
July 23, 2004 at 6:36 am
Firstly I would remove the subqueries from the while statements and do them once at the beginning, ie
declare @maxdataid int, @maxruleid int
select @maxdataid = isnull(max([id]),0) from newdata
select @maxruleid = isnull(max([id]),0)...
July 21, 2004 at 6:13 am
Created on the fly no testing
Probable poor performance
Assumes complete sql (including rules/test) less than 4000 bytes
CREATE TABLE #tests (rowid int IDENTITY(1,1),test nvarchar(100))
INSERT INTO #tests (test) values ('where rule1')
INSERT...
July 20, 2004 at 8:56 am
SET DATEFIRST 7 --Set First Day of Week to Sunday
SELECT SUM(CASE WHEN DATEPART(weekday,[date]) = 1 THEN [column] ELSE 0 END) AS 'Sun',
SUM(CASE WHEN DATEPART(weekday,[date]) = 2 THEN [column] ELSE...
July 20, 2004 at 8:12 am
Viewing 15 posts - 2,551 through 2,565 (of 3,543 total)