Viewing 15 posts - 1,846 through 1,860 (of 2,171 total)
However, this is a SP I would use. I don't like cursors that much.
CREATE PROCEDURE usp_AFSearch
AS
DECLARE @SQL VARCHAR(8000)
SELECT @SQL = ISNULL(@SQL + ', ', ' ')...
August 18, 2006 at 3:04 am
CREATE proc SP_AFSearch
as
declare @Column as varchar(300),
@strquery as varchar(8000)
Declare CRS_AddColumn CURSOR FOR select syscolumns.name Name
from syscolumns
inner join sysobjects on sysobjects.ID = syscolumns.ID
where sysobjects.xtype = 'U'
and sysobjects.name = 'Store'
and syscolumns.name not...
August 18, 2006 at 2:55 am
Best way to go is to prefix all "dynamically created columns" with for example "dc_"
as "dc_ItemHeight" or "dc_ItemColor".
This way there is no confusion of which are "fixed" columns and dynamic...
August 18, 2006 at 2:49 am
DECLARE @BaseDate DATETIME
SELECT @BaseDate = '20060814'
SELECT DATEADD(week, b3.i + b2.i + b1.i + b0.i, @BaseDate),
DATEADD(day, 6, DATEADD(week, b3.i + b2.i + b1.i + b0.i, @BaseDate)),
count(*) as SomethingCounting
FROM (SELECT 0...
August 17, 2006 at 12:45 pm
Take a look in Books Online for BCP and queryout option.
August 17, 2006 at 12:41 pm
Here is a starter
DECLARE @BaseDate DATETIME
SELECT @BaseDate = '20060814'
SELECT DATEADD(week, b3.i + b2.i + b1.i + b0.i, @BaseDate)
FROM (SELECT 0 i UNION ALL SELECT 1) b0
CROSS JOIN (SELECT 0...
August 17, 2006 at 10:43 am
What if you have some million rows? Then that will take some time to complete...
August 17, 2006 at 7:40 am
Please do not cross post!
Your question has already been answered here
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=302310
August 17, 2006 at 7:06 am
Or more specialized.
CREATE FUNCTION dbo.fnIPv4_InRange
(
@CurrentIP VARCHAR(15),
@FromIP VARCHAR(15),
@ToIP VARCHAR(15)
)
RETURNS BIT
AS
BEGIN
DECLARE @CurrentNum BIGINT,
@FromNum BIGINT,
@ToNum BIGINT,
@InRange BIT
SELECT @CurrentNum = 16777216 * CAST(PARSENAME(@CurrentIP, 4) AS BIGINT) +
65536...
August 17, 2006 at 6:42 am
-- prepare test data
declare @bill table (billno int)
insert @bill
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 6
-- do the work
SELECT b.billno - 1 MissingNo
FROM @bill...
August 17, 2006 at 6:35 am
Strange with the error you say my code produces.
At least since I do not have either nvarchar not tinyint declarations...
August 17, 2006 at 6:22 am
Change DECLARE @sql VARCHAR(100) to
DECLARE @sql NVARCHAR(100).
That is one of the drawbacks for sp_executeSQL
August 17, 2006 at 6:19 am
Yes there is! But I agree with you that a CASE is more readable.
SELECT f.Country_Name
FROM (
SELECT Country_Name
FROM tblCountry
WHERE Country_ID = 26
UNION ALL
SELECT TOP 100...
August 17, 2006 at 5:38 am
Easy. Write like this
SELECT CASE
WHEN dbo.fnIPv4('193.194.227.51') BETWEEN dbo.fnIPv4('193.194.226.19') AND dbo.fnIPv4('194.193.1.1') THEN 'Yes'
ELSE 'No'
END
Where the function dbo.fnIPv4 looks like this
CREATE FUNCTION dbo.fnIPv4
(
@IP VARCHAR(15)
)
RETURNS BIGINT
AS
BEGIN
RETURN 16777216...
August 17, 2006 at 5:36 am
Rule number 1
ALWAYS USE
SET NOCOUNT ON
in stored procedures that have contact with ADO
August 17, 2006 at 5:24 am
Viewing 15 posts - 1,846 through 1,860 (of 2,171 total)