sql-server-2005

Child sProc cannot reference a Local temp table created in parent sProc

ぃ、小莉子 提交于 2020-01-06 02:04:06
问题 On our production SQL2000 instance, we have a database with hundreds of stored procedures, many of which use a technique of creating a #TEMP table "early" on in the code and then various inner stored procedures get EXECUTEd by this parent sProc. In SQL2000, the inner or "child" sProc have no problem INSERTing into #TEMP or SELECTing data from #TEMP. In short, I assume they can all refer to this #TEMP because they use the same connection. In testing with SQL2008, I find 2 manifestations of

declare variables in sql ce

夙愿已清 提交于 2020-01-06 01:51:25
问题 I am tryin to get records from a table within a month in sql compact edition. Here is the sql query I know: DECLARE @startDate as DATETIME, @EndDate as DATETIME @startDate = GetDate(); @ENdDate = DATEADD(m,1,@startDate) select * from table where (columnname between @startdate and @enddate) I know that you have to send one script at a time, but how can you declare variables in sql ce(I guess it doesn't accept declare)? 回答1: I think my answer is very late for this question, but hope it will be

Where should the partitioning column go in the primary key on SQL Server?

瘦欲@ 提交于 2020-01-06 01:46:48
问题 Using SQL Server 2005 and 2008. I've got a potentially very large table (potentially hundreds of millions of rows) consisting of the following columns: CREATE TABLE ( date SMALLDATETIME, id BIGINT, value FLOAT ) which is being partitioned on column date in daily partitions. The question then is should the primary key be on date, id or value, id ? I can imagine that SQL Server is smart enough to know that it's already partitioning on date and therefore, if I'm always querying for whole chunks

How to call an extended procedure from a function

吃可爱长大的小学妹 提交于 2020-01-05 13:32:03
问题 hi im having trouble trying to get the following function to work. CREATE FUNCTION test ( @nt_group VARCHAR(128) ) RETURNS @nt_usr TABLE ( [name] [nchar](128) NULL , [type] [char](8) NULL , [privilege] [char](9) NULL , [mapped login name] [nchar](128) NULL , [permission path] [nchar](128) NULL ) AS BEGIN INSERT INTO @nt_usr EXEC master.dbo.xp_logininfo 'DOMAIN\USER', @nt_group RETURN END As far as i know i should be allowed to call an extended stored procedure, im getting the following error

How to call an extended procedure from a function

陌路散爱 提交于 2020-01-05 13:31:25
问题 hi im having trouble trying to get the following function to work. CREATE FUNCTION test ( @nt_group VARCHAR(128) ) RETURNS @nt_usr TABLE ( [name] [nchar](128) NULL , [type] [char](8) NULL , [privilege] [char](9) NULL , [mapped login name] [nchar](128) NULL , [permission path] [nchar](128) NULL ) AS BEGIN INSERT INTO @nt_usr EXEC master.dbo.xp_logininfo 'DOMAIN\USER', @nt_group RETURN END As far as i know i should be allowed to call an extended stored procedure, im getting the following error

How to call an extended procedure from a function

旧时模样 提交于 2020-01-05 13:31:08
问题 hi im having trouble trying to get the following function to work. CREATE FUNCTION test ( @nt_group VARCHAR(128) ) RETURNS @nt_usr TABLE ( [name] [nchar](128) NULL , [type] [char](8) NULL , [privilege] [char](9) NULL , [mapped login name] [nchar](128) NULL , [permission path] [nchar](128) NULL ) AS BEGIN INSERT INTO @nt_usr EXEC master.dbo.xp_logininfo 'DOMAIN\USER', @nt_group RETURN END As far as i know i should be allowed to call an extended stored procedure, im getting the following error

SQL Server - Transactional Replication (partial data only)

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 12:13:09
问题 I have 6 months of data, how do I replicate only the most current 3 months of data to the subscribers? 回答1: You can use filtered replication. When you read examples about filtered replication, you'll probably see it referring to a branch office scenario where a single central office stores data for several branch offices, and each branch only wants to replicate their own data. It involves creating filters on a key, and in your case, you'll want to use your date range as the key. Here's an

SQL Server - Transactional Replication (partial data only)

拜拜、爱过 提交于 2020-01-05 12:11:18
问题 I have 6 months of data, how do I replicate only the most current 3 months of data to the subscribers? 回答1: You can use filtered replication. When you read examples about filtered replication, you'll probably see it referring to a branch office scenario where a single central office stores data for several branch offices, and each branch only wants to replicate their own data. It involves creating filters on a key, and in your case, you'll want to use your date range as the key. Here's an

finding local maximums and local minimums in SQL

让人想犯罪 __ 提交于 2020-01-05 09:12:57
问题 In order to find the max draw down of a stock price versus time graph, you first have to find all local maximums (peaks) and local minimums (valleys) for a given set of prices and days. How would you do this in SQL Server 2005? edit: There is a brute force way of doing this with cursors: compare the high of the first day to the high of the next day. if the high of the first day is higher than the high of the next day, the high of the first day is a local Max. effectively, I need to find every

SQL Server query to group sequential date data

梦想的初衷 提交于 2020-01-05 08:31:06
问题 I have got a bit of 'brain fade' going on this afternoon, so if anyone can help with this mssql query it would be fantastic. I have a table called 'seasons' with three columns (there are more but not relevant to the example): seasonId, date, tariffId SeasonId is a unique key. A date can only have one tariffid, but a tariffId can have many different dates. For example: seasonId | date | tariffId ---------------------------------- 1 | 1 jan 2009 | 1 2 | 2 jan 2009 | 1 3 | 3 jan 2009 | 2 4 | 4