Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to write this in SQL Server 2008
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gaby_58
Starting Member

33 Posts

Posted - 11/13/2013 :  11:09:28  Show Profile  Reply with Quote
Hi all,

I have this Insert statement in Access, need to write the same in SQL Server, how to write this?

INSERT INTO Load ( LocationNumber, LocationNumber2, LocationId, PermitLocation, FilingLocation, ReportingId, DistrictId, StatusId
SELECT Original.MAST_ID, Original.WELL_ID, 0 AS expr1, [State_Name] & " " & [County_SL] AS Permit, [Oper_State] & " " & [Oper_City] AS Filing, 1 AS expr2, 0 AS expr3, 1 AS StatusId
FROM Original
WHERE (((Original.NEW_WELL)=True))AND ((Original.RecdDate)=#10/25/2013#));

Thanks for any support

sanjnep
Posting Yak Master

USA
191 Posts

Posted - 11/13/2013 :  12:39:12  Show Profile  Visit sanjnep's Homepage  Reply with Quote
INSERT INTO Load (LocationNumber, LocationNumber2, LocationId, PermitLocation, FilingLocation, ReportingId, DistrictId, StatusId)
SELECT
Original.MAST_ID,
Original.WELL_ID,
0 AS expr1,
[State_Name] + ' '+ [County_SL] AS Permit,
[Oper_State] + ' '+ [Oper_City] AS Filing,
1 AS expr2,
0 AS expr3,
1 AS StatusId
FROM Original
WHERE Original.NEW_WELL = 'True' AND Original.RecdDate ='10/25/2013'
Go to Top of Page

gaby_58
Starting Member

33 Posts

Posted - 11/13/2013 :  14:15:14  Show Profile  Reply with Quote
Thank you somuch, it worked..
Go to Top of Page

gaby_58
Starting Member

33 Posts

Posted - 11/15/2013 :  11:08:52  Show Profile  Reply with Quote
Would like to know if I have more where conditions like Original.Work = 'OD' or 'OD/LT' or 'OD/ST' along with Original.RecdDate, how to keep this in one sentence.

Thank You for your help.
Go to Top of Page

djj55
Constraint Violating Yak Guru

USA
352 Posts

Posted - 11/15/2013 :  12:15:13  Show Profile  Reply with Quote
Original.Work IN ('OD','OD/LT','OD/ST')

djj
Go to Top of Page

gaby_58
Starting Member

33 Posts

Posted - 11/15/2013 :  13:50:41  Show Profile  Reply with Quote
Thank You .
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000