May 25, 2012 at 12:21 pm
hi
how can i add something like this in table
account's value
insert into @temp1('account's value')
getting error?
May 25, 2012 at 12:36 pm
Use the following
insert into @temp1 select "account's value"
or
insert into@ temp1 select 'account''s value')
GulliMeel
Finding top n Worst Performing queries[/url]
Improve the performance of Merge Join(special case)
How to Post Performance Problem -Gail Shaw[/url]
May 25, 2012 at 1:23 pm
Look up the INSERT statement syntax in Books Online.
Really not enough info to tell you more, but then you already know that.
May 26, 2012 at 7:19 am
Gullimeel (5/25/2012)
Use the followinginsert into @temp1 select "account's value"
Msg 207, Level 16, State 1, Line 2
Invalid column name 'account's value'.
or
insert into@ temp1 select 'account''s value')
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'temp1'.
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
May 26, 2012 at 7:29 am
Link to INSERT documentation: http://msdn.microsoft.com/en-us/library/ms174335(v=sql.105).aspx
Example code:
DECLARE @temp1 AS TABLE
(
account_id char(5) NOT NULL
CHECK (account_id LIKE '[A-Z][A-Z][0-9][0-9][0-9]'),
as_of_date date NOT NULL
CHECK (as_of_date <= CONVERT(date, GETDATE())),
balance money NOT NULL,
PRIMARY KEY (account_id, as_of_date)
)
INSERT INTO @temp1
(account_id, as_of_date, balance)
VALUES
('AF167', '2012-05-25', $504.91),
('AF167', '2012-05-26', $761.33),
('AF167', '2012-05-27', $664.87),
('DQ042', '2012-05-26', $730.55),
('DQ042', '2012-05-27', $709.72);
SELECT
t.account_id,
t.as_of_date,
t.balance
FROM @temp1 AS t
ORDER BY
t.account_id,
t.as_of_date;
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
May 28, 2012 at 12:43 am
This will work:
--Creating table
Create Table Ex
(ac varchar(30) )
--Insert Query For Your Requirement
Insert Into Ex Values('Account''s Value')
--Checking the Inserted Value
Select * From Ex
May 29, 2012 at 9:08 am
thanks everyone
May 29, 2012 at 10:38 pm
May 30, 2012 at 12:15 am
use
insert into @temp1('account'+'''+'s value')
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply