Viewing 15 posts - 121 through 135 (of 429 total)
Will be possible with dynamic SQL. I really don't understand why would you want to do that.
SET NOCOUNT ON
GO
CREATE TABLE Configuration
(
MyID INT
)
GO
CREATE TABLE AnyTable
(
myID INT
)
GO
CREATE TRIGGER [T1] ON [dbo].[Configuration]
FOR...
November 21, 2005 at 6:04 am
If the access is through an application using ADO via application user. Then connection string property can be used to specify the NT User as the parameter in connection string...
November 18, 2005 at 11:16 am
exec sp_MSforeachtable 'EXEC ( ''DECLARE @sql VARCHAR(1000) SELECT @sql = ''''?'''' + CHAR(9) + CONVERT(VARCHAR, COUNT(*)) FROM ? PRINT @sql'')'
November 18, 2005 at 11:10 am
How about this
exec sp_MSforeachtable 'EXEC ( ''SELECT TableName = ''''?'''', Rows = COUNT(*) FROM ?'')'
November 17, 2005 at 3:37 pm
That is a good solution. Uses correlation instead of cross join.
November 14, 2005 at 10:17 am
I would assume when the orginal poster said he wouldn't want to use cursor that goes for loops as well.
November 14, 2005 at 10:06 am
SET NOCOUNT ON
Declare @myTable TABLE
(
[Month] INT,
Users INT
)
INSERT @myTable
SELECT 1, 10 UNION
SELECT 2, 20 UNION
SELECT 3, 10 UNION
SELECT 4, 5 UNION
SELECT 5, 15
SELECT B.[Month],
B.Users,
SUM(CASE WHEN A.[Month] <= b.[Month] THEN A.Users ELSE 0 END) Cumulative
FROM
@myTable A
CROSS...
November 14, 2005 at 9:50 am
SET NOCOUNT ON
DECLARE @myTable TABLE
(
lname VARCHAR(10),
fname VARCHAR(10),
review_date DATETIME
)
INSERT @myTable
SELECT 'lname1', 'fname1', DATEADD(DAY, -11, GETDATE()) UNION
SELECT 'lname3', 'fname3', DATEADD(DAY, -10, GETDATE()) UNION
SELECT 'lname4', 'fname4', DATEADD(DAY, -9, GETDATE()) UNION
SELECT 'lname5', 'fname5', DATEADD(DAY, -8, GETDATE()) UNION
SELECT 'lname6', 'fname6', DATEADD(DAY, -7,...
November 11, 2005 at 2:37 pm
I guess there is confusion in What is ASC and DESC.
When there is no order by SQL Server would return the rows in ASC. When we specify DESC then it...
November 8, 2005 at 2:34 pm
HI Sergiy
Can you give an example. I tried that without success.
November 7, 2005 at 3:00 pm
It is not possible to insert into two tables with one insert statement.
November 7, 2005 at 6:55 am
/*I would make a design something like this*/
SET NOCOUNT ON
/* Data Table */
CREATE TABLE MyAcctsNew
(
Account VARCHAR(10),
DateYear DATETIME,
Amount NUMERIC(10,2)
)
INSERT MyAcctsNew
SELECT 'A', '01/01/2000', 250.00 UNION
SELECT 'A', '01/01/2001', 150.00 UNION
SELECT 'A', '01/01/2002', 180.00...
November 7, 2005 at 6:42 am
SET NOCOUNT ON
DECLARE @MyAccts TABLE
(
Account VARCHAR(10),
Year1 NUMERIC(10,2) NULL,
Year2 NUMERIC(10,2) NULL,
Year3 NUMERIC(10,2) NULL
)
INSERT @MyAccts
SELECT 'A1', 250.00, null, null UNION
SELECT 'A1', null, 150.00, null UNION
SELECT 'A1', null, null, 180.00
SELECT SUM(COALESCE(Year1, 0)) Year1, SUM(COALESCE(Year2,...
November 7, 2005 at 6:17 am
SET NOCOUNT ON
DECLARE @TransData TABLE
(
GLAcct VARCHAR(25),
AcctDetls VARCHAR(10)
)
INSERT @TransData
SELECT '1', 'AcctDetls1' UNION
SELECT '2', 'AcctDetls2' UNION
SELECT '3', 'AcctDetls3' UNION
SELECT '4', 'AcctDetls4' UNION
SELECT '5', 'AcctDetls5' UNION
SELECT '6', 'AcctDetls6' UNION
SELECT '7', 'AcctDetls7'
DECLARE @ExcludedGLAccounts...
November 1, 2005 at 1:37 pm
SET NOCOUNT ON
DECLARE @OldTable TABLE
(
StoreID INT,
WeekA NUMERIC(10,2),
WeekB NUMERIC(10,2),
WeekC NUMERIC(10,2),
WeekD NUMERIC(10,2),
WeekE NUMERIC(10,2)
)
INSERT INTO @OldTable
SELECT 1, 23.4, 43.5, 23.6, 45.6, 56.7 UNION
SELECT 2, 24.4, 73.5, 73.6, 45.7, 16.7 UNION
SELECT 3, 25.4, 63.5, 27.6, 43.6, 46.7
DECLARE @NewTable TABLE
(
StroreID INT,
WeekID VARCHAR(10), -- Iwould keep...
October 11, 2005 at 3:21 pm
Viewing 15 posts - 121 through 135 (of 429 total)