Viewing 15 posts - 1,081 through 1,095 (of 2,038 total)
Hi Bruce
This works correct, but why access the table twice? My first post should also work without accessing UserStats twice:
SELECT @UserId = 2
INSERT INTO dbo.UserStats
SELECT @UserId
...
May 6, 2009 at 4:30 pm
Sure, the variable has only one value, but your SELECT might return many:
DECLARE @UserStats TABLE (UserId INT)
INSERT INTO @UserStats
...
May 6, 2009 at 4:20 pm
Hi
I just tried on SQL Server 2008 and this seems to work:
CREATE TABLE TestDefault (Id INT)
GO
INSERT INTO TestDefault SELECT 1
GO
ALTER TABLE TestDefault ADD Dt DATETIME NOT NULL DEFAULT GETDATE()
GO
SELECT *...
May 6, 2009 at 4:17 pm
Lynn, please correct me if I'm wrong but the original code would only once insert the @UserId if does not yet exist. Your code seems to create a new row...
May 6, 2009 at 4:09 pm
Alvin Ramard (5/6/2009)
And Flo?
Nothing to hide. Just updated my profile picture 😉
May 6, 2009 at 3:07 pm
Great feature, [] works even for multi-line:
CREATE TABLE [
] ([.] INT, [
] INT, [ ]]
] INT,"""" INT)
INSERT INTO [
] SELECT 1, 2, 3, 4
SELECT []]].[
], [,].[ ]]
] [[], [,].["],[[[
].[
],[,].[.]
FROM [
]...
May 6, 2009 at 2:55 pm
Hi
Because you said that neither linked server nor openrowset is an option I think there is no other way than a server-client-server transfer.
* Create a temp table (or a stateful...
May 6, 2009 at 2:24 pm
:sick:
CREATE SCHEMA [%]
GO
CREATE TABLE [%].[%] (Id INT IDENTITY PRIMARY KEY, i INT, [-] INT, [AND] INT, [*] INT, [%] VARCHAR(10))
CREATE INDEX [master.sys.objects] ON [%].[%] ([-]) INCLUDE ([*])
INSERT INTO [%].[%] SELECT...
May 6, 2009 at 2:15 pm
So, if your application currently works, why not just a "BEGIN TRANSACTION" at start and a "COMMIT TRANSACTION" after all was done?
Another approach, to avoid a long time lock might...
May 6, 2009 at 1:49 pm
😀
Just one thing missing:
DECLARE @t TABLE (Id INT, [*] VARCHAR(10))
INSERT INTO @t SELECT 1, 'abc'
SELECT [*] FROM @t
Hope The Thread forgives this kind of source code!
May 6, 2009 at 1:30 pm
Just to ensure, if you say "Linked server" is not an option. Does this include "OPENROWSET"?
May 6, 2009 at 1:26 pm
Bob Hovious (5/6/2009)
Thankfully, I have yet to see a column named [NULL].
Sorry, forgot: How often did you have a column "Group" or even "From" (and "To") 😀
May 6, 2009 at 1:19 pm
I noticed the sarcasm and I noticed the 'NULL'. I've just been bothered by the thread. If the question would be this don't work:
SELECT blah FROM anywhere
UNION ALL
SELECT 'NULL'
.. I...
May 6, 2009 at 1:16 pm
Hi
What about just a simple INSERT SELECT WHERE:
DECLARE @users TABLE (Id INT)
DECLARE @UserId INT
-- New user
SELECT @UserId = 1
INSERT INTO @users
SELECT @UserId
WHERE NOT EXISTS...
May 6, 2009 at 1:01 pm
Alvin,
I have to confirm Bob. Because I am more a C#y than a VBly I would say "null" is always better than "Nothing"
BTW: In contrast to Bob I really hope...
May 6, 2009 at 12:54 pm
Viewing 15 posts - 1,081 through 1,095 (of 2,038 total)